Skip to content

Commit c58640d

Browse files
authored
Mandrill: update integration test
Mandrill bad API key can respond either 401 or 500, so don't bother checking exact status code. (Just make sure it results in a useful error.)
1 parent ea446a9 commit c58640d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tests/test_mandrill_integration.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,9 @@ def test_rejected_to(self):
171171

172172
@override_settings(MANDRILL_API_KEY="Hey, that's not an API key!")
173173
def test_invalid_api_key(self):
174-
# Example of trying to send with an invalid MANDRILL_API_KEY
175-
with self.assertRaises(AnymailAPIError) as cm:
174+
# Example of trying to send with an invalid MANDRILL_API_KEY.
175+
# Mandrill responds either 401 or 500 status for this case (it varies),
176+
# but always seems to include the message "Invalid API key".
177+
# Either response should result in an AnymailAPIError.
178+
with self.assertRaisesMessage(AnymailAPIError, "Invalid API key"):
176179
self.message.send()
177-
err = cm.exception
178-
self.assertEqual(err.status_code, 500)
179-
# Make sure the exception message includes Mandrill's response:
180-
self.assertIn("Invalid API key", str(err))

0 commit comments

Comments
 (0)