From 660777bb8fee20bbbe4bb07cbc6679a11c29b7c3 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 10 Sep 2015 19:51:16 -0300 Subject: [test] leap_mailstore handles unknow uuid as empty Given a unknown mailbox uuid, we should return an empty string as name. This will show the mail as in 'all mails' instead of a KeyError. This scenario is supposed to happen only if the mail comes before the mailbox, which is our current unicorn. Anyway, when the missing mailbox gets created it will read correctly or let the see under all mails instead of breaking the account. --Issue #444 --- service/test/unit/adapter/mailstore/test_leap_mailstore.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'service/test/unit/adapter/mailstore') diff --git a/service/test/unit/adapter/mailstore/test_leap_mailstore.py b/service/test/unit/adapter/mailstore/test_leap_mailstore.py index 96a862be..4eabc144 100644 --- a/service/test/unit/adapter/mailstore/test_leap_mailstore.py +++ b/service/test/unit/adapter/mailstore/test_leap_mailstore.py @@ -239,6 +239,19 @@ class TestLeapMailStore(TestCase): self.assertEqual({'INBOX', 'OTHER'}, names) + @defer.inlineCallbacks + def test_handles_unmapped_mailbox_uuid(self): + # given + store = LeapMailStore(self.soledad) + new_uuid = 'UNICORN' + + # if no mailbox doc is created yet (async hell?) + when(self.soledad).get_from_index('by-type', 'mbox').thenReturn(defer.succeed([])) + + # then it should point to empty, which is all mails + name = yield store._mailbox_name_from_uuid(new_uuid) + self.assertEquals('', name) + @defer.inlineCallbacks def test_add_mail(self): expected_message = self._add_create_mail_mocks_to_soledad_from_fixture_file('mbox00000000') -- cgit v1.2.3