How to use the sparkpost.tornado.SparkPostAPIException function in sparkpost

To help you get started, we’ve selected a few sparkpost examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SparkPost / python-sparkpost / test / tornado / test_tornado.py View on Github external
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)
github SparkPost / python-sparkpost / test / tornado / test_tornado.py View on Github external
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)