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_get():
responses.add(
responses.GET,
'https://api.sparkpost.com/api/v1/transmissions/foobar',
status=404,
content_type='application/json',
body="""
{"errors": [{"message": "cant find", "description": "where you go"}]}
"""
)
with pytest.raises(SparkPostAPIException):
sp = SparkPost('fake-key')
def send():
return sp.transmission.get('foobar')
ioloop.IOLoop().run_sync(send, timeout=3)
def test_fail_send():
responses.add(
responses.POST,
'https://api.sparkpost.com/api/v1/transmissions',
status=500,
content_type='application/json',
body="""
{"errors": [{"message": "You failed", "description": "More Info"}]}
"""
)
with pytest.raises(SparkPostAPIException):
sp = SparkPost('fake-key')
ioloop.IOLoop().run_sync(sp.transmission.send)