diff options
-rw-r--r-- | service/pixelated/adapter/mail_service.py | 2 | ||||
-rw-r--r-- | service/pixelated/adapter/pixelated_mailbox.py | 5 | ||||
-rw-r--r-- | service/test/adapter/mail_service_test.py | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/service/pixelated/adapter/mail_service.py b/service/pixelated/adapter/mail_service.py index 6949d6cb..162fa9c5 100644 --- a/service/pixelated/adapter/mail_service.py +++ b/service/pixelated/adapter/mail_service.py @@ -33,7 +33,7 @@ class MailService: def mails(self, query): _mails = None - if not query: + if not query['tags']: return self.mailbox.mails() if query['tags']: diff --git a/service/pixelated/adapter/pixelated_mailbox.py b/service/pixelated/adapter/pixelated_mailbox.py index 2f50c2b4..d2c31978 100644 --- a/service/pixelated/adapter/pixelated_mailbox.py +++ b/service/pixelated/adapter/pixelated_mailbox.py @@ -31,11 +31,16 @@ class PixelatedMailbox: return self.leap_mailbox.messages def mails(self): + + mails = self.leap_mailbox.messages or [] mails = [PixelatedMail.from_leap_mail(mail) for mail in mails] return mails def mails_by_tags(self, tags): + if 'all' in map(str, tags): + return self.mails() + return [mail for mail in self.mails() if len(mail.tags.intersection(tags)) > 0] def mail(self, mail_id): diff --git a/service/test/adapter/mail_service_test.py b/service/test/adapter/mail_service_test.py index f66a3fae..bd45c4bf 100644 --- a/service/test/adapter/mail_service_test.py +++ b/service/test/adapter/mail_service_test.py @@ -30,7 +30,7 @@ class TestMailService(unittest.TestCase): when(mailbox_inbox).mails().thenReturn(["mail"]) when(self.mailboxes).inbox().thenReturn(mailbox_inbox) - mails = self.mail_service.mails({}) + mails = self.mail_service.mails({'tags': {}}) self.assertEqual(1, len(mails)) |