From 95b0e2e6f834804630bf9d091b156ac68ff20583 Mon Sep 17 00:00:00 2001 From: Patrick Maia Date: Wed, 17 Sep 2014 02:02:28 -0300 Subject: 74 - moves move_to_trash logic to PixelatedMailboxes and adds some tests --- service/test/adapter/pixelated_mailbox_test.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'service/test/adapter/pixelated_mailbox_test.py') diff --git a/service/test/adapter/pixelated_mailbox_test.py b/service/test/adapter/pixelated_mailbox_test.py index b4ddb32d..ac9d3f34 100644 --- a/service/test/adapter/pixelated_mailbox_test.py +++ b/service/test/adapter/pixelated_mailbox_test.py @@ -14,10 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . import unittest -from mockito import * -import leap -import os from pixelated.adapter.pixelated_mail import PixelatedMail +from pixelated.adapter.status import Status import test_helper from pixelated.adapter.pixelated_mailbox import PixelatedMailbox from mockito import * @@ -42,13 +40,24 @@ class TestPixelatedMailbox(unittest.TestCase): self.assertNotIn('spam', mailbox.mails()[0].tags) def test_add_message_to_mailbox(self): - PixelatedMail.from_email_address = 'pixel@ted.org' mail = PixelatedMail.from_dict(test_helper.mail_dict()) - mail.to_smtp_format = lambda: 'the mail in smtp format' + mail.raw_message = lambda: 'the mail in smtp format' leap_mailbox_messages = mock() self.mailbox.leap_mailbox.messages = leap_mailbox_messages - self.mailbox.add.wrapped_function(self.mailbox, mail) + self.mailbox._do_add_async.wrapped_function(self.mailbox, mail) verify(leap_mailbox_messages).add_msg('the mail in smtp format') + + def test_remove_message_from_mailbox(self): + mail = PixelatedMail.from_dict(test_helper.mail_dict()) + mail.raw_message = lambda: 'the mail in smtp format' + + mail.leap_mail = mock() + self.mailbox.leap_mailbox = mock() + + self.mailbox.remove(mail) + + verify(mail.leap_mail).setFlags((Status.PixelatedStatus.DELETED,), 1) + verify(self.mailbox.leap_mailbox).expunge() -- cgit v1.2.3