From 3ee647db4dc7dab385df7251de758980973cc3d9 Mon Sep 17 00:00:00 2001 From: Mike Edmunds Date: Wed, 11 Dec 2019 12:43:50 -0800 Subject: [PATCH 1/2] Tests: work around Mailgun event reporting change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the live integration tests, work around Mailgun's recent change to how inline attachments are reported in "accepted" events data. (But keep it working either way, since it seems likely this change was unintentional—other event types still exclude inline attachments from `event.message.attachments`.) Fixes #172 --- tests/test_mailgun_integration.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_mailgun_integration.py b/tests/test_mailgun_integration.py index a1e4e7a8..4905ae2c 100644 --- a/tests/test_mailgun_integration.py +++ b/tests/test_mailgun_integration.py @@ -151,7 +151,13 @@ def test_all_options(self): self.assertEqual(headers["subject"], "Anymail Mailgun all-options integration test") attachments = event["message"]["attachments"] - self.assertEqual(len(attachments), 2) # because inline image shouldn't be an attachment + if len(attachments) == 3: + # The inline attachment shouldn't be in the event message.attachments array, + # but sometimes is included for the accepted event (see #172) + inline_attachment = attachments.pop(0) + self.assertEqual(inline_attachment["filename"], cid) + self.assertEqual(inline_attachment["content-type"], "image/png") + self.assertEqual(len(attachments), 2) self.assertEqual(attachments[0]["filename"], "attachment1.txt") self.assertEqual(attachments[0]["content-type"], "text/plain") self.assertEqual(attachments[1]["filename"], "vedhæftet fil.csv") From 93d8b79e509c9116331ac081c89c32a2247c14cf Mon Sep 17 00:00:00 2001 From: Mike Edmunds Date: Wed, 11 Dec 2019 14:42:12 -0800 Subject: [PATCH 2/2] Fix trailing whitespace --- tests/test_mailgun_integration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mailgun_integration.py b/tests/test_mailgun_integration.py index 4905ae2c..16a5e2d4 100644 --- a/tests/test_mailgun_integration.py +++ b/tests/test_mailgun_integration.py @@ -152,7 +152,7 @@ def test_all_options(self): attachments = event["message"]["attachments"] if len(attachments) == 3: - # The inline attachment shouldn't be in the event message.attachments array, + # The inline attachment shouldn't be in the event message.attachments array, # but sometimes is included for the accepted event (see #172) inline_attachment = attachments.pop(0) self.assertEqual(inline_attachment["filename"], cid)