From d079a506a12af433a9590c15b84e237d3dbf53ad Mon Sep 17 00:00:00 2001 From: medmunds Date: Fri, 6 Apr 2018 15:28:55 -0700 Subject: [PATCH] Tests: better recipient addresses for live integration tests Some ESPs have special blacklist handling for mailinator.com; switch to (deliverable, blackholed) anymail.info test addresses. --- tests/test_mailgun_integration.py | 20 ++++++++++---------- tests/test_mailjet_integration.py | 28 ++++++++++++++-------------- tests/test_mandrill_integration.py | 12 ++++++------ tests/test_postmark_integration.py | 12 ++++++------ tests/test_sendinblue_integration.py | 14 +++++++------- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/tests/test_mailgun_integration.py b/tests/test_mailgun_integration.py index 0017ef3..e5bad34 100644 --- a/tests/test_mailgun_integration.py +++ b/tests/test_mailgun_integration.py @@ -38,7 +38,7 @@ class MailgunBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): def setUp(self): super(MailgunBackendIntegrationTests, self).setUp() self.message = AnymailMessage('Anymail Mailgun integration test', 'Text content', - 'from@example.com', ['anymail-test-to1@mailinator.com']) + 'from@example.com', ['test+to1@anymail.info']) self.message.attach_alternative('

HTML content

', "text/html") def fetch_mailgun_events(self, message_id, event=None, @@ -87,8 +87,8 @@ class MailgunBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): self.assertEqual(sent_count, 1) anymail_status = self.message.anymail_status - sent_status = anymail_status.recipients['anymail-test-to1@mailinator.com'].status - message_id = anymail_status.recipients['anymail-test-to1@mailinator.com'].message_id + sent_status = anymail_status.recipients['test+to1@anymail.info'].status + message_id = anymail_status.recipients['test+to1@anymail.info'].message_id self.assertEqual(sent_status, 'queued') # Mailgun always queues self.assertGreater(len(message_id), 0) # don't know what it'll be, but it should exist @@ -103,9 +103,9 @@ class MailgunBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): subject="Anymail Mailgun all-options integration test", body="This is the text body", from_email="Test From , also-from@example.com", - to=["anymail-test-to1@mailinator.com", "Recipient 2 "], - cc=["anymail-test-cc1@mailinator.com", "Copy 2 "], - bcc=["anymail-test-bcc1@mailinator.com", "Blind Copy 2 "], + to=["test+to1@anymail.info", "Recipient 2 "], + cc=["test+cc1@anymail.info", "Copy 2 "], + bcc=["test+bcc1@anymail.info", "Blind Copy 2 "], reply_to=["reply1@example.com", "Reply 2 "], headers={"X-Anymail-Test": "value"}, @@ -137,14 +137,14 @@ class MailgunBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): {"meta1": "simple string", "meta2": "2"}) # all metadata values become strings self.assertEqual(event["message"]["scheduled-for"], send_at_timestamp) - self.assertIn(event["recipient"], ['anymail-test-to1@mailinator.com', 'anymail-test-to2@mailinator.com', - 'anymail-test-cc1@mailinator.com', 'anymail-test-cc1@mailinator.com', - 'anymail-test-bcc1@mailinator.com', 'anymail-test-bcc2@mailinator.com']) + self.assertIn(event["recipient"], ['test+to1@anymail.info', 'test+to2@anymail.info', + 'test+cc1@anymail.info', 'test+cc1@anymail.info', + 'test+bcc1@anymail.info', 'test+bcc2@anymail.info']) headers = event["message"]["headers"] self.assertEqual(headers["from"], "Test From , also-from@example.com") self.assertEqual(headers["to"], - "anymail-test-to1@mailinator.com, Recipient 2 ") + "test+to1@anymail.info, Recipient 2 ") self.assertEqual(headers["subject"], "Anymail Mailgun all-options integration test") attachments = event["message"]["attachments"] diff --git a/tests/test_mailjet_integration.py b/tests/test_mailjet_integration.py index e82d79c..64ec197 100644 --- a/tests/test_mailjet_integration.py +++ b/tests/test_mailjet_integration.py @@ -39,7 +39,7 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): def setUp(self): super(MailjetBackendIntegrationTests, self).setUp() self.message = AnymailMessage('Anymail Mailjet integration test', 'Text content', - 'test@test-mj.anymail.info', ['anymail-test-to1@mailinator.com']) + 'test@test-mj.anymail.info', ['test+to1@anymail.info']) self.message.attach_alternative('

HTML content

', "text/html") def test_simple_send(self): @@ -48,8 +48,8 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): self.assertEqual(sent_count, 1) anymail_status = self.message.anymail_status - sent_status = anymail_status.recipients['anymail-test-to1@mailinator.com'].status - message_id = anymail_status.recipients['anymail-test-to1@mailinator.com'].message_id + sent_status = anymail_status.recipients['test+to1@anymail.info'].status + message_id = anymail_status.recipients['test+to1@anymail.info'].message_id self.assertEqual(sent_status, 'sent') self.assertRegex(message_id, r'.+') @@ -61,9 +61,9 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): subject="Anymail Mailjet all-options integration test", body="This is the text body", from_email='"Test Sender, Inc." ', - to=['anymail-test-to1@mailinator.com', '"Recipient, 2nd" '], - cc=['anymail-test-cc1@mailinator.com', 'Copy 2 '], - bcc=['anymail-test-bcc1@mailinator.com', 'Blind Copy 2 '], + to=['test+to1@anymail.info', '"Recipient, 2nd" '], + cc=['test+cc1@anymail.info', 'Copy 2 '], + bcc=['test+bcc1@anymail.info', 'Blind Copy 2 '], reply_to=['reply1@example.com', '"Reply, 2nd" '], headers={"X-Anymail-Test": "value"}, @@ -89,10 +89,10 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): body="This body includes merge data: [[var:value]]\n" "And global merge data: [[var:global]]", from_email="Test From ", - to=["anymail-test-to1@mailinator.com", "Recipient 2 "], + to=["test+to1@anymail.info", "Recipient 2 "], merge_data={ - 'anymail-test-to1@mailinator.com': {'value': 'one'}, - 'anymail-test-to2@mailinator.com': {'value': 'two'}, + 'test+to1@anymail.info': {'value': 'one'}, + 'test+to2@anymail.info': {'value': 'two'}, }, merge_global_data={ 'global': 'global_value' @@ -100,15 +100,15 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): ) message.send() recipient_status = message.anymail_status.recipients - self.assertEqual(recipient_status['anymail-test-to1@mailinator.com'].status, 'sent') - self.assertEqual(recipient_status['anymail-test-to2@mailinator.com'].status, 'sent') + self.assertEqual(recipient_status['test+to1@anymail.info'].status, 'sent') + self.assertEqual(recipient_status['test+to2@anymail.info'].status, 'sent') def test_stored_template(self): message = AnymailMessage( template_id='176375', # ID of the real template named 'test-template' in our Mailjet test account - to=["anymail-test-to1@mailinator.com"], + to=["test+to1@anymail.info"], merge_data={ - 'anymail-test-to1@mailinator.com': { + 'test+to1@anymail.info': { 'name': "Test Recipient", } }, @@ -119,7 +119,7 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): message.from_email = None # use the template's sender email/name message.send() recipient_status = message.anymail_status.recipients - self.assertEqual(recipient_status['anymail-test-to1@mailinator.com'].status, 'sent') + self.assertEqual(recipient_status['test+to1@anymail.info'].status, 'sent') @override_settings(ANYMAIL_MAILJET_API_KEY="Hey, that's not an API key!") def test_invalid_api_key(self): diff --git a/tests/test_mandrill_integration.py b/tests/test_mandrill_integration.py index 2b09d9a..2c775af 100644 --- a/tests/test_mandrill_integration.py +++ b/tests/test_mandrill_integration.py @@ -33,7 +33,7 @@ class MandrillBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): def setUp(self): super(MandrillBackendIntegrationTests, self).setUp() self.message = mail.EmailMultiAlternatives('Anymail Mandrill integration test', 'Text content', - 'from@example.com', ['anymail-test-to1@mailinator.com']) + 'from@example.com', ['test+to1@anymail.info']) self.message.attach_alternative('

HTML content

', "text/html") def test_simple_send(self): @@ -43,8 +43,8 @@ class MandrillBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): # noinspection PyUnresolvedReferences anymail_status = self.message.anymail_status - sent_status = anymail_status.recipients['anymail-test-to1@mailinator.com'].status - message_id = anymail_status.recipients['anymail-test-to1@mailinator.com'].message_id + sent_status = anymail_status.recipients['test+to1@anymail.info'].status + message_id = anymail_status.recipients['test+to1@anymail.info'].message_id self.assertIn(sent_status, ['sent', 'queued']) # successful send (could still bounce later) self.assertGreater(len(message_id), 0) # don't know what it'll be, but it should exist @@ -57,9 +57,9 @@ class MandrillBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): subject="Anymail Mandrill all-options integration test", body="This is the text body", from_email="Test From ", - to=["anymail-test-to1@mailinator.com", "Recipient 2 "], - cc=["anymail-test-cc1@mailinator.com", "Copy 2 "], - bcc=["anymail-test-bcc1@mailinator.com", "Blind Copy 2 "], + to=["test+to1@anymail.info", "Recipient 2 "], + cc=["test+cc1@anymail.info", "Copy 2 "], + bcc=["test+bcc1@anymail.info", "Blind Copy 2 "], reply_to=["reply1@example.com", "Reply 2 "], headers={"X-Anymail-Test": "value"}, diff --git a/tests/test_postmark_integration.py b/tests/test_postmark_integration.py index 2f652d4..aff182b 100644 --- a/tests/test_postmark_integration.py +++ b/tests/test_postmark_integration.py @@ -22,7 +22,7 @@ class PostmarkBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): def setUp(self): super(PostmarkBackendIntegrationTests, self).setUp() self.message = AnymailMessage('Anymail Postmark integration test', 'Text content', - 'from@example.com', ['anymail-test-to1@mailinator.com']) + 'from@example.com', ['test+to1@anymail.info']) self.message.attach_alternative('

HTML content

', "text/html") def test_simple_send(self): @@ -31,8 +31,8 @@ class PostmarkBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): self.assertEqual(sent_count, 1) anymail_status = self.message.anymail_status - sent_status = anymail_status.recipients['anymail-test-to1@mailinator.com'].status - message_id = anymail_status.recipients['anymail-test-to1@mailinator.com'].message_id + sent_status = anymail_status.recipients['test+to1@anymail.info'].status + message_id = anymail_status.recipients['test+to1@anymail.info'].message_id self.assertEqual(sent_status, 'sent') self.assertGreater(len(message_id), 0) # non-empty string @@ -45,9 +45,9 @@ class PostmarkBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): body="This is the text body", # Postmark accepts multiple from_email addresses, but truncates to the first on their end from_email="Test From , also-from@example.com", - to=["anymail-test-to1@mailinator.com", "Recipient 2 "], - cc=["anymail-test-cc1@mailinator.com", "Copy 2 "], - bcc=["anymail-test-bcc1@mailinator.com", "Blind Copy 2 "], + to=["test+to1@anymail.info", "Recipient 2 "], + cc=["test+cc1@anymail.info", "Copy 2 "], + bcc=["test+bcc1@anymail.info", "Blind Copy 2 "], reply_to=["reply1@example.com", "Reply 2 "], headers={"X-Anymail-Test": "value"}, diff --git a/tests/test_sendinblue_integration.py b/tests/test_sendinblue_integration.py index fc31639..c4c0989 100644 --- a/tests/test_sendinblue_integration.py +++ b/tests/test_sendinblue_integration.py @@ -35,7 +35,7 @@ class SendinBlueBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): super(SendinBlueBackendIntegrationTests, self).setUp() self.message = AnymailMessage('Anymail SendinBlue integration test', 'Text content', - 'from@test-sb.anymail.info', ['anymail-test-to1@mailinator.com']) + 'from@test-sb.anymail.info', ['test+to1@anymail.info']) self.message.attach_alternative('

HTML content

', "text/html") def test_simple_send(self): @@ -44,8 +44,8 @@ class SendinBlueBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): self.assertEqual(sent_count, 1) anymail_status = self.message.anymail_status - sent_status = anymail_status.recipients['anymail-test-to1@mailinator.com'].status - message_id = anymail_status.recipients['anymail-test-to1@mailinator.com'].message_id + sent_status = anymail_status.recipients['test+to1@anymail.info'].status + message_id = anymail_status.recipients['test+to1@anymail.info'].message_id self.assertEqual(sent_status, 'queued') # SendinBlue always queues self.assertRegex(message_id, r'\<.+@.+\>') # Message-ID can be ...@smtp-relay.mail.fr or .sendinblue.com @@ -57,9 +57,9 @@ class SendinBlueBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): subject="Anymail SendinBlue all-options integration test", body="This is the text body", from_email='"Test From, with comma" ', - to=["anymail-test-to1@mailinator.com", '"Recipient 2, OK?" '], - cc=["anymail-test-cc1@mailinator.com", "Copy 2 "], - bcc=["anymail-test-bcc1@mailinator.com", "Blind Copy 2 "], + to=["test+to1@anymail.info", '"Recipient 2, OK?" '], + cc=["test+cc1@anymail.info", "Copy 2 "], + bcc=["test+bcc1@anymail.info", "Blind Copy 2 "], reply_to=['"Reply, with comma" '], # SendinBlue API v3 only supports single reply-to headers={"X-Anymail-Test": "value", "X-Anymail-Count": 3}, @@ -78,7 +78,7 @@ class SendinBlueBackendIntegrationTests(SimpleTestCase, AnymailTestMixin): def test_template(self): message = AnymailMessage( template_id=1, # There is a template with this id in the Anymail test account - to=["anymail-test-to1@mailinator.com"], # SendinBlue doesn't allow recipient display names with templates + to=["test+to1@anymail.info"], # SendinBlue doesn't allow recipient display names with templates reply_to=["reply@example.com"], tags=["using-template"], headers={"X-Anymail-Test": "group: A, variation: C"},