EmailMessage.attach() docs: "You can pass it a single argument that is a MIMEPart object."
(self)
| 1142 | self.assertIsNone(image_att.get_filename()) |
| 1143 | |
| 1144 | def test_attach_mime_part(self): |
| 1145 | """ |
| 1146 | EmailMessage.attach() docs: "You can pass it |
| 1147 | a single argument that is a MIMEPart object." |
| 1148 | """ |
| 1149 | # This also verifies complex attachments with extra header fields. |
| 1150 | email = EmailMessage() |
| 1151 | image = MIMEPart() |
| 1152 | image.set_content( |
| 1153 | b"GIF89a...", |
| 1154 | maintype="image", |
| 1155 | subtype="gif", |
| 1156 | disposition="inline", |
| 1157 | cid="<content-id@example.org>", |
| 1158 | ) |
| 1159 | email.attach(image) |
| 1160 | |
| 1161 | attachments = self.get_raw_attachments(email) |
| 1162 | self.assertEqual(len(attachments), 1) |
| 1163 | image_att = attachments[0] |
| 1164 | self.assertEqual(image_att.get_content_type(), "image/gif") |
| 1165 | self.assertEqual(image_att.get_content_disposition(), "inline") |
| 1166 | self.assertEqual(image_att["Content-ID"], "<content-id@example.org>") |
| 1167 | self.assertEqual(image_att.get_content(), b"GIF89a...") |
| 1168 | self.assertIsNone(image_att.get_filename()) |
| 1169 | |
| 1170 | # RemovedInDjango70Warning. |
| 1171 | def test_attach_mime_image_in_constructor(self): |
nothing calls this directly
no test coverage detected