Skip to content

Commit 59685b8

Browse files
authored
Tests: work around Mailgun event reporting change
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
1 parent c38218d commit 59685b8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/test_mailgun_integration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,13 @@ def test_all_options(self):
151151
self.assertEqual(headers["subject"], "Anymail Mailgun all-options integration test")
152152

153153
attachments = event["message"]["attachments"]
154-
self.assertEqual(len(attachments), 2) # because inline image shouldn't be an attachment
154+
if len(attachments) == 3:
155+
# The inline attachment shouldn't be in the event message.attachments array,
156+
# but sometimes is included for the accepted event (see #172)
157+
inline_attachment = attachments.pop(0)
158+
self.assertEqual(inline_attachment["filename"], cid)
159+
self.assertEqual(inline_attachment["content-type"], "image/png")
160+
self.assertEqual(len(attachments), 2)
155161
self.assertEqual(attachments[0]["filename"], "attachment1.txt")
156162
self.assertEqual(attachments[0]["content-type"], "text/plain")
157163
self.assertEqual(attachments[1]["filename"], "vedhæftet fil.csv")

0 commit comments

Comments
 (0)