diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-03-22 00:55:56 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-03-22 01:00:32 -0300 |
commit | d6a6560f0ecd4d434f6fe5e1dd5f7bf40fcb2430 (patch) | |
tree | e3d6757ad45c41e1615ae095b69634248ce15ef0 | |
parent | 37781b4dccadb2e10589d814cd748ee6d83de9ab (diff) |
checks if a mailbox is fresh (uid is 0).
If so, we are able to put welcome mail on INBOX after checking it
-- Issue #334
-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) |