diff options
Diffstat (limited to 'service/test/unit/adapter/test_soledad_querier.py')
-rw-r--r-- | service/test/unit/adapter/test_soledad_querier.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/service/test/unit/adapter/test_soledad_querier.py b/service/test/unit/adapter/test_soledad_querier.py index 2cc23750..e5ea457d 100644 --- a/service/test/unit/adapter/test_soledad_querier.py +++ b/service/test/unit/adapter/test_soledad_querier.py @@ -104,3 +104,47 @@ class SoledadQuerierTest(unittest.TestCase): attachment = querier.attachment(u'0400BEBACAFE', 'quoted-printable') self.assertEquals('esse papo seu ta qualquer coisa', attachment['content']) + + def test_empty_or_null_queries_are_ignored(self): + soledad = mock() + when(soledad).get_from_index(any(), any(), any()).thenReturn(['nonempty', 'list']) + querier = SoledadQuerier(soledad) + + test_parameters = ['', None] + + def call_with_bad_parameters(funct): + for param in test_parameters: + self.assertFalse(funct(param)) + + call_with_bad_parameters(querier.get_all_flags_by_mbox) + call_with_bad_parameters(querier.get_content_by_phash) + call_with_bad_parameters(querier.get_flags_by_chash) + call_with_bad_parameters(querier.get_header_by_chash) + call_with_bad_parameters(querier.get_recent_by_mbox) + call_with_bad_parameters(querier.idents_by_mailbox) + call_with_bad_parameters(querier.get_mbox) + + def test_get_lastuid(self): + soledad = mock() + mbox = mock() + mbox.content = {'lastuid': 0} + when(soledad).get_from_index('by-type-and-mbox', 'mbox', 'INBOX').thenReturn([mbox]) + querier = SoledadQuerier(soledad) + + self.assertEquals(querier.get_lastuid(querier.get_mbox('INBOX')[0]), 0) + mbox.content = {'lastuid': 1} + self.assertEquals(querier.get_lastuid(querier.get_mbox('INBOX')[0]), 1) + + def test_create_mail_increments_uid(self): + soledad = mock() + mbox = mock() + mail = mock() + when(mail).get_for_save(next_uid=any(), mailbox='INBOX').thenReturn([]) + mbox.content = {'lastuid': 0} + when(soledad).get_from_index('by-type-and-mbox', 'mbox', 'INBOX').thenReturn([mbox]) + querier = SoledadQuerier(soledad) + when(querier).mail(any()).thenReturn([]) + + self.assertEquals(querier.get_lastuid(querier.get_mbox('INBOX')[0]), 0) + querier.create_mail(mail, 'INBOX') + self.assertEquals(querier.get_lastuid(querier.get_mbox('INBOX')[0]), 1) |