diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/adapter/mailstore/searchable_mailstore.py | 6 | ||||
-rw-r--r-- | service/test/unit/adapter/mailstore/test_searchable_mailstore.py | 11 |
2 files changed, 16 insertions, 1 deletions
diff --git a/service/pixelated/adapter/mailstore/searchable_mailstore.py b/service/pixelated/adapter/mailstore/searchable_mailstore.py index 7339bd18..264f41cc 100644 --- a/service/pixelated/adapter/mailstore/searchable_mailstore.py +++ b/service/pixelated/adapter/mailstore/searchable_mailstore.py @@ -54,6 +54,12 @@ class SearchableMailStore(object): # implementes MailStore self._search_engine.index_mail(moved_mail) defer.returnValue(moved_mail) + @defer.inlineCallbacks + def copy_mail_to_mailbox(self, mail_id, mailbox_name): + copied_mail = yield self._delegate.copy_mail_to_mailbox(mail_id, mailbox_name) + self._search_engine.index_mail(copied_mail) + defer.returnValue(copied_mail) + def __getattr__(self, name): """ Acts like method missing. If a method of MailStore is not implemented in this class, diff --git a/service/test/unit/adapter/mailstore/test_searchable_mailstore.py b/service/test/unit/adapter/mailstore/test_searchable_mailstore.py index 00695a19..cae6b2f3 100644 --- a/service/test/unit/adapter/mailstore/test_searchable_mailstore.py +++ b/service/test/unit/adapter/mailstore/test_searchable_mailstore.py @@ -77,13 +77,22 @@ class TestSearchableMailStore(TestCase): verify(self.search_index).index_mail(leap_mail) @defer.inlineCallbacks + def test_copy_mail_delegates_to_mail_store_and_updates_index(self): + copied_mail = LeapMail('new id', ANY_MAILBOX) + when(self.delegate_mail_store).copy_mail_to_mailbox('mail id', ANY_MAILBOX).thenReturn(defer.succeed(copied_mail)) + + result = yield self.store.copy_mail_to_mailbox('mail id', ANY_MAILBOX) + + verify(self.search_index).index_mail(copied_mail) + self.assertEqual(copied_mail, result) + + @defer.inlineCallbacks def test_move_mail_delegates_to_mail_store_and_updates_index(self): moved_mail = LeapMail('new id', ANY_MAILBOX) when(self.delegate_mail_store).move_mail_to_mailbox('mail id', ANY_MAILBOX).thenReturn(defer.succeed(moved_mail)) result = yield self.store.move_mail_to_mailbox('mail id', ANY_MAILBOX) - verify(self.delegate_mail_store).move_mail_to_mailbox('mail id', ANY_MAILBOX) verify(self.search_index).remove_from_index('mail id') verify(self.search_index).index_mail(moved_mail) self.assertEqual(moved_mail, result) |