diff options
-rw-r--r-- | service/integration/tags_test.py | 2 | ||||
-rw-r--r-- | service/pixelated/adapter/pixelated_mailbox.py | 10 | ||||
-rw-r--r-- | service/pixelated/adapter/tag_service.py | 4 | ||||
-rw-r--r-- | service/test/adapter/pixelated_mailbox_test.py | 12 |
4 files changed, 4 insertions, 24 deletions
diff --git a/service/integration/tags_test.py b/service/integration/tags_test.py index eb278a71..13e1c22d 100644 --- a/service/integration/tags_test.py +++ b/service/integration/tags_test.py @@ -36,7 +36,7 @@ class TagsTest(unittest.TestCase, SoledadTestBase): self.post_tags(mail.ident, self._tags_json(['IMPORTANT'])) mails = self.get_mails_by_tag('inbox') - self.assertEquals({'inbox', 'important'}, set(mails[0].tags)) + self.assertEquals({'important'}, set(mails[0].tags)) mails = self.get_mails_by_tag('important') self.assertEquals('Mail with tags', mails[0].subject) diff --git a/service/pixelated/adapter/pixelated_mailbox.py b/service/pixelated/adapter/pixelated_mailbox.py index 62ea57e6..e8c063e8 100644 --- a/service/pixelated/adapter/pixelated_mailbox.py +++ b/service/pixelated/adapter/pixelated_mailbox.py @@ -26,23 +26,16 @@ class PixelatedMailbox: self.mailbox_tag = mailbox_name.lower() self.querier = querier - def add_mailbox_tag_if_not_there(self, pixelated_mail): - if not pixelated_mail.has_tag(self.mailbox_tag): - pixelated_mail.update_tags({self.mailbox_tag}.union(pixelated_mail.tags)) - self.tag_service.notify_tags_updated({self.mailbox_tag}, [], pixelated_mail.ident) - pixelated_mail.mark_as_not_recent() - def mails(self): _mails = self.querier.all_mails_by_mailbox(self.mailbox_name) result = [] for mail in _mails: - self.add_mailbox_tag_if_not_there(mail) result.append(mail) return result def mails_by_tags(self, tags): - if 'all' in tags: + if 'all' in tags or self.mailbox_tag in tags: return self.mails() return [mail for mail in self.mails() if len(mail.tags.intersection(tags)) > 0] @@ -59,7 +52,6 @@ class PixelatedMailbox: mail.remove_all_tags() mail.set_mailbox(self.mailbox_name) mail.save() - self.add_mailbox_tag_if_not_there(mail) def remove(self, ident): mail = self.querier.mail(ident) diff --git a/service/pixelated/adapter/tag_service.py b/service/pixelated/adapter/tag_service.py index ecc64fad..dc13bc54 100644 --- a/service/pixelated/adapter/tag_service.py +++ b/service/pixelated/adapter/tag_service.py @@ -20,11 +20,11 @@ from pixelated.adapter.tag_index import TagIndex class TagService: instance = None - SPECIAL_TAGS = [Tag('inbox', True), Tag('sent', True), Tag('drafts', True), Tag('trash', True)] + SPECIAL_TAGS = {Tag('inbox', True), Tag('sent', True), Tag('drafts', True), Tag('trash', True)} @classmethod def extract_reserved(cls, tags): - return set(tag.name for tag in cls.SPECIAL_TAGS if tag.name in tags) + return {tag.name for tag in cls.SPECIAL_TAGS if tag.name in tags} @classmethod def get_instance(cls): diff --git a/service/test/adapter/pixelated_mailbox_test.py b/service/test/adapter/pixelated_mailbox_test.py index 5b1cfae5..a6e4a1ab 100644 --- a/service/test/adapter/pixelated_mailbox_test.py +++ b/service/test/adapter/pixelated_mailbox_test.py @@ -27,18 +27,6 @@ class PixelatedMailboxTest(unittest.TestCase): self.querier = mock() self.mailbox = PixelatedMailbox('INBOX', self.querier, tag_service=self.tag_service) - def test_mailbox_tag_is_added_when_recent_mail_arrives(self): - recent_leap_mail = test_helper.leap_mail(uid=0, mbox='INBOX', flags=['\\Recent']) - when(self.querier).all_mails_by_mailbox('INBOX').thenReturn([PixelatedMail.from_soledad(*recent_leap_mail, soledad_querier=self.querier)]) - - self.assertIn('inbox', self.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='INBOX', flags=[]) - when(self.querier).all_mails_by_mailbox('INBOX').thenReturn([PixelatedMail.from_soledad(*recent_leap_mail, soledad_querier=self.querier)]) - - self.assertNotIn('spam', self.mailbox.mails()[0].tags) - 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) |