EmailMessage.attach() docs: "You can pass it a single argument that is a MIMEBase instance."
(self)
| 1116 | |
| 1117 | # RemovedInDjango70Warning. |
| 1118 | def test_attach_mime_image(self): |
| 1119 | """ |
| 1120 | EmailMessage.attach() docs: "You can pass it |
| 1121 | a single argument that is a MIMEBase instance." |
| 1122 | """ |
| 1123 | msg = ( |
| 1124 | "MIMEBase attachments are deprecated." |
| 1125 | " Use an email.message.MIMEPart instead." |
| 1126 | ) |
| 1127 | # This also verifies complex attachments with extra header fields. |
| 1128 | email = EmailMessage() |
| 1129 | image = MIMEImage(b"GIF89a...", "gif") |
| 1130 | image["Content-Disposition"] = "inline" |
| 1131 | image["Content-ID"] = "<content-id@example.org>" |
| 1132 | with self.assertWarnsMessage(RemovedInDjango70Warning, msg): |
| 1133 | email.attach(image) |
| 1134 | |
| 1135 | attachments = self.get_raw_attachments(email) |
| 1136 | self.assertEqual(len(attachments), 1) |
| 1137 | image_att = attachments[0] |
| 1138 | self.assertEqual(image_att.get_content_type(), "image/gif") |
| 1139 | self.assertEqual(image_att.get_content_disposition(), "inline") |
| 1140 | self.assertEqual(image_att["Content-ID"], "<content-id@example.org>") |
| 1141 | self.assertEqual(image_att.get_content(), b"GIF89a...") |
| 1142 | self.assertIsNone(image_att.get_filename()) |
| 1143 | |
| 1144 | def test_attach_mime_part(self): |
| 1145 | """ |
nothing calls this directly
no test coverage detected