diff options
Diffstat (limited to 'service/test/unit')
-rw-r--r-- | service/test/unit/adapter/listener_test.py | 25 | ||||
-rw-r--r-- | service/test/unit/adapter/mail_service_test.py | 6 | ||||
-rw-r--r-- | service/test/unit/adapter/pixelated_mail_test.py | 2 | ||||
-rw-r--r-- | service/test/unit/adapter/pixelated_mailboxes_test.py | 15 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/abstract_leap_test.py | 3 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/leap_srp_test.py | 2 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/provider_test.py | 1 | ||||
-rw-r--r-- | service/test/unit/search/test_search_query.py | 3 | ||||
-rw-r--r-- | service/test/unit/user_agent_test.py | 3 |
9 files changed, 21 insertions, 39 deletions
diff --git a/service/test/unit/adapter/listener_test.py b/service/test/unit/adapter/listener_test.py index 284c6b16..e131aebd 100644 --- a/service/test/unit/adapter/listener_test.py +++ b/service/test/unit/adapter/listener_test.py @@ -16,16 +16,12 @@ import unittest from mockito import * -import pixelated.adapter.soledad_querier - -querier = mock() -when(pixelated.adapter.soledad_querier).get_soledad_querier_instance().thenReturn(querier) - from pixelated.adapter.listener import MailboxListener class MailboxListenerTest(unittest.TestCase): def setUp(self): + self.querier = mock() self.account = mock() self.account.mailboxes = [] @@ -36,11 +32,11 @@ class MailboxListenerTest(unittest.TestCase): mailbox.listeners = set() when(mailbox).addListener = lambda x: mailbox.listeners.add(x) - self.assertNotIn(MailboxListener('INBOX'), mailbox.listeners) + self.assertNotIn(MailboxListener('INBOX', self.querier), mailbox.listeners) - MailboxListener.listen(self.account, 'INBOX') + MailboxListener.listen(self.account, 'INBOX', self.querier) - self.assertIn(MailboxListener('INBOX'), mailbox.listeners) + self.assertIn(MailboxListener('INBOX', self.querier), mailbox.listeners) def test_reindex_missing_idents(self): search_engine = mock() @@ -48,12 +44,11 @@ class MailboxListenerTest(unittest.TestCase): MailboxListener.SEARCH_ENGINE = search_engine - listener = MailboxListener('INBOX') - listener.querier = querier - when(querier).idents_by_mailbox('INBOX').thenReturn({'ident1', 'ident2', 'missing_ident'}) - querier.used_arguments = [] - querier.mails = lambda x: querier.used_arguments.append(x) + listener = MailboxListener('INBOX', self.querier) + when(self.querier).idents_by_mailbox('INBOX').thenReturn({'ident1', 'ident2', 'missing_ident'}) + self.querier.used_arguments = [] + self.querier.mails = lambda x: self.querier.used_arguments.append(x) listener.newMessages(10, 5) - verify(querier, times=1).idents_by_mailbox('INBOX') - self.assertIn({'missing_ident'}, querier.used_arguments) + verify(self.querier, times=1).idents_by_mailbox('INBOX') + self.assertIn({'missing_ident'}, self.querier.used_arguments) diff --git a/service/test/unit/adapter/mail_service_test.py b/service/test/unit/adapter/mail_service_test.py index 21f34b12..c69f8f74 100644 --- a/service/test/unit/adapter/mail_service_test.py +++ b/service/test/unit/adapter/mail_service_test.py @@ -17,21 +17,19 @@ import unittest from pixelated.adapter.mail_service import MailService from mockito import * -import pixelated.adapter.soledad_querier class TestMailService(unittest.TestCase): def setUp(self): self.querier = mock() - pixelated.adapter.soledad_querier.get_soledad_querier_instance = lambda x, y: self.querier - self.mailboxes = mock() + self.tag_service = mock() self.mailboxes.drafts = lambda: mock() self.mailboxes.trash = lambda: mock() self.mailboxes.sent = lambda: mock() self.mail_sender = mock() - self.mail_service = MailService(self.mailboxes, self.mail_sender) + self.mail_service = MailService(self.mailboxes, self.mail_sender, self.tag_service, self.querier) def test_send_mail(self): mail = "mail" diff --git a/service/test/unit/adapter/pixelated_mail_test.py b/service/test/unit/adapter/pixelated_mail_test.py index 904f621d..eb66f0fb 100644 --- a/service/test/unit/adapter/pixelated_mail_test.py +++ b/service/test/unit/adapter/pixelated_mail_test.py @@ -15,10 +15,8 @@ # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. import unittest -import os import pixelated.support.date from pixelated.adapter.pixelated_mail import PixelatedMail, InputMail -from pixelated.adapter.tag import Tag from mockito import * from test.support import test_helper diff --git a/service/test/unit/adapter/pixelated_mailboxes_test.py b/service/test/unit/adapter/pixelated_mailboxes_test.py index ddb3e84b..3ca8cc2f 100644 --- a/service/test/unit/adapter/pixelated_mailboxes_test.py +++ b/service/test/unit/adapter/pixelated_mailboxes_test.py @@ -15,14 +15,7 @@ # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. import unittest -from test.support import test_helper from mockito import * -import pixelated.adapter.soledad_querier - -querier = mock() -when(pixelated.adapter.soledad_querier).get_soledad_querier_instance().thenReturn(querier) - -from pixelated.adapter.pixelated_mail import InputMail from pixelated.adapter.pixelated_mailbox import PixelatedMailbox from pixelated.adapter.pixelated_mailboxes import PixelatedMailBoxes @@ -30,19 +23,21 @@ from pixelated.adapter.pixelated_mailboxes import PixelatedMailBoxes class PixelatedMailboxesTest(unittest.TestCase): def setUp(self): + self.querier = mock() self.account = mock() self.account.mailboxes = [] self.drafts_mailbox = mock() self.drafts_mailbox.mailbox_name = 'drafts' - self.mailboxes = PixelatedMailBoxes(self.account) + self.mailboxes = PixelatedMailBoxes(self.account, self.querier) self.mailboxes.drafts = lambda: self.drafts_mailbox def test_search_for_tags(self): mailbox = mock() - self.account.mailboxes = ['INBOX'] + self.mailboxes.mailboxes = lambda: [mailbox] + tags_to_search_for = {'tags': ['inbox', 'custom_tag']} - when(PixelatedMailbox).create('INBOX').thenReturn(mailbox) + when(PixelatedMailbox).create('INBOX', self.querier).thenReturn(mailbox) when(mailbox).mails_by_tags(any(list)).thenReturn(["mail"]) mails = self.mailboxes.mails_by_tag(tags_to_search_for['tags']) diff --git a/service/test/unit/bitmask_libraries/abstract_leap_test.py b/service/test/unit/bitmask_libraries/abstract_leap_test.py index ddcfb08f..2634f330 100644 --- a/service/test/unit/bitmask_libraries/abstract_leap_test.py +++ b/service/test/unit/bitmask_libraries/abstract_leap_test.py @@ -13,10 +13,11 @@ # # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. -import os import tempfile import unittest from uuid import uuid4 + +import os from mock import Mock, MagicMock diff --git a/service/test/unit/bitmask_libraries/leap_srp_test.py b/service/test/unit/bitmask_libraries/leap_srp_test.py index 591929ce..6d067e5d 100644 --- a/service/test/unit/bitmask_libraries/leap_srp_test.py +++ b/service/test/unit/bitmask_libraries/leap_srp_test.py @@ -21,9 +21,9 @@ from urlparse import parse_qs from httmock import urlmatch, all_requests, HTTMock, response from requests.exceptions import Timeout import srp - from pixelated.bitmask_libraries.leap_srp import LeapSecureRemotePassword, LeapAuthException + (salt_bytes, verification_key_bytes) = srp.create_salted_verification_key('username', 'password', hash_alg=srp.SHA256, ng_type=srp.NG_1024) verifier = None diff --git a/service/test/unit/bitmask_libraries/provider_test.py b/service/test/unit/bitmask_libraries/provider_test.py index 41cf3bf4..dd57afa0 100644 --- a/service/test/unit/bitmask_libraries/provider_test.py +++ b/service/test/unit/bitmask_libraries/provider_test.py @@ -17,7 +17,6 @@ import json from httmock import all_requests, HTTMock, urlmatch from requests import HTTPError - from pixelated.bitmask_libraries.config import LeapConfig from pixelated.bitmask_libraries.provider import LeapProvider from abstract_leap_test import AbstractLeapTest diff --git a/service/test/unit/search/test_search_query.py b/service/test/unit/search/test_search_query.py index 3bcbd219..179d121a 100644 --- a/service/test/unit/search/test_search_query.py +++ b/service/test/unit/search/test_search_query.py @@ -13,9 +13,8 @@ # # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. -import sys -import os import unittest + import pixelated.search_query as search_query diff --git a/service/test/unit/user_agent_test.py b/service/test/unit/user_agent_test.py index ea695b26..0ea83a5d 100644 --- a/service/test/unit/user_agent_test.py +++ b/service/test/unit/user_agent_test.py @@ -15,12 +15,9 @@ # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. import unittest -import json import sys import pixelated.user_agent -from pixelated.adapter.tag import Tag -from pixelated.adapter.tag_service import TagService from mockito import * import crochet import pixelated.reactor_manager as reactor_manager |