diff options
author | Rémi Cardona <remi.cardona@logilab.fr> | 2015-09-21 10:51:28 +0200 |
---|---|---|
committer | Rémi Cardona <remi.cardona@logilab.fr> | 2015-09-21 10:51:28 +0200 |
commit | 6ac46aa37813f34dd8ce7500366d2d519a03680b (patch) | |
tree | 1bf0a32e055ccd48eb513632f920b218fb4927e0 /test | |
parent | 012b8f8e800556cbfe0bff2b1caefb9b242dce17 (diff) | |
download | logilab-common-6ac46aa37813f34dd8ce7500366d2d519a03680b.tar.gz |
[umessage] Use the same code paths for both python 2 and 3
Add tests for UMessage.get_payload() (taken from CubicWeb).
Closes #1716128.
Diffstat (limited to 'test')
-rw-r--r-- | test/unittest_umessage.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/unittest_umessage.py b/test/unittest_umessage.py index 940b308..2841172 100644 --- a/test/unittest_umessage.py +++ b/test/unittest_umessage.py @@ -23,7 +23,7 @@ from os.path import join, dirname, abspath from six import text_type from logilab.common.testlib import TestCase, unittest_main -from logilab.common.umessage import UMessage, decode_QP +from logilab.common.umessage import UMessage, decode_QP, message_from_string DATA = join(dirname(abspath(__file__)), 'data') @@ -53,6 +53,23 @@ class UMessageTC(TestCase): def test_get_payload_no_multi(self): payload = self.umessage1.get_payload() self.assertEqual(type(payload), text_type) + + def test_get_payload_decode(self): + msg = """\ +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: base64 +Subject: =?utf-8?q?b=C3=AFjour?= +From: =?utf-8?q?oim?= <oim@logilab.fr> +Reply-to: =?utf-8?q?oim?= <oim@logilab.fr>, =?utf-8?q?BimBam?= <bim@boum.fr> +X-CW: data +To: test@logilab.fr +Date: now + +dW4gcGV0aXQgY8O2dWNvdQ== +""" + msg = message_from_string(msg) + self.assertEqual(msg.get_payload(decode=True), u'un petit cöucou') def test_decode_QP(self): test_line = '=??b?UmFwaGHrbA==?= DUPONT<raphael.dupont@societe.fr>' |