mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
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.
This commit is contained in:
@@ -38,7 +38,7 @@ class MailgunBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(MailgunBackendIntegrationTests, self).setUp()
|
super(MailgunBackendIntegrationTests, self).setUp()
|
||||||
self.message = AnymailMessage('Anymail Mailgun integration test', 'Text content',
|
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('<p>HTML content</p>', "text/html")
|
self.message.attach_alternative('<p>HTML content</p>', "text/html")
|
||||||
|
|
||||||
def fetch_mailgun_events(self, message_id, event=None,
|
def fetch_mailgun_events(self, message_id, event=None,
|
||||||
@@ -87,8 +87,8 @@ class MailgunBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
self.assertEqual(sent_count, 1)
|
self.assertEqual(sent_count, 1)
|
||||||
|
|
||||||
anymail_status = self.message.anymail_status
|
anymail_status = self.message.anymail_status
|
||||||
sent_status = anymail_status.recipients['anymail-test-to1@mailinator.com'].status
|
sent_status = anymail_status.recipients['test+to1@anymail.info'].status
|
||||||
message_id = anymail_status.recipients['anymail-test-to1@mailinator.com'].message_id
|
message_id = anymail_status.recipients['test+to1@anymail.info'].message_id
|
||||||
|
|
||||||
self.assertEqual(sent_status, 'queued') # Mailgun always queues
|
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
|
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",
|
subject="Anymail Mailgun all-options integration test",
|
||||||
body="This is the text body",
|
body="This is the text body",
|
||||||
from_email="Test From <from@example.com>, also-from@example.com",
|
from_email="Test From <from@example.com>, also-from@example.com",
|
||||||
to=["anymail-test-to1@mailinator.com", "Recipient 2 <anymail-test-to2@mailinator.com>"],
|
to=["test+to1@anymail.info", "Recipient 2 <test+to2@anymail.info>"],
|
||||||
cc=["anymail-test-cc1@mailinator.com", "Copy 2 <anymail-test-cc2@mailinator.com>"],
|
cc=["test+cc1@anymail.info", "Copy 2 <test+cc2@anymail.info>"],
|
||||||
bcc=["anymail-test-bcc1@mailinator.com", "Blind Copy 2 <anymail-test-bcc2@mailinator.com>"],
|
bcc=["test+bcc1@anymail.info", "Blind Copy 2 <test+bcc2@anymail.info>"],
|
||||||
reply_to=["reply1@example.com", "Reply 2 <reply2@example.com>"],
|
reply_to=["reply1@example.com", "Reply 2 <reply2@example.com>"],
|
||||||
headers={"X-Anymail-Test": "value"},
|
headers={"X-Anymail-Test": "value"},
|
||||||
|
|
||||||
@@ -137,14 +137,14 @@ class MailgunBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
{"meta1": "simple string", "meta2": "2"}) # all metadata values become strings
|
{"meta1": "simple string", "meta2": "2"}) # all metadata values become strings
|
||||||
|
|
||||||
self.assertEqual(event["message"]["scheduled-for"], send_at_timestamp)
|
self.assertEqual(event["message"]["scheduled-for"], send_at_timestamp)
|
||||||
self.assertIn(event["recipient"], ['anymail-test-to1@mailinator.com', 'anymail-test-to2@mailinator.com',
|
self.assertIn(event["recipient"], ['test+to1@anymail.info', 'test+to2@anymail.info',
|
||||||
'anymail-test-cc1@mailinator.com', 'anymail-test-cc1@mailinator.com',
|
'test+cc1@anymail.info', 'test+cc1@anymail.info',
|
||||||
'anymail-test-bcc1@mailinator.com', 'anymail-test-bcc2@mailinator.com'])
|
'test+bcc1@anymail.info', 'test+bcc2@anymail.info'])
|
||||||
|
|
||||||
headers = event["message"]["headers"]
|
headers = event["message"]["headers"]
|
||||||
self.assertEqual(headers["from"], "Test From <from@example.com>, also-from@example.com")
|
self.assertEqual(headers["from"], "Test From <from@example.com>, also-from@example.com")
|
||||||
self.assertEqual(headers["to"],
|
self.assertEqual(headers["to"],
|
||||||
"anymail-test-to1@mailinator.com, Recipient 2 <anymail-test-to2@mailinator.com>")
|
"test+to1@anymail.info, Recipient 2 <test+to2@anymail.info>")
|
||||||
self.assertEqual(headers["subject"], "Anymail Mailgun all-options integration test")
|
self.assertEqual(headers["subject"], "Anymail Mailgun all-options integration test")
|
||||||
|
|
||||||
attachments = event["message"]["attachments"]
|
attachments = event["message"]["attachments"]
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(MailjetBackendIntegrationTests, self).setUp()
|
super(MailjetBackendIntegrationTests, self).setUp()
|
||||||
self.message = AnymailMessage('Anymail Mailjet integration test', 'Text content',
|
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('<p>HTML content</p>', "text/html")
|
self.message.attach_alternative('<p>HTML content</p>', "text/html")
|
||||||
|
|
||||||
def test_simple_send(self):
|
def test_simple_send(self):
|
||||||
@@ -48,8 +48,8 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
self.assertEqual(sent_count, 1)
|
self.assertEqual(sent_count, 1)
|
||||||
|
|
||||||
anymail_status = self.message.anymail_status
|
anymail_status = self.message.anymail_status
|
||||||
sent_status = anymail_status.recipients['anymail-test-to1@mailinator.com'].status
|
sent_status = anymail_status.recipients['test+to1@anymail.info'].status
|
||||||
message_id = anymail_status.recipients['anymail-test-to1@mailinator.com'].message_id
|
message_id = anymail_status.recipients['test+to1@anymail.info'].message_id
|
||||||
|
|
||||||
self.assertEqual(sent_status, 'sent')
|
self.assertEqual(sent_status, 'sent')
|
||||||
self.assertRegex(message_id, r'.+')
|
self.assertRegex(message_id, r'.+')
|
||||||
@@ -61,9 +61,9 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
subject="Anymail Mailjet all-options integration test",
|
subject="Anymail Mailjet all-options integration test",
|
||||||
body="This is the text body",
|
body="This is the text body",
|
||||||
from_email='"Test Sender, Inc." <test@test-mj.anymail.info>',
|
from_email='"Test Sender, Inc." <test@test-mj.anymail.info>',
|
||||||
to=['anymail-test-to1@mailinator.com', '"Recipient, 2nd" <anymail-test-to2@mailinator.com>'],
|
to=['test+to1@anymail.info', '"Recipient, 2nd" <test+to2@anymail.info>'],
|
||||||
cc=['anymail-test-cc1@mailinator.com', 'Copy 2 <anymail-test-cc1@mailinator.com>'],
|
cc=['test+cc1@anymail.info', 'Copy 2 <test+cc1@anymail.info>'],
|
||||||
bcc=['anymail-test-bcc1@mailinator.com', 'Blind Copy 2 <anymail-test-bcc2@mailinator.com>'],
|
bcc=['test+bcc1@anymail.info', 'Blind Copy 2 <test+bcc2@anymail.info>'],
|
||||||
reply_to=['reply1@example.com', '"Reply, 2nd" <reply2@example.com>'],
|
reply_to=['reply1@example.com', '"Reply, 2nd" <reply2@example.com>'],
|
||||||
headers={"X-Anymail-Test": "value"},
|
headers={"X-Anymail-Test": "value"},
|
||||||
|
|
||||||
@@ -89,10 +89,10 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
body="This body includes merge data: [[var:value]]\n"
|
body="This body includes merge data: [[var:value]]\n"
|
||||||
"And global merge data: [[var:global]]",
|
"And global merge data: [[var:global]]",
|
||||||
from_email="Test From <test@test-mj.anymail.info>",
|
from_email="Test From <test@test-mj.anymail.info>",
|
||||||
to=["anymail-test-to1@mailinator.com", "Recipient 2 <anymail-test-to2@mailinator.com>"],
|
to=["test+to1@anymail.info", "Recipient 2 <test+to2@anymail.info>"],
|
||||||
merge_data={
|
merge_data={
|
||||||
'anymail-test-to1@mailinator.com': {'value': 'one'},
|
'test+to1@anymail.info': {'value': 'one'},
|
||||||
'anymail-test-to2@mailinator.com': {'value': 'two'},
|
'test+to2@anymail.info': {'value': 'two'},
|
||||||
},
|
},
|
||||||
merge_global_data={
|
merge_global_data={
|
||||||
'global': 'global_value'
|
'global': 'global_value'
|
||||||
@@ -100,15 +100,15 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
)
|
)
|
||||||
message.send()
|
message.send()
|
||||||
recipient_status = message.anymail_status.recipients
|
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')
|
||||||
self.assertEqual(recipient_status['anymail-test-to2@mailinator.com'].status, 'sent')
|
self.assertEqual(recipient_status['test+to2@anymail.info'].status, 'sent')
|
||||||
|
|
||||||
def test_stored_template(self):
|
def test_stored_template(self):
|
||||||
message = AnymailMessage(
|
message = AnymailMessage(
|
||||||
template_id='176375', # ID of the real template named 'test-template' in our Mailjet test account
|
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={
|
merge_data={
|
||||||
'anymail-test-to1@mailinator.com': {
|
'test+to1@anymail.info': {
|
||||||
'name': "Test Recipient",
|
'name': "Test Recipient",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -119,7 +119,7 @@ class MailjetBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
message.from_email = None # use the template's sender email/name
|
message.from_email = None # use the template's sender email/name
|
||||||
message.send()
|
message.send()
|
||||||
recipient_status = message.anymail_status.recipients
|
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!")
|
@override_settings(ANYMAIL_MAILJET_API_KEY="Hey, that's not an API key!")
|
||||||
def test_invalid_api_key(self):
|
def test_invalid_api_key(self):
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class MandrillBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(MandrillBackendIntegrationTests, self).setUp()
|
super(MandrillBackendIntegrationTests, self).setUp()
|
||||||
self.message = mail.EmailMultiAlternatives('Anymail Mandrill integration test', 'Text content',
|
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('<p>HTML content</p>', "text/html")
|
self.message.attach_alternative('<p>HTML content</p>', "text/html")
|
||||||
|
|
||||||
def test_simple_send(self):
|
def test_simple_send(self):
|
||||||
@@ -43,8 +43,8 @@ class MandrillBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
|
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
anymail_status = self.message.anymail_status
|
anymail_status = self.message.anymail_status
|
||||||
sent_status = anymail_status.recipients['anymail-test-to1@mailinator.com'].status
|
sent_status = anymail_status.recipients['test+to1@anymail.info'].status
|
||||||
message_id = anymail_status.recipients['anymail-test-to1@mailinator.com'].message_id
|
message_id = anymail_status.recipients['test+to1@anymail.info'].message_id
|
||||||
|
|
||||||
self.assertIn(sent_status, ['sent', 'queued']) # successful send (could still bounce later)
|
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
|
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",
|
subject="Anymail Mandrill all-options integration test",
|
||||||
body="This is the text body",
|
body="This is the text body",
|
||||||
from_email="Test From <from@example.com>",
|
from_email="Test From <from@example.com>",
|
||||||
to=["anymail-test-to1@mailinator.com", "Recipient 2 <anymail-test-to2@mailinator.com>"],
|
to=["test+to1@anymail.info", "Recipient 2 <test+to2@anymail.info>"],
|
||||||
cc=["anymail-test-cc1@mailinator.com", "Copy 2 <anymail-test-cc2@mailinator.com>"],
|
cc=["test+cc1@anymail.info", "Copy 2 <test+cc2@anymail.info>"],
|
||||||
bcc=["anymail-test-bcc1@mailinator.com", "Blind Copy 2 <anymail-test-bcc2@mailinator.com>"],
|
bcc=["test+bcc1@anymail.info", "Blind Copy 2 <test+bcc2@anymail.info>"],
|
||||||
reply_to=["reply1@example.com", "Reply 2 <reply2@example.com>"],
|
reply_to=["reply1@example.com", "Reply 2 <reply2@example.com>"],
|
||||||
headers={"X-Anymail-Test": "value"},
|
headers={"X-Anymail-Test": "value"},
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class PostmarkBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(PostmarkBackendIntegrationTests, self).setUp()
|
super(PostmarkBackendIntegrationTests, self).setUp()
|
||||||
self.message = AnymailMessage('Anymail Postmark integration test', 'Text content',
|
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('<p>HTML content</p>', "text/html")
|
self.message.attach_alternative('<p>HTML content</p>', "text/html")
|
||||||
|
|
||||||
def test_simple_send(self):
|
def test_simple_send(self):
|
||||||
@@ -31,8 +31,8 @@ class PostmarkBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
self.assertEqual(sent_count, 1)
|
self.assertEqual(sent_count, 1)
|
||||||
|
|
||||||
anymail_status = self.message.anymail_status
|
anymail_status = self.message.anymail_status
|
||||||
sent_status = anymail_status.recipients['anymail-test-to1@mailinator.com'].status
|
sent_status = anymail_status.recipients['test+to1@anymail.info'].status
|
||||||
message_id = anymail_status.recipients['anymail-test-to1@mailinator.com'].message_id
|
message_id = anymail_status.recipients['test+to1@anymail.info'].message_id
|
||||||
|
|
||||||
self.assertEqual(sent_status, 'sent')
|
self.assertEqual(sent_status, 'sent')
|
||||||
self.assertGreater(len(message_id), 0) # non-empty string
|
self.assertGreater(len(message_id), 0) # non-empty string
|
||||||
@@ -45,9 +45,9 @@ class PostmarkBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
body="This is the text body",
|
body="This is the text body",
|
||||||
# Postmark accepts multiple from_email addresses, but truncates to the first on their end
|
# Postmark accepts multiple from_email addresses, but truncates to the first on their end
|
||||||
from_email="Test From <from@example.com>, also-from@example.com",
|
from_email="Test From <from@example.com>, also-from@example.com",
|
||||||
to=["anymail-test-to1@mailinator.com", "Recipient 2 <anymail-test-to2@mailinator.com>"],
|
to=["test+to1@anymail.info", "Recipient 2 <test+to2@anymail.info>"],
|
||||||
cc=["anymail-test-cc1@mailinator.com", "Copy 2 <anymail-test-cc2@mailinator.com>"],
|
cc=["test+cc1@anymail.info", "Copy 2 <test+cc2@anymail.info>"],
|
||||||
bcc=["anymail-test-bcc1@mailinator.com", "Blind Copy 2 <anymail-test-bcc2@mailinator.com>"],
|
bcc=["test+bcc1@anymail.info", "Blind Copy 2 <test+bcc2@anymail.info>"],
|
||||||
reply_to=["reply1@example.com", "Reply 2 <reply2@example.com>"],
|
reply_to=["reply1@example.com", "Reply 2 <reply2@example.com>"],
|
||||||
headers={"X-Anymail-Test": "value"},
|
headers={"X-Anymail-Test": "value"},
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class SendinBlueBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
super(SendinBlueBackendIntegrationTests, self).setUp()
|
super(SendinBlueBackendIntegrationTests, self).setUp()
|
||||||
|
|
||||||
self.message = AnymailMessage('Anymail SendinBlue integration test', 'Text content',
|
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('<p>HTML content</p>', "text/html")
|
self.message.attach_alternative('<p>HTML content</p>', "text/html")
|
||||||
|
|
||||||
def test_simple_send(self):
|
def test_simple_send(self):
|
||||||
@@ -44,8 +44,8 @@ class SendinBlueBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
self.assertEqual(sent_count, 1)
|
self.assertEqual(sent_count, 1)
|
||||||
|
|
||||||
anymail_status = self.message.anymail_status
|
anymail_status = self.message.anymail_status
|
||||||
sent_status = anymail_status.recipients['anymail-test-to1@mailinator.com'].status
|
sent_status = anymail_status.recipients['test+to1@anymail.info'].status
|
||||||
message_id = anymail_status.recipients['anymail-test-to1@mailinator.com'].message_id
|
message_id = anymail_status.recipients['test+to1@anymail.info'].message_id
|
||||||
|
|
||||||
self.assertEqual(sent_status, 'queued') # SendinBlue always queues
|
self.assertEqual(sent_status, 'queued') # SendinBlue always queues
|
||||||
self.assertRegex(message_id, r'\<.+@.+\>') # Message-ID can be ...@smtp-relay.mail.fr or .sendinblue.com
|
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",
|
subject="Anymail SendinBlue all-options integration test",
|
||||||
body="This is the text body",
|
body="This is the text body",
|
||||||
from_email='"Test From, with comma" <from@test-sb.anymail.info>',
|
from_email='"Test From, with comma" <from@test-sb.anymail.info>',
|
||||||
to=["anymail-test-to1@mailinator.com", '"Recipient 2, OK?" <anymail-test-to2@mailinator.com>'],
|
to=["test+to1@anymail.info", '"Recipient 2, OK?" <test+to2@anymail.info>'],
|
||||||
cc=["anymail-test-cc1@mailinator.com", "Copy 2 <anymail-test-cc2@mailinator.com>"],
|
cc=["test+cc1@anymail.info", "Copy 2 <test+cc2@anymail.info>"],
|
||||||
bcc=["anymail-test-bcc1@mailinator.com", "Blind Copy 2 <anymail-test-bcc2@mailinator.com>"],
|
bcc=["test+bcc1@anymail.info", "Blind Copy 2 <test+bcc2@anymail.info>"],
|
||||||
reply_to=['"Reply, with comma" <reply@example.com>'], # SendinBlue API v3 only supports single reply-to
|
reply_to=['"Reply, with comma" <reply@example.com>'], # SendinBlue API v3 only supports single reply-to
|
||||||
headers={"X-Anymail-Test": "value", "X-Anymail-Count": 3},
|
headers={"X-Anymail-Test": "value", "X-Anymail-Count": 3},
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ class SendinBlueBackendIntegrationTests(SimpleTestCase, AnymailTestMixin):
|
|||||||
def test_template(self):
|
def test_template(self):
|
||||||
message = AnymailMessage(
|
message = AnymailMessage(
|
||||||
template_id=1, # There is a template with this id in the Anymail test account
|
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"],
|
reply_to=["reply@example.com"],
|
||||||
tags=["using-template"],
|
tags=["using-template"],
|
||||||
headers={"X-Anymail-Test": "group: A, variation: C"},
|
headers={"X-Anymail-Test": "group: A, variation: C"},
|
||||||
|
|||||||
Reference in New Issue
Block a user