diff options
Diffstat (limited to 'service/test')
4 files changed, 13 insertions, 14 deletions
diff --git a/service/test/integration/test_incoming_mail.py b/service/test/integration/test_incoming_mail.py index 682ca118..e413d6c1 100644 --- a/service/test/integration/test_incoming_mail.py +++ b/service/test/integration/test_incoming_mail.py @@ -25,12 +25,12 @@ class IncomingMailTest(SoledadTestBase): @defer.inlineCallbacks def test_message_collection(self): # given - mbx = yield self.account.getMailbox('INBOX') + mail_collection = yield self.account.get_collection_by_mailbox('INBOX') input_mail = MailBuilder().build_input_mail() # when yield MailboxIndexerListener.listen(self.account, 'INBOX', self.mail_store, self.search_engine) - yield mbx.addMessage(input_mail.raw, [], notify_just_mdoc=False) + yield mail_collection.add_msg(input_mail.raw) # then yield self.wait_in_reactor() # event handlers are called async, wait for it diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index f3ec5d25..95facec0 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -25,7 +25,7 @@ import uuid import random -from leap.mail.imap.account import IMAPAccount +from leap.mail.mail import Account from leap.soledad.client import Soledad from mock import Mock from twisted.internet import reactor, defer @@ -77,7 +77,7 @@ class AppTestAccount(object): self.mail_store = SearchableMailStore(LeapMailStore(self.soledad), self.search_engine) self.attachment_store = LeapAttachmentStore(self.soledad) - yield self._initialize_imap_account() + yield self._initialize_account() self.draft_service = DraftService(self.mail_store) self.leap_session = mock() @@ -110,10 +110,9 @@ class AppTestAccount(object): soledad_test_folder = os.path.join(self._leap_home, self._uuid) shutil.rmtree(soledad_test_folder) - def _initialize_imap_account(self): - account_ready_cb = defer.Deferred() - self.account = IMAPAccount(self._user_id, self.soledad, account_ready_cb) - return account_ready_cb + def _initialize_account(self): + self.account = Account(self.soledad) + return self.account.deferred_initialization def _create_mail_service(self, mail_sender, mail_store, search_engine, attachment_store): return MailService(mail_sender, mail_store, search_engine, self._mail_address, attachment_store) diff --git a/service/test/unit/adapter/test_mailbox_indexer_listener.py b/service/test/unit/adapter/test_mailbox_indexer_listener.py index c88ba035..c101aa1a 100644 --- a/service/test/unit/adapter/test_mailbox_indexer_listener.py +++ b/service/test/unit/adapter/test_mailbox_indexer_listener.py @@ -31,7 +31,7 @@ class MailboxListenerTest(unittest.TestCase): def test_add_itself_to_mailbox_listeners(self): self.account.mailboxes = ['INBOX'] mailbox = mock() - when(self.account).getMailbox('INBOX').thenReturn(mailbox) + when(self.account).get_collection_by_mailbox('INBOX').thenReturn(mailbox) mailbox.listeners = set() when(mailbox).addListener = lambda x: mailbox.listeners.add(x) @@ -49,7 +49,7 @@ class MailboxListenerTest(unittest.TestCase): listener = MailboxIndexerListener('INBOX', self.mail_store, search_engine) when(self.mail_store).get_mailbox_mail_ids('INBOX').thenReturn({'ident1', 'ident2', 'missing_ident'}) when(self.mail_store).get_mails({'missing_ident'}, include_body=True).thenReturn([mail]) - listener.newMessages(10, 5) + listener.notify_new() verify(self.mail_store, times=1).get_mails({'missing_ident'}, include_body=True) verify(search_engine).index_mails([mail]) @@ -59,6 +59,6 @@ class MailboxListenerTest(unittest.TestCase): when(logger).error(ANY()).thenReturn(None) listener = MailboxIndexerListener('INBOX', self.mail_store, mock()) - yield listener.newMessages(1, 1) + yield listener.notify_new() verify(logger).error(ANY()) diff --git a/service/test/unit/bitmask_libraries/test_session.py b/service/test/unit/bitmask_libraries/test_session.py index aad2cac2..84f9f023 100644 --- a/service/test/unit/bitmask_libraries/test_session.py +++ b/service/test/unit/bitmask_libraries/test_session.py @@ -29,7 +29,7 @@ class SessionTest(AbstractLeapTest): self.smtp_mock = MagicMock() @patch('pixelated.bitmask_libraries.session.register') - @patch('pixelated.bitmask_libraries.session.IMAPAccount') + @patch('pixelated.bitmask_libraries.session.Account') @defer.inlineCallbacks def test_background_jobs_are_started_during_initial_sync(self, *unused): mailFetcherMock = MagicMock() @@ -41,7 +41,7 @@ class SessionTest(AbstractLeapTest): @patch('pixelated.bitmask_libraries.session.register') @patch('pixelated.bitmask_libraries.session.unregister') - @patch('pixelated.bitmask_libraries.session.IMAPAccount') + @patch('pixelated.bitmask_libraries.session.Account') @defer.inlineCallbacks def test_that_close_stops_background_jobs(self, *unused): with patch('pixelated.bitmask_libraries.session.reactor.callFromThread', new=_execute_func) as _: @@ -153,7 +153,7 @@ class SessionTest(AbstractLeapTest): @patch('pixelated.bitmask_libraries.session.register') @patch('pixelated.bitmask_libraries.session.unregister') - @patch('pixelated.bitmask_libraries.session.IMAPAccount') + @patch('pixelated.bitmask_libraries.session.Account') @defer.inlineCallbacks def test_session_initial_sync_only_triggered_once(self, *unused): mailFetcherMock = MagicMock() |