class UMessageTC(TestCase):

    def setUp(self):
        msg1 = email.message_from_file(open('data/test1.msg'))
        self.umessage1 = UMessage(msg1)
        msg2 = email.message_from_file(open('data/test2.msg'))
        self.umessage2 = UMessage(msg2)

    def test_get_subject(self):
        subj = self.umessage2.get('Subject')
        self.assertEquals(type(subj), unicode)
        self.assertEquals(subj, u'À LA MER')

    def test_get_all(self):
        to = self.umessage2.get_all('To')
        self.assertEquals(type(to[0]), unicode)
        self.assertEquals(to, [u'élément à accents <*****@*****.**>'])

    def test_get_payload_no_multi(self):
        payload = self.umessage1.get_payload()
        self.assertEquals(type(payload), unicode)

    def test_decode_QP(self):
        test_line =  '=??b?UmFwaGHrbA==?= DUPONT<*****@*****.**>'
        test = decode_QP(test_line)
        self.assertEquals(type(test), unicode)
        self.assertEquals(test, u'Raphaël DUPONT<*****@*****.**>')
class UMessageTC(TestCase):

    def setUp(self):
        if sys.version_info >= (3, 2):
            import io
            msg1 = email.message_from_file(io.open(join(DATA, 'test1.msg'), encoding='utf8'))
            msg2 = email.message_from_file(io.open(join(DATA, 'test2.msg'), encoding='utf8'))
        else:
            msg1 = email.message_from_file(open(join(DATA, 'test1.msg')))
            msg2 = email.message_from_file(open(join(DATA, 'test2.msg')))
        self.umessage1 = UMessage(msg1)
        self.umessage2 = UMessage(msg2)

    def test_get_subject(self):
        subj = self.umessage2.get('Subject')
        self.assertEqual(type(subj), unicode)
        self.assertEqual(subj, u'À LA MER')

    def test_get_all(self):
        to = self.umessage2.get_all('To')
        self.assertEqual(type(to[0]), unicode)
        self.assertEqual(to, [u'élément à accents <*****@*****.**>'])

    def test_get_payload_no_multi(self):
        payload = self.umessage1.get_payload()
        self.assertEqual(type(payload), unicode)

    def test_decode_QP(self):
        test_line =  '=??b?UmFwaGHrbA==?= DUPONT<*****@*****.**>'
        test = decode_QP(test_line)
        self.assertEqual(type(test), unicode)
        self.assertEqual(test, u'Raphaël DUPONT<*****@*****.**>')
class UMessageTC(TestCase):

    def setUp(self):
        msg1 = email.message_from_file(open('data/test1.msg'))
        self.umessage1 = UMessage(msg1)
        msg2 = email.message_from_file(open('data/test2.msg'))
        self.umessage2 = UMessage(msg2)

    def test_get_subject(self):
        subj = self.umessage2.get('Subject')
        self.assertEqual(type(subj), unicode)
        self.assertEqual(subj, u'À LA MER')

    def test_get_all(self):
        to = self.umessage2.get_all('To')
        self.assertEqual(type(to[0]), unicode)
        self.assertEqual(to, [u'élément à accents <*****@*****.**>'])

    def test_get_payload_no_multi(self):
        payload = self.umessage1.get_payload()
        self.assertEqual(type(payload), unicode)

    def test_decode_QP(self):
        test_line =  '=??b?UmFwaGHrbA==?= DUPONT<*****@*****.**>'
        test = decode_QP(test_line)
        self.assertEqual(type(test), unicode)
        self.assertEqual(test, u'Raphaël DUPONT<*****@*****.**>')
Exemple #4
0
class UMessageTC(TestCase):
    def setUp(self):
        if sys.version_info >= (3, 2):
            import io
            msg1 = email.message_from_file(
                io.open(join(DATA, 'test1.msg'), encoding='utf8'))
            msg2 = email.message_from_file(
                io.open(join(DATA, 'test2.msg'), encoding='utf8'))
        else:
            msg1 = email.message_from_file(open(join(DATA, 'test1.msg')))
            msg2 = email.message_from_file(open(join(DATA, 'test2.msg')))
        self.umessage1 = UMessage(msg1)
        self.umessage2 = UMessage(msg2)

    def test_get_subject(self):
        subj = self.umessage2.get('Subject')
        self.assertEqual(type(subj), text_type)
        self.assertEqual(subj, u'À LA MER')

    def test_get_all(self):
        to = self.umessage2.get_all('To')
        self.assertEqual(type(to[0]), text_type)
        self.assertEqual(to, [u'élément à accents <*****@*****.**>'])

    def test_get_payload_no_multi(self):
        payload = self.umessage1.get_payload()
        self.assertEqual(type(payload), text_type)

    def test_decode_QP(self):
        test_line = '=??b?UmFwaGHrbA==?= DUPONT<*****@*****.**>'
        test = decode_QP(test_line)
        self.assertEqual(type(test), text_type)
        self.assertEqual(test, u'Raphaël DUPONT<*****@*****.**>')
