Esempio n. 1
0
    def test_content_id_implies_inline(self):
        """A MIME object with a Content-ID should be assumed to be inline"""
        image = MIMEImage(b";-)", "x-emoticon")
        image["Content-ID"] = "<*****@*****.**>"
        att = Attachment(image, "ascii")
        self.assertTrue(att.inline)
        self.assertEqual(att.content_id, "<*****@*****.**>")

        # ... but not if explicit Content-Disposition says otherwise
        image["Content-Disposition"] = "attachment"
        att = Attachment(image, "ascii")
        self.assertFalse(att.inline)
        self.assertIsNone(att.content_id)  # ignored for non-inline Attachment
Esempio n. 2
0
    def test_content_disposition_inline(self):
        image = MIMEImage(b";-)", "x-emoticon")
        image["Content-Disposition"] = 'inline'
        att = Attachment(image, "ascii")
        self.assertIsNone(att.name)
        self.assertEqual(att.content, b";-)")
        self.assertTrue(att.inline)  # even without the Content-ID
        self.assertIsNone(att.content_id)
        self.assertEqual(att.cid, "")

        image["Content-ID"] = "<*****@*****.**>"
        att = Attachment(image, "ascii")
        self.assertEqual(att.content_id, "<*****@*****.**>")
        self.assertEqual(att.cid, "*****@*****.**")
Esempio n. 3
0
 def test_content_disposition_attachment(self):
     image = MIMEImage(b";-)", "x-emoticon")
     image["Content-Disposition"] = 'attachment; filename="emoticon.txt"'
     att = Attachment(image, "ascii")
     self.assertEqual(att.name, "emoticon.txt")
     self.assertEqual(att.content, b";-)")
     self.assertFalse(att.inline)
     self.assertIsNone(att.content_id)
     self.assertEqual(att.cid, "")
Esempio n. 4
0
 def test_content_type(self):
     att = Attachment(MIMEText("text", "plain", "iso8859-1"), "ascii")
     self.assertEqual(att.mimetype, "text/plain")
     self.assertEqual(att.content_type, 'text/plain; charset="iso8859-1"')
     self.assertEqual(repr(att), "Attachment<text/plain, len=4>")