mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Use specific ESP name in error messages.
Change (e.g.,) "ESP API response 400" to "Mailgun API response 400".
This commit is contained in:
@@ -289,12 +289,8 @@ class SparkPostBackendStandardEmailTests(SparkPostBackendMockAPITestCase):
|
||||
self.assertNotIn('recipients', params)
|
||||
|
||||
def test_api_failure(self):
|
||||
failure_response = b"""{ "errors": [ {
|
||||
"message": "Something went wrong",
|
||||
"description": "Helpful explanation from your ESP"
|
||||
} ] }"""
|
||||
self.set_mock_failure(raw=failure_response)
|
||||
with self.assertRaisesMessage(AnymailAPIError, "Helpful explanation from your ESP"):
|
||||
self.set_mock_failure(status_code=400)
|
||||
with self.assertRaisesMessage(AnymailAPIError, "SparkPost API response 400"):
|
||||
self.message.send()
|
||||
|
||||
def test_api_failure_fail_silently(self):
|
||||
@@ -303,6 +299,16 @@ class SparkPostBackendStandardEmailTests(SparkPostBackendMockAPITestCase):
|
||||
sent = self.message.send(fail_silently=True)
|
||||
self.assertEqual(sent, 0)
|
||||
|
||||
def test_api_error_includes_details(self):
|
||||
"""AnymailAPIError should include ESP's error message"""
|
||||
failure_response = b"""{ "errors": [ {
|
||||
"message": "Something went wrong",
|
||||
"description": "Helpful explanation from your ESP"
|
||||
} ] }"""
|
||||
self.set_mock_failure(raw=failure_response)
|
||||
with self.assertRaisesMessage(AnymailAPIError, "Helpful explanation from your ESP"):
|
||||
self.message.send()
|
||||
|
||||
|
||||
class SparkPostBackendAnymailFeatureTests(SparkPostBackendMockAPITestCase):
|
||||
"""Test backend support for Anymail added features"""
|
||||
|
||||
Reference in New Issue
Block a user