Exemple #5
0
 def setUp(self):
     if sys.version_info >= (3, 2):
         import io
         msg1 = email.message_from_file(io.open(join(DATA, 'test1.msg'), encoding='utf8'))
         msg2 = email.message_from_file(io.open(join(DATA, 'test2.msg'), encoding='utf8'))
     else:
         msg1 = email.message_from_file(open(join(DATA, 'test1.msg')))
         msg2 = email.message_from_file(open(join(DATA, 'test2.msg')))
     self.umessage1 = UMessage(msg1)
     self.umessage2 = UMessage(msg2)
 def setUp(self):
     msg1 = email.message_from_file(open('data/test1.msg'))
     self.umessage1 = UMessage(msg1)
     msg2 = email.message_from_file(open('data/test2.msg'))
     self.umessage2 = UMessage(msg2)
 def setUp(self):
     msg1 = email.message_from_file(open(join(DATA, 'test1.msg')))
     self.umessage1 = UMessage(msg1)
     msg2 = email.message_from_file(open(join(DATA, 'test2.msg')))
     self.umessage2 = UMessage(msg2)
 def setUp(self):
     msg1 = email.message_from_file(open('data/test1.msg'))
     self.umessage1 = UMessage(msg1)
     msg2 = email.message_from_file(open('data/test2.msg'))
     self.umessage2 = UMessage(msg2)
class UMessageTC(TestCase):

    def setUp(self):
        if sys.version_info >= (3, 2):
            import io
            msg1 = email.message_from_file(io.open(join(DATA, 'test1.msg'), encoding='utf8'))
            msg2 = email.message_from_file(io.open(join(DATA, 'test2.msg'), encoding='utf8'))
        else:
            msg1 = email.message_from_file(open(join(DATA, 'test1.msg')))
            msg2 = email.message_from_file(open(join(DATA, 'test2.msg')))
        self.umessage1 = UMessage(msg1)
        self.umessage2 = UMessage(msg2)

    def test_get_subject(self):
        subj = self.umessage2.get('Subject')
        self.assertEqual(type(subj), text_type)
        self.assertEqual(subj, u'À LA MER')

    def test_get_all(self):
        to = self.umessage2.get_all('To')
        self.assertEqual(type(to[0]), text_type)
        self.assertEqual(to, [u'élément à accents <*****@*****.**>'])

    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?= <*****@*****.**>
Reply-to: =?utf-8?q?oim?= <*****@*****.**>, =?utf-8?q?BimBam?= <*****@*****.**>
X-CW: data
To: [email protected]
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<*****@*****.**>'
        test = decode_QP(test_line)
        self.assertEqual(type(test), text_type)
        self.assertEqual(test, u'Raphaël DUPONT<*****@*****.**>')

    def test_decode_QP_utf8(self):
        test_line = '=?utf-8?q?o=C3=AEm?= <*****@*****.**>'
        test = decode_QP(test_line)
        self.assertEqual(type(test), text_type)
        self.assertEqual(test, u'oîm <*****@*****.**>')

    def test_decode_QP_ascii(self):
        test_line = 'test <*****@*****.**>'
        test = decode_QP(test_line)
        self.assertEqual(type(test), text_type)
        self.assertEqual(test, u'test <*****@*****.**>')
 def setUp(self):
     msg1 = email.message_from_file(open(join(DATA, 'test1.msg')))
     self.umessage1 = UMessage(msg1)
     msg2 = email.message_from_file(open(join(DATA, 'test2.msg')))
     self.umessage2 = UMessage(msg2)
Exemple #11
0
class UMessageTC(TestCase):
    def setUp(self):
        if sys.version_info >= (3, 2):
            import io
            msg1 = email.message_from_file(
                io.open(join(DATA, 'test1.msg'), encoding='utf8'))
            msg2 = email.message_from_file(
                io.open(join(DATA, 'test2.msg'), encoding='utf8'))
        else:
            msg1 = email.message_from_file(open(join(DATA, 'test1.msg')))
            msg2 = email.message_from_file(open(join(DATA, 'test2.msg')))
        self.umessage1 = UMessage(msg1)
        self.umessage2 = UMessage(msg2)

    def test_get_subject(self):
        subj = self.umessage2.get('Subject')
        self.assertEqual(type(subj), text_type)
        self.assertEqual(subj, u'À LA MER')

    def test_get_all(self):
        to = self.umessage2.get_all('To')
        self.assertEqual(type(to[0]), text_type)
        self.assertEqual(to, [u'élément à accents <*****@*****.**>'])

    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?= <*****@*****.**>
Reply-to: =?utf-8?q?oim?= <*****@*****.**>, =?utf-8?q?BimBam?= <*****@*****.**>
X-CW: data
To: [email protected]
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<*****@*****.**>'
        test = decode_QP(test_line)
        self.assertEqual(type(test), text_type)
        self.assertEqual(test, u'Raphaël DUPONT<*****@*****.**>')

    def test_decode_QP_utf8(self):
        test_line = '=?utf-8?q?o=C3=AEm?= <*****@*****.**>'
        test = decode_QP(test_line)
        self.assertEqual(type(test), text_type)
        self.assertEqual(test, u'oîm <*****@*****.**>')

    def test_decode_QP_ascii(self):
        test_line = 'test <*****@*****.**>'
        test = decode_QP(test_line)
        self.assertEqual(type(test), text_type)
        self.assertEqual(test, u'test <*****@*****.**>')