예제 #1
0
    def test_prepare_message_unicode(self):
        from gtimelog.main import __version__, prepare_message
        msg = prepare_message(
            sender='Ünicødę Name <*****@*****.**>',
            recipient='Anöther nąme <*****@*****.**>',
            subject='Report for Mr. ☃',
            body='These are the activities done by Mr. ☃:\n...\n',
        )
        expected = textwrap.dedent('''\
            MIME-Version: 1.0
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: base64
            From: =?utf-8?b?w5xuaWPDuGTEmSBOYW1l?= <*****@*****.**>
            To: =?utf-8?b?QW7DtnRoZXIgbsSFbWU=?= <*****@*****.**>
            Subject: =?utf-8?b?UmVwb3J0IGZvciBNci4g4piD?=
            User-Agent: gtimelog/0.11.dev0

            VGhlc2UgYXJlIHRoZSBhY3Rpdml0aWVzIGRvbmUgYnkgTXIuIOKYgzoKLi4uCg==
        ''').replace('0.11.dev0', __version__)
        self.assertEqual(expected, msg.as_string())
예제 #2
0
    def test_prepare_message_unicode(self):
        from gtimelog.main import prepare_message, __version__
        msg = prepare_message(
            sender='Ünicødę Name <*****@*****.**>',
            recipient='Anöther nąme <*****@*****.**>',
            subject='Report for Mr. ☃',
            body='These are the activites done by Mr. ☃:\n...\n',
        )
        expected = textwrap.dedent('''\
            MIME-Version: 1.0
            Content-Type: text/plain; charset="utf-8"
            Content-Transfer-Encoding: base64
            From: =?utf-8?b?w5xuaWPDuGTEmSBOYW1l?= <*****@*****.**>
            To: =?utf-8?b?QW7DtnRoZXIgbsSFbWU=?= <*****@*****.**>
            Subject: =?utf-8?b?UmVwb3J0IGZvciBNci4g4piD?=
            User-Agent: gtimelog/0.11.dev0

            VGhlc2UgYXJlIHRoZSBhY3Rpdml0ZXMgZG9uZSBieSBNci4g4piDOgouLi4K
        ''').replace('0.11.dev0', __version__)
        self.assertEqual(expected, msg.as_string())
예제 #3
0
    def test_prepare_message_ascii(self):
        from gtimelog.main import __version__, prepare_message
        msg = prepare_message(
            sender='ASCII Name <*****@*****.**>',
            recipient='*****@*****.**',
            subject='Report for Mr. Plain',
            body='These are the activities done by Mr. Plain:\n...\n',
        )
        self.assertEqual("ASCII Name <*****@*****.**>", msg["From"])
        self.assertEqual("*****@*****.**", msg["To"])
        self.assertEqual("Report for Mr. Plain", msg["Subject"])
        expected = textwrap.dedent('''\
            Content-Type: text/plain; charset="us-ascii"
            MIME-Version: 1.0
            Content-Transfer-Encoding: 7bit
            From: ASCII Name <*****@*****.**>
            To: [email protected]
            Subject: Report for Mr. Plain
            User-Agent: gtimelog/0.11.dev0

            These are the activities done by Mr. Plain:
            ...
        ''').replace('0.11.dev0', __version__)
        self.assertEqual(expected, msg.as_string())
예제 #4
0
    def test_prepare_message_ascii(self):
        from gtimelog.main import prepare_message, __version__
        msg = prepare_message(
            sender='ASCII Name <*****@*****.**>',
            recipient='*****@*****.**',
            subject='Report for Mr. Plain',
            body='These are the activites done by Mr. Plain:\n...\n',
        )
        self.assertEqual("ASCII Name <*****@*****.**>", msg["From"])
        self.assertEqual("*****@*****.**", msg["To"])
        self.assertEqual("Report for Mr. Plain", msg["Subject"])
        expected = textwrap.dedent('''\
            Content-Type: text/plain; charset="us-ascii"
            MIME-Version: 1.0
            Content-Transfer-Encoding: 7bit
            From: ASCII Name <*****@*****.**>
            To: [email protected]
            Subject: Report for Mr. Plain
            User-Agent: gtimelog/0.11.dev0

            These are the activites done by Mr. Plain:
            ...
        ''').replace('0.11.dev0', __version__)
        self.assertEqual(expected, msg.as_string())