Ejemplo n.º 1
0
    def test_recipients(self):
        e = Email('*****@*****.**', '*****@*****.**')
        self.assertEqual(e.recipients, ['*****@*****.**'])

        recipients = ['*****@*****.**', '*****@*****.**']
        e = Email('*****@*****.**', recipients)
        self.assertEqual(e.recipients, recipients)
Ejemplo n.º 2
0
    def test_msg_contains_html_body_and_attachment(self):
        e = Email('*****@*****.**', '*****@*****.**', 'subject')
        e.body = '<html><body><b>fubar</b></body></html>'
        e.body_is_html = True
        e.attachments.append(Attachment('./tests/440Hz-5sec.mp3'))

        # body will be base64 encoded:
        self.assertTrue('PGh0bWw+PGJvZHk+PGI+ZnViYXI8L2I+PC9ib2R5PjwvaHRtbD4='
                        in str(e)[:500])
        self.assertTrue('filename="440Hz' in str(e)[:800])
Ejemplo n.º 3
0
    def test_msg_contains_html_body_and_attachment(self):
        e = Email('*****@*****.**', '*****@*****.**', 'subject')
        e.body = '<html><body><b>fubar</b></body></html>'
        e.body_is_html = True
        e.attachments.append(Attachment('./tests/440Hz-5sec.mp3'))

        # body will be base64 encoded:
        self.assertTrue('PGh0bWw+PGJvZHk+PGI+ZnViYXI8L2I+PC9ib2R5PjwvaHRtbD4='
                        in str(e)[:500])
        self.assertTrue('filename="440Hz' in str(e)[:800])
Ejemplo n.º 4
0
    def test_msg_contains_body_and_attachment(self):
        e = Email('*****@*****.**', '*****@*****.**', 'subject', 'fubar')
        e.attachments.append(Attachment('./tests/440Hz-5sec.mp3'))

        # body will be base64 encoded:
        self.assertTrue('ZnViYXI=' in str(e)[:500])
        self.assertTrue('filename="440Hz' in str(e)[:800])
Ejemplo n.º 5
0
 def test_all_recipients(self):
     e = Email('*****@*****.**', '*****@*****.**')
     e.cc.append('*****@*****.**')
     e.bcc.append('*****@*****.**')
     self.assertEqual(e.all_recipients,
                      ['*****@*****.**', '*****@*****.**', '*****@*****.**'])
Ejemplo n.º 6
0
 def test_as_string_empty_body(self):
     e = Email('*****@*****.**', '*****@*****.**')
     e.subject = 'äää ööö üfoo äß'
     self.assertTrue(
         'Content-Type: text/plain; charset="us-ascii"' in str(e))
Ejemplo n.º 7
0
 def test_as_string(self):
     e = Email('*****@*****.**', '*****@*****.**')
     e.subject = 'äää ööö üfoo äß'
     e.body = 'ääää'
     self.assertTrue('Content-Type: text/plain; charset="utf-8"' in str(e))
Ejemplo n.º 8
0
 def test_subject_property(self):
     e = Email('*****@*****.**', '*****@*****.**')
     e.subject = 'subject'
     self.assertEqual('subject', str(e.subject))
     self.assertEqual('utf-8', decode_header(e._subject)[0][1])
     self.assertIsInstance(e._subject, Header)
Ejemplo n.º 9
0
 def test_subject_encoding(self):
     e = Email('*****@*****.**', '*****@*****.**', 'subject', 'body')
     self.assertEqual('subject', str(e.subject))
     self.assertEqual('utf-8', decode_header(e._subject)[0][1])
     self.assertIsInstance(e._subject, Header)
     self.assertEqual('body', e.body)
Ejemplo n.º 10
0
 def test_as_string_empty_body(self):
     e = Email('*****@*****.**', '*****@*****.**')
     e.subject = 'äää ööö üfoo äß'
     self.assertTrue('Content-Type: text/plain; charset="us-ascii"' in str(e))
Ejemplo n.º 11
0
 def test_as_string(self):
     e = Email('*****@*****.**', '*****@*****.**')
     e.subject = 'äää ööö üfoo äß'
     e.body = 'ääää'
     self.assertTrue('Content-Type: text/plain; charset="utf-8"' in str(e))
Ejemplo n.º 12
0
 def test_subject_property(self):
     e = Email('*****@*****.**', '*****@*****.**')
     e.subject = 'subject'
     self.assertEqual('subject', str(e.subject))
     self.assertEqual('utf-8', decode_header(e._subject)[0][1])
     self.assertIsInstance(e._subject, Header)