def test_new_tags_are_added_to_mailbox(self):
        leap_flags = ['\\Deleted', 'tag_custom_one', 'tag_custom_two']
        leap_mailbox_mock = test_helper.leap_mailbox(leap_flags=leap_flags)
        mailbox = PixelatedMailbox(leap_mailbox_mock)
        tags = [Tag('custom_one'), Tag('custom_three')]
        mailbox.update_tags(tags)

        expected = set(('\\Deleted', 'tag_custom_one', 'tag_custom_two', 'tag_custom_three'))
        actual_args = set(leap_mailbox_mock.setFlags.call_args[0][0])

        self.assertEquals(expected, actual_args)
class PixelatedMailboxTest(unittest.TestCase):
    def setUp(self):
        self.tag_service = mock()
        self.querier = mock()
        self.mailbox = PixelatedMailbox('INBOX', self.querier, tag_service=self.tag_service)

    def test_remove_message_from_mailbox(self):
        mail = PixelatedMail.from_soledad(*test_helper.leap_mail(), soledad_querier=self.querier)
        when(self.querier).mail(1).thenReturn(mail)

        self.mailbox.remove(1)

        verify(self.querier).remove_mail(mail)
Ejemplo n.º 3
0
    def mails(self, query):
        if not query:
            return self.mailbox.mails()

        mails = []
        if query['tags']:
            tags = [Tag(tag) for tag in query['tags']]
            for leap_mailbox_name in self.account.mailboxes:
                mailbox = PixelatedMailbox(self.account.getMailbox(leap_mailbox_name))
                if len(mailbox.all_tags().intersection(tags)):
                    # mailbox has at least one mail with tag
                    for mail in mailbox.mails():
                        if len(mail.tags.intersection(tags)) > 0:
                            mails.append(mail)
        return mails
 def mailboxes(self):
     return [PixelatedMailbox.create(leap_mailbox_name) for leap_mailbox_name in
             self.account.mailboxes]
 def _create_or_get(self, mailbox_name):
     mailbox_name = mailbox_name.upper()
     if mailbox_name not in self.account.mailboxes:
         self.account.addMailbox(mailbox_name)
     return PixelatedMailbox.create(mailbox_name)
 def setUp(self):
     self.tag_service = mock()
     self.querier = mock()
     self.mailbox = PixelatedMailbox('INBOX', self.querier, tag_service=self.tag_service)
    def test_retrieve_all_tags_from_mailbox(self):
        leap_flags = ['\\Deleted', '\\Draft', '\\Recent', 'tag_custom', 'should_ignore_all_from_here', 'List']
        mailbox = PixelatedMailbox(test_helper.leap_mailbox(leap_flags=leap_flags))

        self.assertEquals(set([Tag('trash'), Tag('inbox'), Tag('drafts'), Tag('custom')]), mailbox.all_tags())