diff options
-rw-r--r-- | service/pixelated/adapter/services/mailbox.py | 4 | ||||
-rw-r--r-- | service/test/unit/adapter/test_mailbox.py | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/service/pixelated/adapter/services/mailbox.py b/service/pixelated/adapter/services/mailbox.py index e358abda..a4029d78 100644 --- a/service/pixelated/adapter/services/mailbox.py +++ b/service/pixelated/adapter/services/mailbox.py @@ -23,6 +23,10 @@ class Mailbox(object): self.search_engine = search_engine self.querier = querier + @property + def fresh(self): + return self.querier.get_lastuid(self.mailbox_name) == 0 + def mail(self, mail_id): return self.querier.mail(mail_id) diff --git a/service/test/unit/adapter/test_mailbox.py b/service/test/unit/adapter/test_mailbox.py index 34777071..ed634648 100644 --- a/service/test/unit/adapter/test_mailbox.py +++ b/service/test/unit/adapter/test_mailbox.py @@ -34,3 +34,9 @@ class PixelatedMailboxTest(unittest.TestCase): self.mailbox.remove(1) verify(self.querier).remove_mail(mail) + + def test_fresh_mailbox_checking_lastuid(self): + when(self.querier).get_lastuid('INBOX').thenReturn(0) + self.assertTrue(self.mailbox.fresh) + when(self.querier).get_lastuid('INBOX').thenReturn(1) + self.assertFalse(self.mailbox.fresh) |