def test_recipients(self): e = Email('*****@*****.**', '*****@*****.**') self.assertEqual(e.recipients, ['*****@*****.**']) recipients = ['*****@*****.**', '*****@*****.**'] e = Email('*****@*****.**', recipients) self.assertEqual(e.recipients, recipients)
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])
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])
def test_all_recipients(self): e = Email('*****@*****.**', '*****@*****.**') e.cc.append('*****@*****.**') e.bcc.append('*****@*****.**') self.assertEqual(e.all_recipients, ['*****@*****.**', '*****@*****.**', '*****@*****.**'])
def test_as_string_empty_body(self): e = Email('*****@*****.**', '*****@*****.**') e.subject = 'äää ööö üfoo äß' self.assertTrue( 'Content-Type: text/plain; charset="us-ascii"' in str(e))
def test_as_string(self): e = Email('*****@*****.**', '*****@*****.**') e.subject = 'äää ööö üfoo äß' e.body = 'ääää' self.assertTrue('Content-Type: text/plain; charset="utf-8"' in str(e))
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)
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)
def test_as_string_empty_body(self): e = Email('*****@*****.**', '*****@*****.**') e.subject = 'äää ööö üfoo äß' self.assertTrue('Content-Type: text/plain; charset="us-ascii"' in str(e))