From eb9af89a56da8f6d4afe759c8b88eaef5d181b8e Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Tue, 16 Sep 2014 16:56:59 -0300 Subject: #53 apply mailbox tag only on recent mail --- service/test/adapter/pixelated_mail_test.py | 7 +++++++ service/test/adapter/pixelated_mailbox_test.py | 12 +++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'service/test/adapter') diff --git a/service/test/adapter/pixelated_mail_test.py b/service/test/adapter/pixelated_mail_test.py index 9eab3d2c..4292883c 100644 --- a/service/test/adapter/pixelated_mail_test.py +++ b/service/test/adapter/pixelated_mail_test.py @@ -119,3 +119,10 @@ class TestPixelatedMail(unittest.TestCase): mail.mark_as_read() self.assertEquals(mail.leap_mail.setFlags.call_args[0], (('\\Seen',), 1)) + + def test_mark_as_not_recent(self): + mail = PixelatedMail.from_leap_mail(test_helper.leap_mail(flags=[])) + + mail.mark_as_not_recent() + + self.assertEquals(mail.leap_mail.setFlags.call_args[0], (('\\Recent',), -1)) diff --git a/service/test/adapter/pixelated_mailbox_test.py b/service/test/adapter/pixelated_mailbox_test.py index 9ac4f53e..b4ddb32d 100644 --- a/service/test/adapter/pixelated_mailbox_test.py +++ b/service/test/adapter/pixelated_mailbox_test.py @@ -31,9 +31,15 @@ class TestPixelatedMailbox(unittest.TestCase): self.tag_service = mock() self.mailbox = PixelatedMailbox(leap_mailbox, self.tag_service) - def test_mailbox_tag_is_added_when_new_mail_arrives(self): - mails = self.mailbox.mails() - self.assertIn('sent', mails[0].tags) + def test_mailbox_tag_is_added_when_recent_mail_arrives(self): + recent_leap_mail = test_helper.leap_mail(uid=0, mbox='SPAM', flags=['\\Recent']) + mailbox = PixelatedMailbox(test_helper.leap_mailbox(messages=[recent_leap_mail], mailbox_name='SPAM')) + self.assertIn('spam', mailbox.mails()[0].tags) + + def test_mailbox_tag_is_ignored_for_non_recent_mail(self): + recent_leap_mail = test_helper.leap_mail(uid=0, mbox='SPAM', flags=[]) + 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): PixelatedMail.from_email_address = 'pixel@ted.org' -- cgit v1.2.3