From bc8ef9af0fc7a5a9e4b3231f9c2cf5c4cd9ed0ac Mon Sep 17 00:00:00 2001 From: Mike Edmunds Date: Tue, 27 Jun 2023 12:25:13 -0700 Subject: [PATCH] Tests: update Postmark integration Postmark has changed their error message for invalid server token. (Also, we don't care about the specific error code, just that the error is caught and reported.) --- tests/test_postmark_integration.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/test_postmark_integration.py b/tests/test_postmark_integration.py index b2712ae..3d240ed 100644 --- a/tests/test_postmark_integration.py +++ b/tests/test_postmark_integration.py @@ -132,9 +132,8 @@ class PostmarkBackendIntegrationTests(AnymailTestMixin, SimpleTestCase): @override_settings(ANYMAIL_POSTMARK_SERVER_TOKEN="Hey, that's not a server token!") def test_invalid_server_token(self): - with self.assertRaises(AnymailAPIError) as cm: + # Message will include something like + # "Request does not contain a valid Server token" + # or "Please verify that you are using a valid token" + with self.assertRaisesRegex(AnymailAPIError, r"valid.*token"): self.message.send() - err = cm.exception - self.assertEqual(err.status_code, 401) - # Make sure the exception message includes Postmark's response: - self.assertIn("Please verify that you are using a valid token", str(err))