Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_fail_silently():
# should not raise
with mock.patch.object(Transmissions, 'send') as mock_send:
mock_send.side_effect = Exception('i should not be raised')
mailer(get_params({'fail_silently': True}))
# should raise
with mock.patch.object(Transmissions, 'send') as mock_send:
mock_send.side_effect = Exception('i should be raised')
with pytest.raises(Exception):
mailer(get_params())
api_key = self.get_api_key()
if not api_key:
raise SparkPostException("No API key. Improve message.")
self.base_uri = 'https://' + base_uri + '/api/v' + version
self.api_key = api_key
self.metrics = Metrics(self.base_uri, self.api_key,
self.TRANSPORT_CLASS)
self.recipient_lists = RecipientLists(self.base_uri, self.api_key,
self.TRANSPORT_CLASS)
self.suppression_list = SuppressionList(self.base_uri, self.api_key,
self.TRANSPORT_CLASS)
self.templates = Templates(self.base_uri, self.api_key,
self.TRANSPORT_CLASS)
self.transmissions = Transmissions(self.base_uri, self.api_key,
self.TRANSPORT_CLASS)
# Keeping self.transmission for backwards compatibility.
# Will be removed in a future release.
self.transmission = self.transmissions