diff options
author | Patrick Maia <pixelated-team+pmaia@thoughtworks.com> | 2014-10-23 19:15:03 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2014-10-24 10:22:03 -0300 |
commit | e72e8ab515931f294523e836693eb76358fed240 (patch) | |
tree | fe75da953b49296c44559539c220becb2e47604c /service/test | |
parent | 7ce93f2d1d4568e4cd5284209fb28f578b2978b3 (diff) |
Card #30 - handles alternative bodies on InputMail
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/unit/adapter/mail_test.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/service/test/unit/adapter/mail_test.py b/service/test/unit/adapter/mail_test.py index b4e19017..3bec6fc7 100644 --- a/service/test/unit/adapter/mail_test.py +++ b/service/test/unit/adapter/mail_test.py @@ -104,6 +104,19 @@ class InputMailTest(unittest.TestCase): 'tags': ['sent'] } + multipart_mail_dict = lambda x: { + 'body': [{'content-type': 'plain', 'raw': 'Hello world!'}, + {'content-type': 'html', 'raw': '<p>Hello html world!</p>'}], + 'header': { + 'cc': ['cc@pixelated.org', 'anothercc@pixelated.org'], + 'to': ['to@pixelated.org', 'anotherto@pixelated.org'], + 'bcc': ['bcc@pixelated.org', 'anotherbcc@pixelated.org'], + 'subject': 'Oi', + }, + 'ident': '', + 'tags': ['sent'] + } + def test_to_mime_multipart_should_add_blank_fields(self): pixelated.support.date.iso_now = lambda: 'date now' @@ -138,3 +151,12 @@ class InputMailTest(unittest.TestCase): smtp_format = InputMail.from_dict(self.mail_dict()).to_smtp_format() self.assertRegexpMatches(smtp_format, "\nFrom: pixelated@org") + + def test_to_mime_multipart_handles_alternative_bodies(self): + mime_multipart = InputMail.from_dict(self.multipart_mail_dict()).to_mime_multipart() + + part_one = 'Content-Type: text/plain; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\n\nHello world!' + part_two = 'Content-Type: text/html; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\n\n<p>Hello html world!</p>' + + self.assertRegexpMatches(mime_multipart.as_string(), part_one) + self.assertRegexpMatches(mime_multipart.as_string(), part_two) |