diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-09-19 11:49:23 -0300 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-09-19 11:49:23 -0300 |
commit | eb59c286605147442ae54005dc59812f4b086662 (patch) | |
tree | 539bded4347fd0dfe5cccf55530103a49947bc4d /service/test | |
parent | 610d356c0ad2e9ea47946f0212a945ed663d0106 (diff) |
Now it is possible to add_msg with either raw format (for when changing leap messages to different mailboxes) or smtp_format (when adding a brand new draft)
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/adapter/pixelated_mailbox_test.py | 21 | ||||
-rw-r--r-- | service/test/adapter/pixelated_mailboxes_test.py | 8 |
2 files changed, 20 insertions, 9 deletions
diff --git a/service/test/adapter/pixelated_mailbox_test.py b/service/test/adapter/pixelated_mailbox_test.py index ac9d3f34..8bff7e68 100644 --- a/service/test/adapter/pixelated_mailbox_test.py +++ b/service/test/adapter/pixelated_mailbox_test.py @@ -21,7 +21,7 @@ from pixelated.adapter.pixelated_mailbox import PixelatedMailbox from mockito import * -class TestPixelatedMailbox(unittest.TestCase): +class PixelatedMailboxTest(unittest.TestCase): def setUp(self): mail_one = test_helper.leap_mail(uid=0, mbox='SENT') leap_mailbox = test_helper.leap_mailbox(messages=[mail_one], mailbox_name='SENT') @@ -39,16 +39,27 @@ class TestPixelatedMailbox(unittest.TestCase): mailbox = PixelatedMailbox(test_helper.leap_mailbox(messages=[recent_leap_mail], mailbox_name='SPAM')) self.assertNotIn('spam', mailbox.mails()[0].tags) - def test_add_message_to_mailbox(self): + def test_add_message_to_mailbox_with_raw_message(self): mail = PixelatedMail.from_dict(test_helper.mail_dict()) - mail.raw_message = lambda: 'the mail in smtp format' + mail.raw_message = lambda: 'raw mail' + + leap_mailbox_messages = mock() + self.mailbox.leap_mailbox.messages = leap_mailbox_messages + + self.mailbox._do_add_async.wrapped_function(self.mailbox, mail, use_smtp_format=False) + + verify(leap_mailbox_messages).add_msg('raw mail') + + def test_add_message_to_mailbox_with_smtp_format(self): + mail = PixelatedMail.from_dict(test_helper.mail_dict()) + mail.to_smtp_format = lambda: 'smtp format mail' leap_mailbox_messages = mock() self.mailbox.leap_mailbox.messages = leap_mailbox_messages - self.mailbox._do_add_async.wrapped_function(self.mailbox, mail) + self.mailbox._do_add_async.wrapped_function(self.mailbox, mail, use_smtp_format=True) - verify(leap_mailbox_messages).add_msg('the mail in smtp format') + verify(leap_mailbox_messages).add_msg('smtp format mail') def test_remove_message_from_mailbox(self): mail = PixelatedMail.from_dict(test_helper.mail_dict()) diff --git a/service/test/adapter/pixelated_mailboxes_test.py b/service/test/adapter/pixelated_mailboxes_test.py index b112905c..e188354e 100644 --- a/service/test/adapter/pixelated_mailboxes_test.py +++ b/service/test/adapter/pixelated_mailboxes_test.py @@ -44,21 +44,21 @@ class PixelatedMailboxesTest(unittest.TestCase): def test_add_draft(self): mail = PixelatedMail() - when(self.drafts_mailbox).add(mail).thenReturn(1) + when(self.drafts_mailbox).add(mail, use_smtp_format=True).thenReturn(1) self.mailboxes.add_draft(mail) - verify(self.drafts_mailbox).add(mail) + verify(self.drafts_mailbox).add(mail, use_smtp_format=True) self.assertEqual('drafts', mail.mailbox_name) self.assertEqual(1, mail.uid) def test_update_draft(self): mail = PixelatedMail() - when(self.drafts_mailbox).add(mail).thenReturn(1) + when(self.drafts_mailbox).add(mail, use_smtp_format=True).thenReturn(1) self.mailboxes.update_draft(mail) - inorder.verify(self.drafts_mailbox).add(mail) + inorder.verify(self.drafts_mailbox).add(mail, use_smtp_format=True) inorder.verify(self.drafts_mailbox).remove(mail) self.assertEqual('drafts', mail.mailbox_name) |