summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoald de Vries <rdevries@thoughtworks.com>2016-10-06 17:03:44 -0300
committerRoald de Vries <rdevries@thoughtworks.com>2016-10-07 18:25:02 -0300
commitf4d7541c9b6dcf67b57b13f7ca7434ec68eeb59c (patch)
tree8d50a54a9a8d5dd451253e55275f209f9df32b0a /service
parent4642cee939c08bfa809f55b6a85ffa773600eaf9 (diff)
use test client in test case through composition instead of inheritance
Diffstat (limited to 'service')
-rw-r--r--service/test/integration/test_contacts.py24
-rw-r--r--service/test/integration/test_delete_mail.py30
-rw-r--r--service/test/integration/test_draft_service.py12
-rw-r--r--service/test/integration/test_drafts.py26
-rw-r--r--service/test/integration/test_incoming_mail.py10
-rw-r--r--service/test/integration/test_leap_mailstore.py82
-rw-r--r--service/test/integration/test_logout.py19
-rw-r--r--service/test/integration/test_mark_as_read_unread.py48
-rw-r--r--service/test/integration/test_multi_user_login.py15
-rw-r--r--service/test/integration/test_retrieve_attachment.py18
-rw-r--r--service/test/integration/test_search.py62
-rw-r--r--service/test/integration/test_tags.py44
-rw-r--r--service/test/integration/test_users_count.py20
-rw-r--r--service/test/support/integration/app_test_client.py5
-rw-r--r--service/test/support/integration/multi_user_client.py6
-rw-r--r--service/test/support/integration/soledad_test_base.py25
-rw-r--r--service/test/support/mockito/__init__.py20
-rw-r--r--service/test/unit/adapter/mailstore/test_leap_attachment_store.py10
-rw-r--r--service/test/unit/adapter/mailstore/test_leap_mailstore.py21
-rw-r--r--service/test/unit/resources/test_login_resource.py6
-rw-r--r--service/test/unit/resources/test_users_resource.py2
21 files changed, 281 insertions, 224 deletions
diff --git a/service/test/integration/test_contacts.py b/service/test/integration/test_contacts.py
index e7fabdb7..946818fd 100644
--- a/service/test/integration/test_contacts.py
+++ b/service/test/integration/test_contacts.py
@@ -24,9 +24,9 @@ class ContactsTest(SoledadTestBase):
@defer.inlineCallbacks
def test_TO_CC_and_BCC_fields_are_being_searched(self):
input_mail = MailBuilder().with_tags(['important']).build_input_mail()
- yield self.add_mail_to_inbox(input_mail)
+ yield self.app_test_client.add_mail_to_inbox(input_mail)
- contacts = yield self.get_contacts(query='recipient')
+ contacts = yield self.app_test_client.get_contacts(query='recipient')
self.assertTrue('recipient@to.com' in contacts)
self.assertTrue('recipient@cc.com' in contacts)
@@ -35,20 +35,20 @@ class ContactsTest(SoledadTestBase):
@defer.inlineCallbacks
def test_FROM_address_is_being_searched(self):
input_mail = MailBuilder().with_tags(['important']).with_from('Formatted Sender <sender@from.com>').build_input_mail()
- yield self.add_mail_to_inbox(input_mail)
+ yield self.app_test_client.add_mail_to_inbox(input_mail)
- contacts = yield self.get_contacts(query='Sender')
+ contacts = yield self.app_test_client.get_contacts(query='Sender')
self.assertIn('Formatted Sender <sender@from.com>', contacts)
@defer.inlineCallbacks
def test_trash_and_drafts_mailboxes_are_being_ignored(self):
- yield self.add_multiple_to_mailbox(1, mailbox='INBOX', to='recipient@inbox.com')
- yield self.add_multiple_to_mailbox(1, mailbox='DRAFTS', to='recipient@drafts.com')
- yield self.add_multiple_to_mailbox(1, mailbox='SENT', to='recipient@sent.com')
- yield self.add_multiple_to_mailbox(1, mailbox='TRASH', to='recipient@trash.com')
+ yield self.app_test_client.add_multiple_to_mailbox(1, mailbox='INBOX', to='recipient@inbox.com')
+ yield self.app_test_client.add_multiple_to_mailbox(1, mailbox='DRAFTS', to='recipient@drafts.com')
+ yield self.app_test_client.add_multiple_to_mailbox(1, mailbox='SENT', to='recipient@sent.com')
+ yield self.app_test_client.add_multiple_to_mailbox(1, mailbox='TRASH', to='recipient@trash.com')
- contacts = yield self.get_contacts(query='recipient')
+ contacts = yield self.app_test_client.get_contacts(query='recipient')
self.assertTrue('recipient@inbox.com' in contacts)
self.assertTrue('recipient@sent.com' in contacts)
@@ -65,10 +65,10 @@ class ContactsTest(SoledadTestBase):
formatted_input_mail.with_bcc('Recipient Carbon <recipient@bcc.com>')
formatted_input_mail = formatted_input_mail.build_input_mail()
- yield self.add_mail_to_inbox(input_mail)
- yield self.add_mail_to_inbox(formatted_input_mail)
+ yield self.app_test_client.add_mail_to_inbox(input_mail)
+ yield self.app_test_client.add_mail_to_inbox(formatted_input_mail)
- contacts = yield self.get_contacts(query='Recipient')
+ contacts = yield self.app_test_client.get_contacts(query='Recipient')
self.assertEquals(4, len(contacts))
self.assertTrue('Recipient Copied <recipient@cc.com>' in contacts)
diff --git a/service/test/integration/test_delete_mail.py b/service/test/integration/test_delete_mail.py
index 9e5143e1..a912f9f0 100644
--- a/service/test/integration/test_delete_mail.py
+++ b/service/test/integration/test_delete_mail.py
@@ -22,44 +22,44 @@ class DeleteMailTest(SoledadTestBase):
@defer.inlineCallbacks
def test_move_mail_to_trash_when_deleting(self):
input_mail = MailBuilder().with_subject('Mail with tags').build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
- inbox_mails = yield self.get_mails_by_tag('inbox')
+ inbox_mails = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertEquals(1, len(inbox_mails))
- yield self.delete_mail(mail.mail_id)
+ yield self.app_test_client.delete_mail(mail.mail_id)
- inbox_mails = yield self.get_mails_by_tag('inbox')
+ inbox_mails = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertEquals(0, len(inbox_mails))
- trash_mails = yield self.get_mails_by_tag('trash')
+ trash_mails = yield self.app_test_client.get_mails_by_tag('trash')
self.assertEquals(1, len(trash_mails))
@defer.inlineCallbacks
def test_delete_mail_when_trashing_mail_from_trash_mailbox(self):
- mails = yield self.add_multiple_to_mailbox(1, 'trash')
- yield self.delete_mails([mails[0].ident])
+ mails = yield self.app_test_client.add_multiple_to_mailbox(1, 'trash')
+ yield self.app_test_client.delete_mails([mails[0].ident])
- trash_mails = yield self.get_mails_by_tag('trash')
+ trash_mails = yield self.app_test_client.get_mails_by_tag('trash')
self.assertEqual(0, len(trash_mails))
@defer.inlineCallbacks
def test_move_mail_to_trash_when_delete_multiple(self):
- yield self.add_multiple_to_mailbox(1, 'trash')
- mails = yield self.add_multiple_to_mailbox(5, 'inbox')
+ yield self.app_test_client.add_multiple_to_mailbox(1, 'trash')
+ mails = yield self.app_test_client.add_multiple_to_mailbox(5, 'inbox')
mail_idents = [m.ident for m in mails]
- yield self.delete_mails(mail_idents)
+ yield self.app_test_client.delete_mails(mail_idents)
- inbox = yield self.get_mails_by_tag('inbox')
+ inbox = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertEquals(0, len(inbox))
@defer.inlineCallbacks
def test_delete_permanently_when_mails_are_in_trash(self):
- mails = yield self.add_multiple_to_mailbox(5, 'trash')
+ mails = yield self.app_test_client.add_multiple_to_mailbox(5, 'trash')
mail_idents = [m.ident for m in mails]
- yield self.delete_mails(mail_idents)
+ yield self.app_test_client.delete_mails(mail_idents)
- trash = yield self.get_mails_by_tag('trash')
+ trash = yield self.app_test_client.get_mails_by_tag('trash')
self.assertEquals(0, len(trash))
diff --git a/service/test/integration/test_draft_service.py b/service/test/integration/test_draft_service.py
index 4f4a9181..159de605 100644
--- a/service/test/integration/test_draft_service.py
+++ b/service/test/integration/test_draft_service.py
@@ -25,23 +25,23 @@ class DraftServiceTest(SoledadTestBase):
def test_store_and_load_draft(self):
input_mail = MailBuilder().with_body('some test text').build_input_mail()
draft_id = None
- stored_draft = yield self.draft_service.process_draft(draft_id, input_mail)
+ stored_draft = yield self.app_test_client.draft_service.process_draft(draft_id, input_mail)
- draft = yield self.mail_store.get_mail(stored_draft.ident, include_body=True)
+ draft = yield self.app_test_client.mail_store.get_mail(stored_draft.ident, include_body=True)
self.assertEqual('some test text', draft.body)
@defer.inlineCallbacks
def test_update_draft(self):
input_mail = MailBuilder().with_body('some test text').build_input_mail()
- saved_mail = yield self.mail_store.add_mail('DRAFTS', input_mail.raw)
+ saved_mail = yield self.app_test_client.mail_store.add_mail('DRAFTS', input_mail.raw)
draft_id = saved_mail.ident
new_email = MailBuilder().with_body('other test text').with_ident(draft_id).build_input_mail()
- stored_draft = yield self.draft_service.process_draft(draft_id, new_email)
+ stored_draft = yield self.app_test_client.draft_service.process_draft(draft_id, new_email)
- old_draft = yield self.mail_store.get_mail(draft_id, include_body=True)
- draft = yield self.mail_store.get_mail(stored_draft.ident, include_body=True)
+ old_draft = yield self.app_test_client.mail_store.get_mail(draft_id, include_body=True)
+ draft = yield self.app_test_client.mail_store.get_mail(stored_draft.ident, include_body=True)
self.assertIsNone(old_draft)
self.assertEqual('other test text', draft.body)
diff --git a/service/test/integration/test_drafts.py b/service/test/integration/test_drafts.py
index a2c71af4..657cfab1 100644
--- a/service/test/integration/test_drafts.py
+++ b/service/test/integration/test_drafts.py
@@ -28,11 +28,11 @@ class DraftsTest(SoledadTestBase):
def test_post_sends_mail_and_deletes_previous_draft_if_it_exists(self):
# act as if sending the mail by SMTP succeeded
sendmail_deferred = defer.Deferred()
- when(self.mail_sender).sendmail(any()).thenReturn(sendmail_deferred)
+ when(self.app_test_client.mail_sender).sendmail(any()).thenReturn(sendmail_deferred)
# creates one draft
first_draft = MailBuilder().with_subject('First draft').build_json()
- first_draft_ident = (yield self.put_mail(first_draft)[0])['ident']
+ first_draft_ident = (yield self.app_test_client.put_mail(first_draft)[0])['ident']
# sends an updated version of the draft
second_draft = MailBuilder().with_subject('Second draft').with_ident(first_draft_ident).build_json()
@@ -42,8 +42,8 @@ class DraftsTest(SoledadTestBase):
yield deferred_res
- sent_mails = yield self.get_mails_by_tag('sent')
- drafts = yield self.get_mails_by_tag('drafts')
+ sent_mails = yield self.app_test_client.get_mails_by_tag('sent')
+ drafts = yield self.app_test_client.get_mails_by_tag('drafts')
# make sure there is one email in the sent mailbox and it is the second draft
self.assertEquals(1, len(sent_mails))
@@ -56,41 +56,41 @@ class DraftsTest(SoledadTestBase):
def test_post_sends_mail_even_when_draft_does_not_exist(self):
# act as if sending the mail by SMTP succeeded
sendmail_deferred = defer.Deferred()
- when(self.mail_sender).sendmail(any()).thenReturn(sendmail_deferred)
+ when(self.app_test_client.mail_sender).sendmail(any()).thenReturn(sendmail_deferred)
first_draft = MailBuilder().with_subject('First draft').build_json()
res = self.post_mail(first_draft)
sendmail_deferred.callback(True)
yield res
- sent_mails = yield self.get_mails_by_tag('sent')
- drafts = yield self.get_mails_by_tag('drafts')
+ sent_mails = yield self.app_test_client.get_mails_by_tag('sent')
+ drafts = yield self.app_test_client.get_mails_by_tag('drafts')
self.assertEquals(1, len(sent_mails))
self.assertEquals('First draft', sent_mails[0].subject)
self.assertEquals(0, len(drafts))
def post_mail(self, data):
- deferred_res, req = self.post('/mails', data)
+ deferred_res, req = self.app_test_client.post('/mails', data)
return deferred_res
@defer.inlineCallbacks
def test_put_creates_a_draft_if_it_does_not_exist(self):
mail = MailBuilder().with_subject('A new draft').build_json()
- yield self.put_mail(mail)[0]
- mails = yield self.get_mails_by_tag('drafts')
+ yield self.app_test_client.put_mail(mail)[0]
+ mails = yield self.app_test_client.get_mails_by_tag('drafts')
self.assertEquals('A new draft', mails[0].subject)
@defer.inlineCallbacks
def test_put_updates_draft_if_it_already_exists(self):
draft = MailBuilder().with_subject('First draft').build_json()
- draft_ident = (yield self.put_mail(draft)[0])['ident']
+ draft_ident = (yield self.app_test_client.put_mail(draft)[0])['ident']
updated_draft = MailBuilder().with_subject('First draft edited').with_ident(draft_ident).build_json()
- yield self.put_mail(updated_draft)[0]
+ yield self.app_test_client.put_mail(updated_draft)[0]
- drafts = yield self.get_mails_by_tag('drafts')
+ drafts = yield self.app_test_client.get_mails_by_tag('drafts')
self.assertEquals(1, len(drafts))
self.assertEquals('First draft edited', drafts[0].subject)
diff --git a/service/test/integration/test_incoming_mail.py b/service/test/integration/test_incoming_mail.py
index e413d6c1..62d7b97e 100644
--- a/service/test/integration/test_incoming_mail.py
+++ b/service/test/integration/test_incoming_mail.py
@@ -25,17 +25,21 @@ class IncomingMailTest(SoledadTestBase):
@defer.inlineCallbacks
def test_message_collection(self):
# given
- mail_collection = yield self.account.get_collection_by_mailbox('INBOX')
+ mail_collection = yield self.app_test_client.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 MailboxIndexerListener.listen(
+ self.app_test_client.account,
+ 'INBOX',
+ self.app_test_client.mail_store,
+ self.app_test_client.search_engine)
yield mail_collection.add_msg(input_mail.raw)
# then
yield self.wait_in_reactor() # event handlers are called async, wait for it
- mails, mail_count = self.search_engine.search('in:all')
+ mails, mail_count = self.app_test_client.search_engine.search('in:all')
self.assertEqual(1, mail_count)
self.assertEqual(1, len(mails))
diff --git a/service/test/integration/test_leap_mailstore.py b/service/test/integration/test_leap_mailstore.py
index 7a39e0c0..d331c22a 100644
--- a/service/test/integration/test_leap_mailstore.py
+++ b/service/test/integration/test_leap_mailstore.py
@@ -18,7 +18,19 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from test.support.integration import SoledadTestBase, load_mail_from_file
from twisted.internet import defer
-from pixelated.adapter.model.mail import InputMail
+import time
+from contextlib import contextmanager
+
+
+@contextmanager
+def measure():
+ start_time = time.time()
+ start_clock = time.clock()
+ yield
+ end_time = time.time()
+ end_clock = time.clock()
+ # print 'time: %10d - %10d = %10d' % (start_time, end_time, start_time - end_time)
+ # print 'clock: %10d - %10d = %10d' % (start_clock, end_clock, start_clock - end_clock)
class LeapMailStoreTest(SoledadTestBase):
@@ -28,13 +40,25 @@ class LeapMailStoreTest(SoledadTestBase):
yield super(LeapMailStoreTest, self).setUp()
@defer.inlineCallbacks
+ def test_get_mail_for_measuring(self):
+ self.maxDiff = None
+ mail = load_mail_from_file('mbox00000000')
+ mail_id = yield self._create_mail_in_soledad(mail)
+ expected_mail_dict = {'body': u'Dignissimos ducimus veritatis. Est tenetur consequatur quia occaecati. Vel sit sit voluptas.\n\nEarum distinctio eos. Accusantium qui sint ut quia assumenda. Facere dignissimos inventore autem sit amet. Pariatur voluptatem sint est.\n\nUt recusandae praesentium aspernatur. Exercitationem amet placeat deserunt quae consequatur eum. Unde doloremque suscipit quia.\n\n', 'header': {u'date': u'Tue, 21 Apr 2015 08:43:27 +0000 (UTC)', u'to': [u'carmel@murazikortiz.name'], u'x-tw-pixelated-tags': u'nite, macro, trash', u'from': u'darby.senger@zemlak.biz', u'subject': u'Itaque consequatur repellendus provident sunt quia.'}, 'ident': mail_id, 'status': [], 'tags': set([]), 'textPlainBody': u'Dignissimos ducimus veritatis. Est tenetur consequatur quia occaecati. Vel sit sit voluptas.\n\nEarum distinctio eos. Accusantium qui sint ut quia assumenda. Facere dignissimos inventore autem sit amet. Pariatur voluptatem sint est.\n\nUt recusandae praesentium aspernatur. Exercitationem amet placeat deserunt quae consequatur eum. Unde doloremque suscipit quia.\n\n', 'mailbox': u'inbox', 'attachments': [], 'security_casing': {'imprints': [{'state': 'no_signature_information'}], 'locks': []}}
+
+ with measure():
+ result = yield self.app_test_client.mail_store.get_mail(mail_id, include_body=True)
+ self.assertIsNotNone(result)
+ self.assertEqual(expected_mail_dict, result.as_dict())
+
+ @defer.inlineCallbacks
def test_get_mail_with_body(self):
self.maxDiff = None
mail = load_mail_from_file('mbox00000000')
mail_id = yield self._create_mail_in_soledad(mail)
expected_mail_dict = {'body': u'Dignissimos ducimus veritatis. Est tenetur consequatur quia occaecati. Vel sit sit voluptas.\n\nEarum distinctio eos. Accusantium qui sint ut quia assumenda. Facere dignissimos inventore autem sit amet. Pariatur voluptatem sint est.\n\nUt recusandae praesentium aspernatur. Exercitationem amet placeat deserunt quae consequatur eum. Unde doloremque suscipit quia.\n\n', 'header': {u'date': u'Tue, 21 Apr 2015 08:43:27 +0000 (UTC)', u'to': [u'carmel@murazikortiz.name'], u'x-tw-pixelated-tags': u'nite, macro, trash', u'from': u'darby.senger@zemlak.biz', u'subject': u'Itaque consequatur repellendus provident sunt quia.'}, 'ident': mail_id, 'status': [], 'tags': set([]), 'textPlainBody': u'Dignissimos ducimus veritatis. Est tenetur consequatur quia occaecati. Vel sit sit voluptas.\n\nEarum distinctio eos. Accusantium qui sint ut quia assumenda. Facere dignissimos inventore autem sit amet. Pariatur voluptatem sint est.\n\nUt recusandae praesentium aspernatur. Exercitationem amet placeat deserunt quae consequatur eum. Unde doloremque suscipit quia.\n\n', 'mailbox': u'inbox', 'attachments': [], 'security_casing': {'imprints': [{'state': 'no_signature_information'}], 'locks': []}}
- result = yield self.mail_store.get_mail(mail_id, include_body=True)
+ result = yield self.app_test_client.mail_store.get_mail(mail_id, include_body=True)
self.assertIsNotNone(result)
self.assertEqual(expected_mail_dict, result.as_dict())
@@ -46,8 +70,8 @@ class LeapMailStoreTest(SoledadTestBase):
attachment.add_header('Content-Disposition', 'attachment', filename='filename.txt')
input_mail.attach(attachment)
- mail = yield self.mail_store.add_mail('INBOX', input_mail.as_string())
- fetched_mail = yield self.mail_store.get_mail(mail.ident, include_body=True)
+ mail = yield self.app_test_client.mail_store.add_mail('INBOX', input_mail.as_string())
+ fetched_mail = yield self.app_test_client.mail_store.get_mail(mail.ident, include_body=True)
self.assertTrue(fetched_mail.as_dict()['attachments'])
@defer.inlineCallbacks
@@ -58,8 +82,8 @@ class LeapMailStoreTest(SoledadTestBase):
attachment.add_header('Content-Disposition', 'attachment', filename='filename.txt')
input_mail.attach(attachment)
- mail = yield self.mail_store.add_mail('INBOX', input_mail.as_string())
- fetched_mail = yield self.mail_store.get_mail(mail.ident, include_body=True)
+ mail = yield self.app_test_client.mail_store.add_mail('INBOX', input_mail.as_string())
+ fetched_mail = yield self.app_test_client.mail_store.get_mail(mail.ident, include_body=True)
fetched_attachment_name = fetched_mail.as_dict()['attachments'][0]['name']
self.assertEqual(fetched_attachment_name, 'filename.txt')
@@ -71,8 +95,8 @@ class LeapMailStoreTest(SoledadTestBase):
attachment.add_header('content-disposition', 'attachment', filename='filename.txt')
input_mail.attach(attachment)
- mail = yield self.mail_store.add_mail('INBOX', input_mail.as_string())
- fetched_mail = yield self.mail_store.get_mail(mail.ident, include_body=True)
+ mail = yield self.app_test_client.mail_store.add_mail('INBOX', input_mail.as_string())
+ fetched_mail = yield self.app_test_client.mail_store.get_mail(mail.ident, include_body=True)
fetched_attachment_name = fetched_mail.as_dict()['attachments'][0]['name']
self.assertEqual(fetched_attachment_name, 'filename.txt')
@@ -82,8 +106,8 @@ class LeapMailStoreTest(SoledadTestBase):
mail_id = yield self._create_mail_in_soledad(mail)
expected_mail_dict = {'body': u'Dignissimos ducimus veritatis. Est tenetur consequatur quia occaecati. Vel sit sit voluptas.\n\nEarum distinctio eos. Accusantium qui sint ut quia assumenda. Facere dignissimos inventore autem sit amet. Pariatur voluptatem sint est.\n\nUt recusandae praesentium aspernatur. Exercitationem amet placeat deserunt quae consequatur eum. Unde doloremque suscipit quia.\n\n', 'header': {u'date': u'Tue, 21 Apr 2015 08:43:27 +0000 (UTC)', u'to': [u'carmel@murazikortiz.name'], u'x-tw-pixelated-tags': u'nite, macro, trash', u'from': u'darby.senger@zemlak.biz', u'subject': u'Itaque consequatur repellendus provident sunt quia.'}, 'ident': mail_id, 'status': [], 'tags': set([])}
- mail = yield self.mail_store.add_mail('INBOX', mail.as_string())
- fetched_mail = yield self.mail_store.get_mail(mail_id, include_body=True)
+ mail = yield self.app_test_client.mail_store.add_mail('INBOX', mail.as_string())
+ fetched_mail = yield self.app_test_client.mail_store.get_mail(mail_id, include_body=True)
self.assertEqual(expected_mail_dict['header'], mail.as_dict()['header'])
self.assertEqual(expected_mail_dict['header'], fetched_mail.as_dict()['header'])
@@ -95,8 +119,8 @@ class LeapMailStoreTest(SoledadTestBase):
attachment.add_header('Content-Disposition', 'attachment', filename='filename.txt')
input_mail.attach(attachment)
- mail = yield self.mail_store.add_mail('INBOX', input_mail.as_string())
- fetched_mail = yield self.mail_store.get_mail(mail.ident, include_body=True)
+ mail = yield self.app_test_client.mail_store.add_mail('INBOX', input_mail.as_string())
+ fetched_mail = yield self.app_test_client.mail_store.get_mail(mail.ident, include_body=True)
self.assertDictEqual(mail.as_dict(), fetched_mail.as_dict())
@defer.inlineCallbacks
@@ -104,34 +128,34 @@ class LeapMailStoreTest(SoledadTestBase):
mail = load_mail_from_file('mbox00000000')
yield self._create_mail_in_soledad(mail)
- mails = yield self.mail_store.all_mails()
+ mails = yield self.app_test_client.mail_store.all_mails()
self.assertEqual(1, len(mails))
self.assertEqual('Itaque consequatur repellendus provident sunt quia.', mails[0].subject)
@defer.inlineCallbacks
def test_add_and_remove_mail(self):
- yield self.adaptor.initialize_store(self.soledad)
+ yield self.adaptor.initialize_store(self.app_test_client.soledad)
mail = load_mail_from_file('mbox00000000')
- yield self.mail_store.add_mailbox('INBOX')
+ yield self.app_test_client.mail_store.add_mailbox('INBOX')
- msg = yield self.mail_store.add_mail('INBOX', mail.as_string())
+ msg = yield self.app_test_client.mail_store.add_mail('INBOX', mail.as_string())
- yield self.mail_store.delete_mail(msg.mail_id)
+ yield self.app_test_client.mail_store.delete_mail(msg.mail_id)
- deleted_msg = yield self.mail_store.get_mail(msg.mail_id)
+ deleted_msg = yield self.app_test_client.mail_store.get_mail(msg.mail_id)
self.assertIsNone(deleted_msg)
@defer.inlineCallbacks
def test_add_add_mail_twice(self):
- yield self.adaptor.initialize_store(self.soledad)
+ yield self.adaptor.initialize_store(self.app_test_client.soledad)
mail = load_mail_from_file('mbox00000000', enforceUniqueMessageId=True)
mail2 = load_mail_from_file('mbox00000000', enforceUniqueMessageId=True)
- yield self.mail_store.add_mailbox('INBOX')
+ yield self.app_test_client.mail_store.add_mailbox('INBOX')
- msg1 = yield self.mail_store.add_mail('INBOX', mail.as_string())
- msg2 = yield self.mail_store.add_mail('INBOX', mail2.as_string())
+ msg1 = yield self.app_test_client.mail_store.add_mail('INBOX', mail.as_string())
+ msg2 = yield self.app_test_client.mail_store.add_mail('INBOX', mail2.as_string())
self.assertIsNotNone(msg1.ident)
self.assertIsNotNone(msg2.ident)
@@ -139,10 +163,10 @@ class LeapMailStoreTest(SoledadTestBase):
@defer.inlineCallbacks
def test_get_mailbox_mail_ids(self):
mail = load_mail_from_file('mbox00000000')
- yield self.mail_store.add_mailbox('INBOX')
- mail = yield self.mail_store.add_mail('INBOX', mail.as_string())
+ yield self.app_test_client.mail_store.add_mailbox('INBOX')
+ mail = yield self.app_test_client.mail_store.add_mail('INBOX', mail.as_string())
- mails = yield self.mail_store.get_mailbox_mail_ids('INBOX')
+ mails = yield self.app_test_client.mail_store.get_mailbox_mail_ids('INBOX')
self.assertEqual(1, len(mails))
self.assertEqual(mail.mail_id, mails[0])
@@ -150,12 +174,12 @@ class LeapMailStoreTest(SoledadTestBase):
@defer.inlineCallbacks
def test_deleting_a_deleted_mail_doesnt_raise_errors(self):
mail = load_mail_from_file('mbox00000000')
- yield self.mail_store.add_mailbox('INBOX')
- mail = yield self.mail_store.add_mail('INBOX', mail.as_string())
+ yield self.app_test_client.mail_store.add_mailbox('INBOX')
+ mail = yield self.app_test_client.mail_store.add_mail('INBOX', mail.as_string())
- yield self.mail_store.delete_mail(mail.ident)
+ yield self.app_test_client.mail_store.delete_mail(mail.ident)
try:
- yield self.mail_store.delete_mail(mail.ident)
+ yield self.app_test_client.mail_store.delete_mail(mail.ident)
except Exception as e:
self.fail("Deleting a deleted mail should be ok, but raised an error")
raise e
diff --git a/service/test/integration/test_logout.py b/service/test/integration/test_logout.py
index da414126..e67fabab 100644
--- a/service/test/integration/test_logout.py
+++ b/service/test/integration/test_logout.py
@@ -15,29 +15,32 @@
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import json
+from mock import patch
from mockito import verify
from twisted.internet import defer
-from test.support.integration.multi_user_client import MultiUserClient
-from test.support.integration.soledad_test_base import SoledadTestBase
+from test.support.integration.soledad_test_base import MultiUserSoledadTestBase
-class MultiUserLogoutTest(MultiUserClient, SoledadTestBase):
+class MultiUserLogoutTest(MultiUserSoledadTestBase):
@defer.inlineCallbacks
def wait_for_session_user_id_to_finish(self):
- yield self.adaptor.initialize_store(self.soledad)
+ yield self.adaptor.initialize_store(self.app_test_client.soledad)
@defer.inlineCallbacks
def test_logout_deletes_services_stop_background_reactor_tasks_and_closes_soledad(self):
- response, login_request = yield self.login()
+ response, login_request = yield self.app_test_client.login()
yield response
yield self.wait_for_session_user_id_to_finish()
- response, request = self.post("/logout", json.dumps({'csrftoken': [login_request.getCookie('XSRF-TOKEN')]}),
- from_request=login_request, as_json=False)
+ response, request = self.app_test_client.post(
+ "/logout",
+ json.dumps({'csrftoken': [login_request.getCookie('XSRF-TOKEN')]}),
+ from_request=login_request,
+ as_json=False)
yield response
self.assertEqual(302, request.responseCode) # redirected
- verify(self.services).close()
+ verify(self.app_test_client.services).close()
diff --git a/service/test/integration/test_mark_as_read_unread.py b/service/test/integration/test_mark_as_read_unread.py
index 48879e4a..18c3ddc2 100644
--- a/service/test/integration/test_mark_as_read_unread.py
+++ b/service/test/integration/test_mark_as_read_unread.py
@@ -25,24 +25,24 @@ class MarkAsReadUnreadTest(SoledadTestBase):
@defer.inlineCallbacks
def test_mark_single_as_read(self):
input_mail = MailBuilder().build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
- mails = yield self.get_mails_by_tag('inbox')
+ mails = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertNotIn('read', mails[0].status)
- yield self.mark_many_as_read([mail.ident])
+ yield self.app_test_client.mark_many_as_read([mail.ident])
- mails = yield self.get_mails_by_tag('inbox')
+ mails = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertIn('read', mails[0].status)
@defer.inlineCallbacks
def test_mark_single_as_unread(self):
input_mail = MailBuilder().build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
- yield self.mark_many_as_read([mail.ident])
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
+ yield self.app_test_client.mark_many_as_read([mail.ident])
- yield self.mark_many_as_unread([mail.ident])
- result = (yield self.get_mails_by_tag('inbox'))[0]
+ yield self.app_test_client.mark_many_as_unread([mail.ident])
+ result = (yield self.app_test_client.get_mails_by_tag('inbox'))[0]
self.assertNotIn('read', result.status)
@@ -51,13 +51,13 @@ class MarkAsReadUnreadTest(SoledadTestBase):
input_mail = MailBuilder().with_status([Status.SEEN]).build_input_mail()
input_mail2 = MailBuilder().with_status([Status.SEEN]).build_input_mail()
- mail1 = yield self.add_mail_to_inbox(input_mail)
- mail2 = yield self.add_mail_to_inbox(input_mail2)
- yield self.mark_many_as_read([mail1.ident, mail2.ident])
+ mail1 = yield self.app_test_client.add_mail_to_inbox(input_mail)
+ mail2 = yield self.app_test_client.add_mail_to_inbox(input_mail2)
+ yield self.app_test_client.mark_many_as_read([mail1.ident, mail2.ident])
- yield self.mark_many_as_unread([mail1.ident, mail2.ident])
+ yield self.app_test_client.mark_many_as_unread([mail1.ident, mail2.ident])
- mails = yield self.get_mails_by_tag('inbox')
+ mails = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertNotIn('read', mails[0].status)
self.assertNotIn('read', mails[1].status)
@@ -67,17 +67,17 @@ class MarkAsReadUnreadTest(SoledadTestBase):
input_mail = MailBuilder().build_input_mail()
input_mail2 = MailBuilder().build_input_mail()
- yield self.add_mail_to_inbox(input_mail)
- yield self.add_mail_to_inbox(input_mail2)
+ yield self.app_test_client.add_mail_to_inbox(input_mail)
+ yield self.app_test_client.add_mail_to_inbox(input_mail2)
- mails = yield self.get_mails_by_tag('inbox')
+ mails = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertNotIn('read', mails[0].status)
self.assertNotIn('read', mails[1].status)
- yield self.mark_many_as_read([mails[0].ident, mails[1].ident])
+ yield self.app_test_client.mark_many_as_read([mails[0].ident, mails[1].ident])
- mails = yield self.get_mails_by_tag('inbox')
+ mails = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertIn('read', mails[0].status)
self.assertIn('read', mails[1].status)
@@ -87,20 +87,20 @@ class MarkAsReadUnreadTest(SoledadTestBase):
input_mail = MailBuilder().with_subject('first').build_input_mail()
input_mail2 = MailBuilder().with_subject('second').build_input_mail()
- yield self.add_mail_to_inbox(input_mail)
- mail2 = yield self.add_mail_to_inbox(input_mail2)
- yield self.mark_many_as_read([mail2.ident])
+ yield self.app_test_client.add_mail_to_inbox(input_mail)
+ mail2 = yield self.app_test_client.add_mail_to_inbox(input_mail2)
+ yield self.app_test_client.mark_many_as_read([mail2.ident])
- mails = yield self.get_mails_by_tag('inbox')
+ mails = yield self.app_test_client.get_mails_by_tag('inbox')
read_mails = filter(lambda x: 'read' in x.status, mails)
unread_mails = filter(lambda x: 'read' not in x.status, mails)
self.assertEquals(1, len(unread_mails))
self.assertEquals(1, len(read_mails))
- yield self.mark_many_as_read([mails[0].ident, mails[1].ident])
+ yield self.app_test_client.mark_many_as_read([mails[0].ident, mails[1].ident])
- mails = yield self.get_mails_by_tag('inbox')
+ mails = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertIn('read', mails[0].status)
self.assertIn('read', mails[1].status)
diff --git a/service/test/integration/test_multi_user_login.py b/service/test/integration/test_multi_user_login.py
index 307551d5..c1500031 100644
--- a/service/test/integration/test_multi_user_login.py
+++ b/service/test/integration/test_multi_user_login.py
@@ -13,18 +13,19 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
+from mock import patch
+
from twisted.internet import defer
from test.support.integration import load_mail_from_file
-from test.support.integration.multi_user_client import MultiUserClient
-from test.support.integration.soledad_test_base import SoledadTestBase
+from test.support.integration.soledad_test_base import MultiUserSoledadTestBase
-class MultiUserLoginTest(MultiUserClient, SoledadTestBase):
+class MultiUserLoginTest(MultiUserSoledadTestBase):
@defer.inlineCallbacks
def test_logged_out_users_should_receive_unauthorized(self):
- response, request = yield self.get("/mail", as_json=False)
+ response, request = yield self.app_test_client.get("/mail", as_json=False)
response_str = yield response
self.assertEqual(401, request.responseCode)
@@ -32,12 +33,12 @@ class MultiUserLoginTest(MultiUserClient, SoledadTestBase):
@defer.inlineCallbacks
def test_logged_in_users_sees_resources(self):
- response, login_request = yield self.login()
+ response, login_request = yield self.app_test_client.login()
yield response
mail = load_mail_from_file('mbox00000000')
mail_id = yield self._create_mail_in_soledad(mail)
expected_mail_dict = {'body': u'Dignissimos ducimus veritatis. Est tenetur consequatur quia occaecati. Vel sit sit voluptas.\n\nEarum distinctio eos. Accusantium qui sint ut quia assumenda. Facere dignissimos inventore autem sit amet. Pariatur voluptatem sint est.\n\nUt recusandae praesentium aspernatur. Exercitationem amet placeat deserunt quae consequatur eum. Unde doloremque suscipit quia.\n\n', 'header': {u'date': u'Tue, 21 Apr 2015 08:43:27 +0000 (UTC)', u'to': [u'carmel@murazikortiz.name'], u'x-tw-pixelated-tags': u'nite, macro, trash', u'from': u'darby.senger@zemlak.biz', u'subject': u'Itaque consequatur repellendus provident sunt quia.'}, 'ident': mail_id, 'status': [], 'tags': [], 'textPlainBody': u'Dignissimos ducimus veritatis. Est tenetur consequatur quia occaecati. Vel sit sit voluptas.\n\nEarum distinctio eos. Accusantium qui sint ut quia assumenda. Facere dignissimos inventore autem sit amet. Pariatur voluptatem sint est.\n\nUt recusandae praesentium aspernatur. Exercitationem amet placeat deserunt quae consequatur eum. Unde doloremque suscipit quia.\n\n', 'mailbox': u'inbox', 'attachments': [], 'security_casing': {'imprints': [{'state': 'no_signature_information'}], 'locks': []}}
- response, request = self.get("/mail/%s" % mail_id, from_request=login_request)
+ response, request = self.app_test_client.get("/mail/%s" % mail_id, from_request=login_request)
response = yield response
self.assertEqual(200, request.code)
@@ -46,7 +47,7 @@ class MultiUserLoginTest(MultiUserClient, SoledadTestBase):
@defer.inlineCallbacks
def test_wrong_credentials_cannot_access_resources(self):
- response, login_request = self.login('username', 'wrong_password')
+ response, login_request = self.app_test_client.login('username', 'wrong_password')
response_str = yield response
self.assertEqual(401, login_request.responseCode)
self.assertIn('Invalid credentials', login_request.written)
diff --git a/service/test/integration/test_retrieve_attachment.py b/service/test/integration/test_retrieve_attachment.py
index eaf1d36c..b46d40d5 100644
--- a/service/test/integration/test_retrieve_attachment.py
+++ b/service/test/integration/test_retrieve_attachment.py
@@ -13,9 +13,7 @@
#
# 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 base64
import json
-from email import encoders
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@@ -30,13 +28,13 @@ class RetrieveAttachmentTest(SoledadTestBase):
@defer.inlineCallbacks
def test_attachment_content_is_retrieved(self):
attachment_id, input_mail = self._create_mail_with_attachment()
- yield self.mail_store.add_mail('INBOX', input_mail.as_string())
+ yield self.app_test_client.mail_store.add_mail('INBOX', input_mail.as_string())
requested_filename = "file name with space"
expected_content_type = 'text/plain'
expected_content_disposition = 'attachment; filename="file name with space"'
- attachment, req = yield self.get_attachment(attachment_id, 'base64', filename=requested_filename, content_type=expected_content_type)
+ attachment, req = yield self.app_test_client.get_attachment(attachment_id, 'base64', filename=requested_filename, content_type=expected_content_type)
self.assertEqual(200, req.code)
self.assertEquals('pretend to be binary attachment data', attachment)
@@ -46,14 +44,16 @@ class RetrieveAttachmentTest(SoledadTestBase):
@defer.inlineCallbacks
def test_should_retrieve_attachment_even_if_xsrf_token_not_passed(self):
attachment_id, input_mail = self._create_mail_with_attachment()
- yield self.mail_store.add_mail('INBOX', input_mail.as_string())
+ yield self.app_test_client.mail_store.add_mail('INBOX', input_mail.as_string())
requested_filename = "file name with space"
expected_content_type = 'text/plain'
expected_content_disposition = 'attachment; filename="file name with space"'
- attachment, req = yield self.get_attachment(attachment_id, 'base64', filename=requested_filename,
- content_type=expected_content_type, ajax=False, csrf='mismatched token')
+ attachment, req = yield self.app_test_client.get_attachment(
+ attachment_id, 'base64', filename=requested_filename,
+ content_type=expected_content_type, ajax=False,
+ csrf='mismatched token')
self.assertEqual(200, req.code)
self.assertEquals('pretend to be binary attachment data', attachment)
@@ -72,7 +72,7 @@ class RetrieveAttachmentTest(SoledadTestBase):
@defer.inlineCallbacks
def test_attachment_error_returned_if_id_not_found(self):
- attachment, req = yield self.get_attachment('invalid attachment id', 'base64')
+ attachment, req = yield self.app_test_client.get_attachment('invalid attachment id', 'base64')
self.assertEqual(404, req.code)
self.assertIsNone(attachment)
@@ -86,7 +86,7 @@ class RetrieveAttachmentTest(SoledadTestBase):
datagen, headers = multipart_encode([file])
post_data = "".join(datagen)
- _, req = yield self.post_attachment(post_data, headers)
+ _, req = yield self.app_test_client.post_attachment(post_data, headers)
self.assertEqual(201, req.code)
self.assertEqual('/attachment/B5B4ED80AC3B894523D72E375DACAA2FC6606C18EDF680FE95903086C8B5E14A', req.responseHeaders.getRawHeaders('location')[0])
diff --git a/service/test/integration/test_search.py b/service/test/integration/test_search.py
index aafcb4fc..c36e29aa 100644
--- a/service/test/integration/test_search.py
+++ b/service/test/integration/test_search.py
@@ -23,10 +23,10 @@ class SearchTest(SoledadTestBase):
@defer.inlineCallbacks
def test_that_tags_returns_all_tags(self):
input_mail = MailBuilder().build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
- yield self.mail_service.update_tags(mail.ident, ['important'])
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
+ yield self.app_test_client.mail_service.update_tags(mail.ident, ['important'])
- all_tags = yield self.get_tags()
+ all_tags = yield self.app_test_client.get_tags()
all_tag_names = [t['name'] for t in all_tags]
self.assertTrue('inbox' in all_tag_names)
@@ -38,10 +38,10 @@ class SearchTest(SoledadTestBase):
@defer.inlineCallbacks
def test_that_tags_are_filtered_by_query(self):
input_mail = MailBuilder().build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
- yield self.mail_service.update_tags(mail.ident, ['ateu', 'catoa', 'luat', 'zuado'])
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
+ yield self.app_test_client.mail_service.update_tags(mail.ident, ['ateu', 'catoa', 'luat', 'zuado'])
- all_tags = yield self.get_tags(q=["at"], skipDefaultTags=["true"])
+ all_tags = yield self.app_test_client.get_tags(q=["at"], skipDefaultTags=["true"])
all_tag_names = [t['name'] for t in all_tags]
self.assertEqual(3, len(all_tag_names))
@@ -52,20 +52,20 @@ class SearchTest(SoledadTestBase):
@defer.inlineCallbacks
def test_tags_with_multiple_words_are_searchable(self):
input_mail = MailBuilder().build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
- yield self.mail_service.update_tags(mail.ident, ['one tag four words'])
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
+ yield self.app_test_client.mail_service.update_tags(mail.ident, ['one tag four words'])
- first_page = yield self.get_mails_by_tag('"one tag four words"', page=1, window=1)
+ first_page = yield self.app_test_client.get_mails_by_tag('"one tag four words"', page=1, window=1)
self.assertEqual(len(first_page), 1)
@defer.inlineCallbacks
def test_that_default_tags_are_ignorable(self):
input_mail = MailBuilder().build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
- yield self.mail_service.update_tags(mail.ident, ['sometag'])
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
+ yield self.app_test_client.mail_service.update_tags(mail.ident, ['sometag'])
- all_tags = yield self.get_tags(skipDefaultTags=["true"])
+ all_tags = yield self.app_test_client.get_tags(skipDefaultTags=["true"])
all_tag_names = [t['name'] for t in all_tags]
self.assertEqual(1, len(all_tag_names))
@@ -73,12 +73,12 @@ class SearchTest(SoledadTestBase):
@defer.inlineCallbacks
def test_tags_count(self):
- yield self.add_multiple_to_mailbox(num=10, mailbox='inbox', flags=['\\Recent'])
- yield self.add_multiple_to_mailbox(num=5, mailbox='inbox', flags=['\\Seen'])
- yield self.add_multiple_to_mailbox(num=3, mailbox='inbox', flags=['\\Recent'], tags=['important', 'later'])
- yield self.add_multiple_to_mailbox(num=1, mailbox='inbox', flags=['\\Seen'], tags=['important'])
+ yield self.app_test_client.add_multiple_to_mailbox(num=10, mailbox='inbox', flags=['\\Recent'])
+ yield self.app_test_client.add_multiple_to_mailbox(num=5, mailbox='inbox', flags=['\\Seen'])
+ yield self.app_test_client.add_multiple_to_mailbox(num=3, mailbox='inbox', flags=['\\Recent'], tags=['important', 'later'])
+ yield self.app_test_client.add_multiple_to_mailbox(num=1, mailbox='inbox', flags=['\\Seen'], tags=['important'])
- tags_count = yield self.get_tags()
+ tags_count = yield self.app_test_client.get_tags()
self.assertEqual(self.get_count(tags_count, 'inbox')['total'], 19)
self.assertEqual(self.get_count(tags_count, 'inbox')['read'], 6)
@@ -89,10 +89,10 @@ class SearchTest(SoledadTestBase):
def test_search_mails_different_window(self):
input_mail = MailBuilder().build_input_mail()
input_mail2 = MailBuilder().build_input_mail()
- yield self.add_mail_to_inbox(input_mail)
- yield self.add_mail_to_inbox(input_mail2)
+ yield self.app_test_client.add_mail_to_inbox(input_mail)
+ yield self.app_test_client.add_mail_to_inbox(input_mail2)
- first_page = yield self.get_mails_by_tag('inbox', page=1, window=1)
+ first_page = yield self.app_test_client.get_mails_by_tag('inbox', page=1, window=1)
self.assertEqual(len(first_page), 1)
@@ -100,11 +100,11 @@ class SearchTest(SoledadTestBase):
def test_search_mails_with_multiple_pages(self):
input_mail = MailBuilder().build_input_mail()
input_mail2 = MailBuilder().build_input_mail()
- mail1 = yield self.add_mail_to_inbox(input_mail)
- mail2 = yield self.add_mail_to_inbox(input_mail2)
+ mail1 = yield self.app_test_client.add_mail_to_inbox(input_mail)
+ mail2 = yield self.app_test_client.add_mail_to_inbox(input_mail2)
- first_page = yield self.get_mails_by_tag('inbox', page=1, window=1)
- second_page = yield self.get_mails_by_tag('inbox', page=2, window=1)
+ first_page = yield self.app_test_client.get_mails_by_tag('inbox', page=1, window=1)
+ second_page = yield self.app_test_client.get_mails_by_tag('inbox', page=2, window=1)
idents = [mail1.ident, mail2.ident]
@@ -114,8 +114,8 @@ class SearchTest(SoledadTestBase):
@defer.inlineCallbacks
def test_page_zero_fetches_first_page(self):
input_mail = MailBuilder().build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
- page = yield self.get_mails_by_tag('inbox', page=0, window=1)
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
+ page = yield self.app_test_client.get_mails_by_tag('inbox', page=0, window=1)
self.assertEqual(page[0].ident, mail.ident)
def get_count(self, tags_count, mailbox):
@@ -128,10 +128,10 @@ class SearchTest(SoledadTestBase):
input_mail = MailBuilder().with_date('2014-10-15T15:15').build_input_mail()
input_mail2 = MailBuilder().with_date('2014-10-15T15:16').build_input_mail()
- mail1 = yield self.add_mail_to_inbox(input_mail)
- mail2 = yield self.add_mail_to_inbox(input_mail2)
+ mail1 = yield self.app_test_client.add_mail_to_inbox(input_mail)
+ mail2 = yield self.app_test_client.add_mail_to_inbox(input_mail2)
- results = yield self.get_mails_by_tag('inbox')
+ results = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertEqual(results[0].ident, mail2.ident)
self.assertEqual(results[1].ident, mail1.ident)
@@ -140,8 +140,8 @@ class SearchTest(SoledadTestBase):
body = u'bl\xe1'
input_mail = MailBuilder().with_body(body.encode('utf-8')).build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
- results = yield self.search(body)
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
+ results = yield self.app_test_client.search(body)
self.assertGreater(len(results), 0, 'No results returned from search')
self.assertEquals(results[0].ident, mail.ident)
diff --git a/service/test/integration/test_tags.py b/service/test/integration/test_tags.py
index 0e0fe66c..555a7382 100644
--- a/service/test/integration/test_tags.py
+++ b/service/test/integration/test_tags.py
@@ -29,30 +29,30 @@ class TagsTest(SoledadTestBase):
@defer.inlineCallbacks
def test_add_tag_to_an_inbox_mail_and_query(self):
input_mail = MailBuilder().with_subject('Mail with tags').build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
- yield self.post_tags(mail.ident, self._tags_json(['IMPORTANT']))
+ yield self.app_test_client.post_tags(mail.ident, self._tags_json(['IMPORTANT']))
- mails = yield self.get_mails_by_tag('inbox')
+ mails = yield self.app_test_client.get_mails_by_tag('inbox')
self.assertEquals({'IMPORTANT'}, set(mails[0].tags))
- mails = yield self.get_mails_by_tag('IMPORTANT')
+ mails = yield self.app_test_client.get_mails_by_tag('IMPORTANT')
self.assertEquals('Mail with tags', mails[0].subject)
@defer.inlineCallbacks
def test_use_old_casing_when_same_tag_with_different_casing_is_posted(self):
input_mail = MailBuilder().with_subject('Mail with tags').build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
- yield self.post_tags(mail.ident, self._tags_json(['ImPoRtAnT']))
- mails = yield self.get_mails_by_tag('ImPoRtAnT')
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
+ yield self.app_test_client.post_tags(mail.ident, self._tags_json(['ImPoRtAnT']))
+ mails = yield self.app_test_client.get_mails_by_tag('ImPoRtAnT')
self.assertEquals({'ImPoRtAnT'}, set(mails[0].tags))
another_input_mail = MailBuilder().with_subject('Mail with tags').build_input_mail()
- another_mail = yield self.add_mail_to_inbox(another_input_mail)
- yield self.post_tags(another_mail.ident, self._tags_json(['IMPORTANT']))
- mails = yield self.get_mails_by_tag('IMPORTANT')
+ another_mail = yield self.app_test_client.add_mail_to_inbox(another_input_mail)
+ yield self.app_test_client.post_tags(another_mail.ident, self._tags_json(['IMPORTANT']))
+ mails = yield self.app_test_client.get_mails_by_tag('IMPORTANT')
self.assertEquals(0, len(mails))
- mails = yield self.get_mails_by_tag('ImPoRtAnT')
+ mails = yield self.app_test_client.get_mails_by_tag('ImPoRtAnT')
self.assertEquals(2, len(mails))
self.assertEquals({'ImPoRtAnT'}, set(mails[0].tags))
self.assertEquals({'ImPoRtAnT'}, set(mails[1].tags))
@@ -60,38 +60,38 @@ class TagsTest(SoledadTestBase):
@defer.inlineCallbacks
def test_tags_are_case_sensitive(self):
input_mail = MailBuilder().with_subject('Mail with tags').build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
- yield self.post_tags(mail.ident, self._tags_json(['ImPoRtAnT']))
+ yield self.app_test_client.post_tags(mail.ident, self._tags_json(['ImPoRtAnT']))
- mails = yield self.get_mails_by_tag('important')
+ mails = yield self.app_test_client.get_mails_by_tag('important')
self.assertEquals(0, len(mails))
- mails = yield self.get_mails_by_tag('IMPORTANT')
+ mails = yield self.app_test_client.get_mails_by_tag('IMPORTANT')
self.assertEquals(0, len(mails))
- mails = yield self.get_mails_by_tag('ImPoRtAnT')
+ mails = yield self.app_test_client.get_mails_by_tag('ImPoRtAnT')
self.assertEquals({'ImPoRtAnT'}, set(mails[0].tags))
@defer.inlineCallbacks
def test_empty_tags_are_not_allowed(self):
input_mail = MailBuilder().with_subject('Mail with tags').build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
- yield self.post_tags(mail.ident, self._tags_json(['tag1', ' ']))
+ yield self.app_test_client.post_tags(mail.ident, self._tags_json(['tag1', ' ']))
- mail = yield self.get_mail(mail.ident)
+ mail = yield self.app_test_client.get_mail(mail.ident)
self.assertEquals(mail['tags'], ['tag1'])
@defer.inlineCallbacks
def test_addition_of_reserved_tags_is_not_allowed(self):
input_mail = MailBuilder().with_subject('Mail with tags').build_input_mail()
- mail = yield self.add_mail_to_inbox(input_mail)
+ mail = yield self.app_test_client.add_mail_to_inbox(input_mail)
for tag in SPECIAL_TAGS:
- response = yield self.post_tags(mail.ident, self._tags_json([tag.name.upper()]))
+ response = yield self.app_test_client.post_tags(mail.ident, self._tags_json([tag.name.upper()]))
self.assertEquals("None of the following words can be used as tags: %s" % tag.name, response)
- mail = yield self.mail_store.get_mail(mail.ident)
+ mail = yield self.app_test_client.mail_store.get_mail(mail.ident)
self.assertNotIn('drafts', mail.tags)
diff --git a/service/test/integration/test_users_count.py b/service/test/integration/test_users_count.py
index d06ffd39..a03adacf 100644
--- a/service/test/integration/test_users_count.py
+++ b/service/test/integration/test_users_count.py
@@ -19,29 +19,31 @@ from mockito import verify
from mockito import when
from twisted.internet import defer
-from test.support.integration.multi_user_client import MultiUserClient
-from test.support.integration.soledad_test_base import SoledadTestBase
+from test.support.integration.soledad_test_base import MultiUserSoledadTestBase
-class UsersResourceTest(MultiUserClient, SoledadTestBase):
+class UsersResourceTest(MultiUserSoledadTestBase):
@defer.inlineCallbacks
def wait_for_session_user_id_to_finish(self):
- yield self.adaptor.initialize_store(self.soledad)
+ yield self.adaptor.initialize_store(self.app_test_client.soledad)
@defer.inlineCallbacks
def test_online_users_count_uses_leap_auth_privileges(self):
- response, login_request = yield self.login()
+ response, login_request = yield self.app_test_client.login()
yield response
yield self.wait_for_session_user_id_to_finish()
- when(self.user_auth).is_admin().thenReturn(True)
- response, request = self.get("/users", json.dumps({'csrftoken': [login_request.getCookie('XSRF-TOKEN')]}),
- from_request=login_request, as_json=False)
+ when(self.app_test_client.user_auth).is_admin().thenReturn(True)
+ response, request = self.app_test_client.get(
+ "/users",
+ json.dumps({'csrftoken': [login_request.getCookie('XSRF-TOKEN')]}),
+ from_request=login_request,
+ as_json=False)
yield response
self.assertEqual(200, request.code) # redirected
self.assertEqual('{"count": 1}', request.getWrittenData()) # redirected
- verify(self.user_auth).is_admin()
+ verify(self.app_test_client.user_auth).is_admin()
diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py
index 02a44da1..13cd9f94 100644
--- a/service/test/support/integration/app_test_client.py
+++ b/service/test/support/integration/app_test_client.py
@@ -155,6 +155,7 @@ class StubServicesFactory(ServicesFactory):
yield defer.succeed(None)
+# TODO: some methods are used by 1 test class only, maybe push them down there
class AppTestClient(object):
INDEX_KEY = '\xde3?\x87\xff\xd9\xd3\x14\xf0\xa7>\x1f%C{\x16.\\\xae\x8c\x13\xa7\xfb\x04\xd4]+\x8d_\xed\xd1\x8d\x0bI' \
'\x8a\x0e\xa4tm\xab\xbf\xb4\xa5\x99\x00d\xd5w\x9f\x18\xbc\x1d\xd4_W\xd2\xb6\xe8H\x83\x1b\xd8\x9d\xad'
@@ -273,6 +274,7 @@ class AppTestClient(object):
def account_for(self, username):
return self.accounts[username]
+ # TODO: remove
def add_mail_to_user_inbox(self, input_mail, username):
return self.account_for(username).mail_store.add_mail('INBOX', input_mail.raw)
@@ -301,6 +303,7 @@ class AppTestClient(object):
mail_sender.sendmail.side_effect = lambda mail: succeed(mail)
return mail_sender
+ # TODO: remove
def _generate_soledad_test_folder_name(self, soledad_test_folder='/tmp/soledad-test/test'):
return os.path.join(soledad_test_folder, str(uuid.uuid4()))
@@ -318,6 +321,7 @@ class AppTestClient(object):
res = yield res
defer.returnValue([ResponseMail(m) for m in res['mails']])
+ # TODO: remove
@defer.inlineCallbacks
def get_mails_by_mailbox_name(self, mbox_name):
mail_ids = yield self.mail_store.get_mailbox_mail_ids(mbox_name)
@@ -357,6 +361,7 @@ class AppTestClient(object):
res, req = self.get('/mail/%s' % mail_ident)
return res
+ # TODO: remove
def delete_mail(self, mail_ident):
res, req = self.delete("/mail/%s" % mail_ident)
return res
diff --git a/service/test/support/integration/multi_user_client.py b/service/test/support/integration/multi_user_client.py
index 2530db46..420ff54b 100644
--- a/service/test/support/integration/multi_user_client.py
+++ b/service/test/support/integration/multi_user_client.py
@@ -13,6 +13,7 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
+from mock import patch
from mockito import mock, when, any as ANY
from twisted.internet import defer
@@ -25,8 +26,8 @@ import pixelated.config.services
from pixelated.resources.root_resource import RootResource
from test.support.integration import AppTestClient
from test.support.integration.app_test_client import AppTestAccount, StubSRPChecker
-import test.support.mockito
from test.support.test_helper import request_mock
+from test.support.mockito import AnswerSelector
class MultiUserClient(AppTestClient):
@@ -63,7 +64,8 @@ class MultiUserClient(AppTestClient):
self.user_auth = session
when(LeapSessionFactory).create(username, password, session).thenReturn(leap_session)
- when(leap_session).initial_sync().thenAnswer(lambda: defer.succeed(None))
+ with patch('mockito.invocation.AnswerSelector', AnswerSelector):
+ when(leap_session).initial_sync().thenAnswer(lambda: defer.succeed(None))
when(pixelated.config.services).Services(ANY()).thenReturn(self.services)
request = request_mock(path='/login', method="POST", body={'username': username, 'password': password})
diff --git a/service/test/support/integration/soledad_test_base.py b/service/test/support/integration/soledad_test_base.py
index e3e582d2..0ab07490 100644
--- a/service/test/support/integration/soledad_test_base.py
+++ b/service/test/support/integration/soledad_test_base.py
@@ -18,12 +18,13 @@ from leap.mail.adaptors.soledad import SoledadMailAdaptor
from leap.mail.mail import Message
from twisted.internet import defer
from twisted.trial import unittest
-from pixelated.adapter.mailstore import LeapMailStore
from test.support.integration.app_test_client import AppTestClient
+from test.support.integration.multi_user_client import MultiUserClient
from leap.common.events.flags import set_events_enabled
-class SoledadTestBase(unittest.TestCase, AppTestClient):
+class SoledadTestBase(unittest.TestCase):
+ Client = AppTestClient
# these are so long because our CI is so slow at the moment.
DEFERRED_TIMEOUT = 120
DEFERRED_TIMEOUT_LONG = 300
@@ -34,18 +35,24 @@ class SoledadTestBase(unittest.TestCase, AppTestClient):
super(SoledadTestBase, self).setUp()
self.adaptor = SoledadMailAdaptor()
self.mbox_uuid = str(uuid4())
- yield self.start_client()
+ yield self.app_test_client.start_client()
def tearDown(self):
set_events_enabled(True)
- self.cleanup()
+ self.app_test_client.cleanup()
+
+ @property
+ def app_test_client(self):
+ if not hasattr(self, '_app_test_client'):
+ self._app_test_client = self.Client()
+ return self._app_test_client
@defer.inlineCallbacks
def _create_mail_in_soledad(self, mail):
- yield self.adaptor.initialize_store(self.soledad)
- mbox = yield self.adaptor.get_or_create_mbox(self.soledad, 'INBOX')
+ yield self.adaptor.initialize_store(self.app_test_client.soledad)
+ mbox = yield self.adaptor.get_or_create_mbox(self.app_test_client.soledad, 'INBOX')
message = self._convert_mail_to_leap_message(mail, mbox.uuid)
- yield self.adaptor.create_msg(self.soledad, message)
+ yield self.adaptor.create_msg(self.app_test_client.soledad, message)
defer.returnValue(message.get_wrapper().mdoc.doc_id)
@@ -53,3 +60,7 @@ class SoledadTestBase(unittest.TestCase, AppTestClient):
message = self.adaptor.get_msg_from_string(Message, mail.as_string())
message.get_wrapper().set_mbox_uuid(mbox_uuid)
return message
+
+
+class MultiUserSoledadTestBase(SoledadTestBase):
+ Client = MultiUserClient
diff --git a/service/test/support/mockito/__init__.py b/service/test/support/mockito/__init__.py
index c8ffc55e..8589fac0 100644
--- a/service/test/support/mockito/__init__.py
+++ b/service/test/support/mockito/__init__.py
@@ -13,7 +13,7 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
-from mockito.invocation import AnswerSelector, CompositeAnswer
+from mockito.invocation import AnswerSelector as OriginalAnswerSelector, CompositeAnswer
class FunctionReturn(object):
@@ -27,14 +27,14 @@ class FunctionReturn(object):
return self.function_answer()
-def thenAnswer(self, answer_function):
- """mockito does not support the thenAnswer style. This method monkey patches it into the library"""
- if not self.answer:
- self.answer = CompositeAnswer(FunctionReturn(answer_function))
- self.invocation.stub_with(self.answer)
- else:
- self.answer.add(FunctionReturn(answer_function))
+class AnswerSelector(OriginalAnswerSelector):
- return self
+ def thenAnswer(self, answer_function):
+ """mockito does not support the thenAnswer style. This method monkey patches it into the library"""
+ if not self.answer:
+ self.answer = CompositeAnswer(FunctionReturn(answer_function))
+ self.invocation.stub_with(self.answer)
+ else:
+ self.answer.add(FunctionReturn(answer_function))
-AnswerSelector.thenAnswer = thenAnswer
+ return self
diff --git a/service/test/unit/adapter/mailstore/test_leap_attachment_store.py b/service/test/unit/adapter/mailstore/test_leap_attachment_store.py
index 4e9b56b1..f442b687 100644
--- a/service/test/unit/adapter/mailstore/test_leap_attachment_store.py
+++ b/service/test/unit/adapter/mailstore/test_leap_attachment_store.py
@@ -20,13 +20,14 @@ import u1db
from leap.mail.adaptors.soledad_indexes import MAIL_INDEXES
from leap.soledad.common.document import SoledadDocument
+from mock import patch
from mockito import mock, when, verify
-import test.support.mockito
from twisted.internet import defer
from twisted.trial.unittest import TestCase
from leap.mail.adaptors.soledad import SoledadMailAdaptor, MailboxWrapper, ContentDocWrapper
from pixelated.adapter.mailstore.leap_attachment_store import LeapAttachmentStore
+from test.support.mockito import AnswerSelector
class TestLeapAttachmentStore(TestCase):
@@ -37,7 +38,8 @@ class TestLeapAttachmentStore(TestCase):
self.mbox_uuid_by_name = {}
self.mbox_soledad_docs = []
- when(self.soledad).get_from_index('by-type', 'mbox').thenAnswer(lambda: defer.succeed(self.mbox_soledad_docs))
+ with patch('mockito.invocation.AnswerSelector', AnswerSelector):
+ when(self.soledad).get_from_index('by-type', 'mbox').thenAnswer(lambda: defer.succeed(self.mbox_soledad_docs))
self._mock_get_mailbox('INBOX')
@defer.inlineCallbacks
@@ -134,7 +136,7 @@ class TestLeapAttachmentStore(TestCase):
def _mock_get_soledad_doc(self, doc_id, doc):
soledad_doc = SoledadDocument(doc_id, json=json.dumps(doc.serialize()))
- # when(self.soledad).get_doc(doc_id).thenReturn(defer.succeed(soledad_doc))
- when(self.soledad).get_doc(doc_id).thenAnswer(lambda: defer.succeed(soledad_doc))
+ with patch('mockito.invocation.AnswerSelector', AnswerSelector):
+ when(self.soledad).get_doc(doc_id).thenAnswer(lambda: defer.succeed(soledad_doc))
self.doc_by_id[doc_id] = soledad_doc
diff --git a/service/test/unit/adapter/mailstore/test_leap_mailstore.py b/service/test/unit/adapter/mailstore/test_leap_mailstore.py
index bde4f59b..62c8ac7a 100644
--- a/service/test/unit/adapter/mailstore/test_leap_mailstore.py
+++ b/service/test/unit/adapter/mailstore/test_leap_mailstore.py
@@ -30,14 +30,15 @@ from twisted.internet.defer import FirstError
from twisted.trial.unittest import TestCase
from leap.mail import constants
from twisted.internet import defer
+from mock import patch
from mockito import mock, when, verify, any as ANY
-import test.support.mockito
from leap.mail.adaptors.soledad import SoledadMailAdaptor, MailboxWrapper, ContentDocWrapper
import pkg_resources
from leap.mail.mail import Message
from pixelated.adapter.mailstore import underscore_uuid
from pixelated.adapter.mailstore.leap_mailstore import LeapMailStore, LeapMail
+from test.support.mockito import AnswerSelector
class TestLeapMailStore(TestCase):
@@ -48,12 +49,14 @@ class TestLeapMailStore(TestCase):
self.mbox_uuid_by_name = {}
self.mbox_soledad_docs = []
- when(self.soledad).get_from_index('by-type', 'mbox').thenAnswer(lambda: defer.succeed(self.mbox_soledad_docs))
+ with patch('mockito.invocation.AnswerSelector', AnswerSelector):
+ when(self.soledad).get_from_index('by-type', 'mbox').thenAnswer(lambda: defer.succeed(self.mbox_soledad_docs))
self._mock_get_mailbox('INBOX')
@defer.inlineCallbacks
def test_get_mail_not_exist(self):
- when(self.soledad).get_doc(ANY()).thenAnswer(lambda: defer.succeed(None))
+ with patch('mockito.invocation.AnswerSelector', AnswerSelector):
+ when(self.soledad).get_doc(ANY()).thenAnswer(lambda: defer.succeed(None))
store = LeapMailStore(self.soledad)
mail = yield store.get_mail(_format_mdoc_id(uuid4(), 1))
@@ -171,8 +174,9 @@ class TestLeapMailStore(TestCase):
when(self.soledad).list_indexes().thenReturn(defer.succeed(MAIL_INDEXES)).thenReturn(defer.succeed(MAIL_INDEXES))
when(self.soledad).get_from_index('by-type-and-mbox', 'mbox', 'TEST').thenReturn(defer.succeed([]))
self._mock_create_soledad_doc(self.mbox_uuid, MailboxWrapper(mbox='TEST'))
- when(self.soledad).get_doc(self.mbox_uuid).thenAnswer(lambda: defer.succeed(self.doc_by_id[self.mbox_uuid]))
- when(self.soledad).put_doc(ANY()).thenAnswer(lambda: defer.succeed(None))
+ with patch('mockito.invocation.AnswerSelector', AnswerSelector):
+ when(self.soledad).get_doc(self.mbox_uuid).thenAnswer(lambda: defer.succeed(self.doc_by_id[self.mbox_uuid]))
+ when(self.soledad).put_doc(ANY()).thenAnswer(lambda: defer.succeed(None))
store = LeapMailStore(self.soledad)
mbox = yield store.add_mailbox('TEST')
@@ -388,7 +392,8 @@ class TestLeapMailStore(TestCase):
def test_all_mail_graceful_error_handling(self):
mail_id, fdoc_id = self._add_mail_fixture_to_soledad_from_file('mbox00000000')
when(self.soledad).get_from_index('by-type', 'meta').thenReturn(defer.succeed([self.doc_by_id[mail_id]]))
- when(self.soledad).get_doc(self.doc_by_id[mail_id].content['cdocs'][0]).thenAnswer(lambda: defer.fail(Exception('fail loading attachment')))
+ with patch('mockito.invocation.AnswerSelector', AnswerSelector):
+ when(self.soledad).get_doc(self.doc_by_id[mail_id].content['cdocs'][0]).thenAnswer(lambda: defer.fail(Exception('fail loading attachment')))
store = LeapMailStore(self.soledad)
mails = yield store.all_mails(gracefully_ignore_errors=True)
@@ -476,8 +481,8 @@ class TestLeapMailStore(TestCase):
def _mock_get_soledad_doc(self, doc_id, doc):
soledad_doc = SoledadDocument(doc_id, json=json.dumps(doc.serialize()))
- # when(self.soledad).get_doc(doc_id).thenReturn(defer.succeed(soledad_doc))
- when(self.soledad).get_doc(doc_id).thenAnswer(lambda: defer.succeed(soledad_doc))
+ with patch('mockito.invocation.AnswerSelector', AnswerSelector):
+ when(self.soledad).get_doc(doc_id).thenAnswer(lambda: defer.succeed(soledad_doc))
self.doc_by_id[doc_id] = soledad_doc
diff --git a/service/test/unit/resources/test_login_resource.py b/service/test/unit/resources/test_login_resource.py
index 6383e25c..0ff9ec91 100644
--- a/service/test/unit/resources/test_login_resource.py
+++ b/service/test/unit/resources/test_login_resource.py
@@ -1,7 +1,5 @@
import os
-import test.support.mockito
-
from leap.bonafide._srp import SRPAuthError
from mock import patch
from mockito import mock, when, any as ANY, verify, verifyZeroInteractions, verifyNoMoreInteractions
@@ -13,6 +11,7 @@ from pixelated.config.sessions import LeapSession
from pixelated.resources.login_resource import LoginResource
from pixelated.resources.login_resource import parse_accept_language
from test.unit.resources import DummySite
+from test.support.mockito import AnswerSelector
class TestParseAcceptLanguage(unittest.TestCase):
@@ -194,7 +193,8 @@ class TestLoginPOST(unittest.TestCase):
def test_login_responds_interstitial_and_add_corresponding_session_to_services_factory(self):
irrelevant = None
when(self.portal).login(ANY(), None, IResource).thenReturn((irrelevant, self.leap_session, irrelevant))
- when(self.services_factory).create_services_from(self.leap_session).thenAnswer(self.mock_user_has_services_setup)
+ with patch('mockito.invocation.AnswerSelector', AnswerSelector):
+ when(self.services_factory).create_services_from(self.leap_session).thenAnswer(self.mock_user_has_services_setup)
d = self.web.get(self.request)
diff --git a/service/test/unit/resources/test_users_resource.py b/service/test/unit/resources/test_users_resource.py
index 417bbcc9..4ca578ae 100644
--- a/service/test/unit/resources/test_users_resource.py
+++ b/service/test/unit/resources/test_users_resource.py
@@ -1,5 +1,3 @@
-import test.support.mockito
-
from mockito import mock, when, verify
from twisted.trial import unittest
from twisted.web.test.requesthelper import DummyRequest