Esempio n. 1
0
    def test_text_attachment(self):
        message = EmailMessage(attachments=[('test.txt', u"データ", None)]).message()

        payloads = message.get_payload()

        # 添付ファイルのペイロード
        self.assertEquals(len(payloads), 1)
        self.assertEquals(payloads[0]['Content-Transfer-Encoding'], 'base64')
        self.assertEquals(payloads[0]['Content-Type'], 'text/plain; charset="UTF-8"')
        self.assertEquals(payloads[0]['Content-Disposition'], 'attachment; filename="test.txt"')
        self.assertEquals(payloads[0].get_payload(), "44OH44O844K/\n")
Esempio n. 2
0
    def test_binary_attachment(self):
        message = EmailMessage(
            attachments=[('test.binary', u"データ".encode("utf8"), None)]).message()

        payloads = message.get_payload()

        # 添付ファイルのペイロード
        self.assertEquals(len(payloads), 1)
        self.assertEquals(payloads[0]['Content-Transfer-Encoding'], 'base64')
        self.assertEquals(payloads[0]['Content-Type'], 'application/octet-stream')
        self.assertEquals(payloads[0]['Content-Disposition'], 'attachment; filename="test.binary"')
        self.assertEquals(payloads[0].get_payload(), "44OH44O844K/")
Esempio n. 3
0
    def test_text_attachment(self):
        message = EmailMessage(attachments=[('test.txt', u"データ",
                                             None)]).message()

        payloads = message.get_payload()

        # 添付ファイルのペイロード
        self.assertEquals(len(payloads), 1)
        self.assertEquals(payloads[0]['Content-Transfer-Encoding'], '8bit')
        self.assertEquals(payloads[0]['Content-Type'],
                          'text/plain; charset="utf-8"')
        self.assertEquals(payloads[0]['Content-Disposition'],
                          'attachment; filename="test.txt"')
        self.assertEqual(payloads[0].get_payload(decode=True),
                         u'データ'.encode('utf-8'))
Esempio n. 4
0
    def test_binary_attachment(self):
        message = EmailMessage(attachments=[('test.binary',
                                             u"データ".encode("utf8"),
                                             None)]).message()

        payloads = message.get_payload()

        # 添付ファイルのペイロード
        self.assertEquals(len(payloads), 1)
        self.assertEquals(payloads[0]['Content-Transfer-Encoding'], 'base64')
        self.assertEquals(payloads[0]['Content-Type'],
                          'application/octet-stream')
        self.assertEquals(payloads[0]['Content-Disposition'],
                          'attachment; filename="test.binary"')
        self.assertEqual(payloads[0].get_payload(decode=True),
                         u'データ'.encode('utf-8'))