Tests: update Mandrill integration

Mandrill has changed status code for
invalid from_email from 500 to 400.
(We don't actually care about the specific
code, just that the error is caught and
reported.)
This commit is contained in:
Mike Edmunds
2023-06-27 12:23:35 -07:00
parent 8a72f89e8a
commit 4f4461af4d

View File

@@ -108,15 +108,11 @@ class MandrillBackendIntegrationTests(AnymailTestMixin, SimpleTestCase):
def test_invalid_from(self): def test_invalid_from(self):
# Example of trying to send from an invalid address # Example of trying to send from an invalid address
# Mandrill returns a 500 response (which raises a MandrillAPIError)
self.message.from_email = ( self.message.from_email = (
"webmaster@localhost" # Django default DEFAULT_FROM_EMAIL "webmaster@localhost" # Django default DEFAULT_FROM_EMAIL
) )
with self.assertRaises(AnymailAPIError) as cm: with self.assertRaisesMessage(AnymailAPIError, "email address is invalid"):
self.message.send() self.message.send()
err = cm.exception
self.assertEqual(err.status_code, 500)
self.assertIn("email address is invalid", str(err))
def test_invalid_to(self): def test_invalid_to(self):
# Example of detecting when a recipient is not a valid email address # Example of detecting when a recipient is not a valid email address