diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-08-26 19:11:01 -0300 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-08-26 19:11:01 -0300 |
commit | cf3ea5411adb12dd1bdc12ec01a17b37d974c7c3 (patch) | |
tree | 52b203175aee472099efb29bb47033b870cc9a8d /service/test/adapter | |
parent | 6095a286a0298c10df3b7bfa163f2f5240b580cd (diff) |
refactoring pixelatedMail constructor so we can have 'two' (from_dict and from_leap_mail)
Diffstat (limited to 'service/test/adapter')
-rw-r--r-- | service/test/adapter/pixelated_mail_test.py | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/service/test/adapter/pixelated_mail_test.py b/service/test/adapter/pixelated_mail_test.py index b0e2f9d2..308424e0 100644 --- a/service/test/adapter/pixelated_mail_test.py +++ b/service/test/adapter/pixelated_mail_test.py @@ -24,29 +24,52 @@ import test_helper class TestPixelatedMail(unittest.TestCase): def test_leap_recent_flag_is_translated_to_inbox_tag(self): - pixelated_mail = PixelatedMail(test_helper.leap_mail(leap_flags=['\\Recent'])) + pixelated_mail = PixelatedMail.from_leap_mail(test_helper.leap_mail(leap_flags=['\\Recent'])) self.assertIn(Tag('inbox'), pixelated_mail.tags) def test_leap_deleted_flag_is_translated_to_trash_tag(self): - pixelated_mail = PixelatedMail(test_helper.leap_mail(leap_flags=['\\Deleted'])) + pixelated_mail = PixelatedMail.from_leap_mail(test_helper.leap_mail(leap_flags=['\\Deleted'])) self.assertIn(Tag('trash'), pixelated_mail.tags) def test_leap_draft_flag_is_translated_to_draft_tag(self): - pixelated_mail = PixelatedMail(test_helper.leap_mail(leap_flags=['\\Draft'])) + pixelated_mail = PixelatedMail.from_leap_mail(test_helper.leap_mail(leap_flags=['\\Draft'])) self.assertIn(Tag('drafts'), pixelated_mail.tags) def test_leap_seen_flag_is_translated_to_read_status(self): - pixelated_mail = PixelatedMail(test_helper.leap_mail(leap_flags=['\\Seen'])) + pixelated_mail = PixelatedMail.from_leap_mail(test_helper.leap_mail(leap_flags=['\\Seen'])) self.assertIn('read', pixelated_mail.status) def test_leap_answered_flag_is_translated_to_replied_status(self): - pixelated_mail = PixelatedMail(test_helper.leap_mail(leap_flags=['\\Answered'])) + pixelated_mail = PixelatedMail.from_leap_mail(test_helper.leap_mail(leap_flags=['\\Answered'])) self.assertIn('replied', pixelated_mail.status) def test_leap_flags_that_are_custom_tags_are_handled(self): - pixelated_mail = PixelatedMail(test_helper.leap_mail(extra_flags=['tag_work'])) + pixelated_mail = PixelatedMail.from_leap_mail(test_helper.leap_mail(extra_flags=['tag_work'])) self.assertIn(Tag('work'), pixelated_mail.tags) def test_custom_tags_containing_our_prefix_are_handled(self): - pixelated_mail = PixelatedMail(test_helper.leap_mail(extra_flags=['tag_tag_work_tag_'])) + pixelated_mail = PixelatedMail.from_leap_mail(test_helper.leap_mail(extra_flags=['tag_tag_work_tag_'])) self.assertIn(Tag('tag_work_tag_'), pixelated_mail.tags) + + def from_dict(self): + mail_dict = { + 'body': 'Este \xe9 o corpo', + 'header': { + 'cc': ['cc@pixelated.com'], + 'to': ['to@pixelated.com'], + 'subject': 'Oi', + 'bcc': ['bcc@pixelated.com'] + }, + 'ident': '', + 'tags': ['sent'] + } + + mail = PixelatedMail.from_dict(mail_dict) + + self.assertEqual(mail.headers.cc, ['cc@pixelated.com']) + self.assertEqual(mail.headers.to, ['to@pixelated.com']) + self.assertEqual(mail.headers.bcc, ['bcc@pixelated.com']) + self.assertEqual(mail.headers.subject, 'Oi') + self.assertEqual(mail.ident, '') + self.assertEqual(mail.tags, ['sent']) + self.assertEqual(mail.body, 'Este \xe9 o corpo') |