diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-10-09 12:03:31 +0200 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-10-09 12:03:38 +0200 |
commit | 0bad14f4b0e6dd5128660d94a436463cbe7dc720 (patch) | |
tree | 1c6170b1e29a09360378253da3fa3aeca9433641 /service | |
parent | e605929f9be56f01795fdc904d98cbe3f91984e3 (diff) |
Changing tests folder structure
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/adapter/soledad_querier.py | 4 | ||||
-rw-r--r-- | service/test/integration/__init__.py | 15 | ||||
-rw-r--r-- | service/test/integration/delete_mail_test.py (renamed from service/integration/delete_mail_test.py) | 2 | ||||
-rw-r--r-- | service/test/integration/drafts_test.py (renamed from service/integration/drafts_test.py) | 2 | ||||
-rw-r--r-- | service/test/integration/mark_as_read_test.py (renamed from service/integration/mark_as_read_test.py) | 2 | ||||
-rw-r--r-- | service/test/integration/tags_test.py (renamed from service/integration/tags_test.py) | 2 | ||||
-rw-r--r-- | service/test/support/__init__.py | 15 | ||||
-rw-r--r-- | service/test/support/integration_helper.py (renamed from service/integration/__init__.py) | 19 | ||||
-rw-r--r-- | service/test/support/test_helper.py (renamed from service/test/adapter/test_helper.py) | 0 | ||||
-rw-r--r-- | service/test/unit/__init__.py | 15 | ||||
-rw-r--r-- | service/test/unit/adapter/__init__.py (renamed from service/test/adapter/__init__.py) | 0 | ||||
-rw-r--r-- | service/test/unit/adapter/mail_service_test.py (renamed from service/test/adapter/mail_service_test.py) | 0 | ||||
-rw-r--r-- | service/test/unit/adapter/pixelated_mail_sender_test.py (renamed from service/test/adapter/pixelated_mail_sender_test.py) | 3 | ||||
-rw-r--r-- | service/test/unit/adapter/pixelated_mail_test.py (renamed from service/test/adapter/pixelated_mail_test.py) | 4 | ||||
-rw-r--r-- | service/test/unit/adapter/pixelated_mailbox_test.py (renamed from service/test/adapter/pixelated_mailbox_test.py) | 2 | ||||
-rw-r--r-- | service/test/unit/adapter/pixelated_mailboxes_test.py (renamed from service/test/adapter/pixelated_mailboxes_test.py) | 5 | ||||
-rw-r--r-- | service/test/unit/adapter/tag_index_test.py (renamed from service/test/adapter/tag_index_test.py) | 0 | ||||
-rw-r--r-- | service/test/unit/adapter/test_status.py (renamed from service/test/adapter/test_status.py) | 1 | ||||
-rw-r--r-- | service/test/unit/adapter/test_tag.py (renamed from service/test/adapter/test_tag.py) | 0 | ||||
-rw-r--r-- | service/test/unit/adapter/test_tag_service.py (renamed from service/test/adapter/test_tag_service.py) | 3 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/__init__.py (renamed from service/test/bitmask_libraries/__init__.py) | 0 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/abstract_leap_test.py (renamed from service/test/bitmask_libraries/abstract_leap_test.py) | 0 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/leap_srp_test.py (renamed from service/test/bitmask_libraries/leap_srp_test.py) | 0 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/nicknym_test.py (renamed from service/test/bitmask_libraries/nicknym_test.py) | 0 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/provider_test.py (renamed from service/test/bitmask_libraries/provider_test.py) | 0 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/session_test.py (renamed from service/test/bitmask_libraries/session_test.py) | 0 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/smtp_test.py (renamed from service/test/bitmask_libraries/smtp_test.py) | 0 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/soledad_test.py (renamed from service/test/bitmask_libraries/soledad_test.py) | 0 | ||||
-rw-r--r-- | service/test/unit/search/test_search_query.py (renamed from service/test/search/test_search_query.py) | 0 | ||||
-rw-r--r-- | service/test/unit/user_agent_test.py (renamed from service/test/user_agent_test.py) | 9 |
30 files changed, 77 insertions, 26 deletions
diff --git a/service/pixelated/adapter/soledad_querier.py b/service/pixelated/adapter/soledad_querier.py index 61bada1a..ab8f6941 100644 --- a/service/pixelated/adapter/soledad_querier.py +++ b/service/pixelated/adapter/soledad_querier.py @@ -35,6 +35,10 @@ class SoledadQuerier: def get_instance(cls, soledad=None): return get_soledad_querier_instance(cls, soledad) + @classmethod + def reset(cls): + cls.instance = None + def all_mails(self): fdocs_chash = [(fdoc, fdoc.content['chash']) for fdoc in self.soledad.get_from_index('by-type', 'flags')] if len(fdocs_chash) == 0: diff --git a/service/test/integration/__init__.py b/service/test/integration/__init__.py new file mode 100644 index 00000000..2756a319 --- /dev/null +++ b/service/test/integration/__init__.py @@ -0,0 +1,15 @@ +# +# Copyright (c) 2014 ThoughtWorks, Inc. +# +# Pixelated is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pixelated is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Pixelated. If not, see <http://www.gnu.org/licenses/>. diff --git a/service/integration/delete_mail_test.py b/service/test/integration/delete_mail_test.py index e7e08c31..3d4a6af7 100644 --- a/service/integration/delete_mail_test.py +++ b/service/test/integration/delete_mail_test.py @@ -14,7 +14,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 unittest -from integration import MailBuilder, SoledadTestBase +from test.support.integration_helper import MailBuilder, SoledadTestBase class DeleteMailTest(unittest.TestCase, SoledadTestBase): diff --git a/service/integration/drafts_test.py b/service/test/integration/drafts_test.py index 64581768..b70af3f5 100644 --- a/service/integration/drafts_test.py +++ b/service/test/integration/drafts_test.py @@ -14,7 +14,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 unittest -from integration import MailBuilder, SoledadTestBase +from test.support.integration_helper import MailBuilder, SoledadTestBase class DraftsTest(unittest.TestCase, SoledadTestBase): diff --git a/service/integration/mark_as_read_test.py b/service/test/integration/mark_as_read_test.py index 60084efa..2c95ebc1 100644 --- a/service/integration/mark_as_read_test.py +++ b/service/test/integration/mark_as_read_test.py @@ -14,7 +14,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 unittest -from integration import MailBuilder, SoledadTestBase +from test.support.integration_helper import MailBuilder, SoledadTestBase class MarkAsReadTest(unittest.TestCase, SoledadTestBase): diff --git a/service/integration/tags_test.py b/service/test/integration/tags_test.py index b313caec..e2ef1c0e 100644 --- a/service/integration/tags_test.py +++ b/service/test/integration/tags_test.py @@ -15,7 +15,7 @@ # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. import json import unittest -from integration import MailBuilder, SoledadTestBase +from test.support.integration_helper import MailBuilder, SoledadTestBase class TagsTest(unittest.TestCase, SoledadTestBase): diff --git a/service/test/support/__init__.py b/service/test/support/__init__.py new file mode 100644 index 00000000..2756a319 --- /dev/null +++ b/service/test/support/__init__.py @@ -0,0 +1,15 @@ +# +# Copyright (c) 2014 ThoughtWorks, Inc. +# +# Pixelated is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pixelated is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Pixelated. If not, see <http://www.gnu.org/licenses/>. diff --git a/service/integration/__init__.py b/service/test/support/integration_helper.py index 7691447d..616485ee 100644 --- a/service/integration/__init__.py +++ b/service/test/support/integration_helper.py @@ -16,7 +16,7 @@ import json from leap.soledad.client import Soledad -from mockito import mock +from mockito import mock, unstub import os from mock import Mock import shutil @@ -45,7 +45,6 @@ def initialize_soledad(tempdir): cert_file = "" class MockSharedDB(object): - get_doc = Mock(return_value=None) put_doc = Mock() lock = Mock(return_value=('atoken', 300)) @@ -65,6 +64,7 @@ def initialize_soledad(tempdir): cert_file) from leap.mail.imap.fields import fields + for name, expression in fields.INDEXES.items(): _soledad.create_index(name, *expression) @@ -103,19 +103,22 @@ class MailBuilder: class SoledadTestBase: - def teardown_soledad(self): self.soledad.close() shutil.rmtree(soledad_test_folder) def setup_soledad(self): + unstub() # making sure all mocks from other tests are reset + self.soledad = initialize_soledad(tempdir=soledad_test_folder) self.mail_address = "test@pixelated.org" - SoledadQuerier.instance = None + # resetting soledad querier + SoledadQuerier.reset() SoledadQuerier.get_instance(soledad=self.soledad) - PixelatedMail.from_email_address = self.mail_address + # setup app + PixelatedMail.from_email_address = self.mail_address self.app = pixelated.user_agent.app.test_client() self.account = FakeAccount() self.mail_sender = mock() @@ -139,7 +142,8 @@ class SoledadTestBase: return response['ident'] def post_tags(self, mail_ident, tags_json): - return json.loads(self.app.post('/mail/' + mail_ident + '/tags', data=tags_json, content_type="application/json").data) + return json.loads( + self.app.post('/mail/' + mail_ident + '/tags', data=tags_json, content_type="application/json").data) def delete_mail(self, mail_ident): self.app.delete('/mail/' + mail_ident) @@ -149,7 +153,6 @@ class SoledadTestBase: class ResponseMail: - def __init__(self, mail_dict): self.mail_dict = mail_dict @@ -171,4 +174,4 @@ class ResponseMail: @property def status(self): - return self.mail_dict['status']
\ No newline at end of file + return self.mail_dict['status'] diff --git a/service/test/adapter/test_helper.py b/service/test/support/test_helper.py index af0fed95..af0fed95 100644 --- a/service/test/adapter/test_helper.py +++ b/service/test/support/test_helper.py diff --git a/service/test/unit/__init__.py b/service/test/unit/__init__.py new file mode 100644 index 00000000..2756a319 --- /dev/null +++ b/service/test/unit/__init__.py @@ -0,0 +1,15 @@ +# +# Copyright (c) 2014 ThoughtWorks, Inc. +# +# Pixelated is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pixelated is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Pixelated. If not, see <http://www.gnu.org/licenses/>. diff --git a/service/test/adapter/__init__.py b/service/test/unit/adapter/__init__.py index e69de29b..e69de29b 100644 --- a/service/test/adapter/__init__.py +++ b/service/test/unit/adapter/__init__.py diff --git a/service/test/adapter/mail_service_test.py b/service/test/unit/adapter/mail_service_test.py index 549ab05c..549ab05c 100644 --- a/service/test/adapter/mail_service_test.py +++ b/service/test/unit/adapter/mail_service_test.py diff --git a/service/test/adapter/pixelated_mail_sender_test.py b/service/test/unit/adapter/pixelated_mail_sender_test.py index d75aa57c..207baadb 100644 --- a/service/test/adapter/pixelated_mail_sender_test.py +++ b/service/test/unit/adapter/pixelated_mail_sender_test.py @@ -14,10 +14,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 unittest + from pixelated.adapter.pixelated_mail import PixelatedMail from pixelated.adapter.pixelated_mail_sender import PixelatedMailSender from mockito import * -import test_helper +from test.support import test_helper class PixelatedMailSenderTest(unittest.TestCase): diff --git a/service/test/adapter/pixelated_mail_test.py b/service/test/unit/adapter/pixelated_mail_test.py index 28f70afa..0ab09a0a 100644 --- a/service/test/adapter/pixelated_mail_test.py +++ b/service/test/unit/adapter/pixelated_mail_test.py @@ -14,15 +14,15 @@ # 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 unittest -import os +import os import pixelated.support.date -import test_helper from pixelated.adapter.pixelated_mail import PixelatedMail, InputMail from pixelated.adapter.tag_service import TagService from pixelated.adapter.tag_index import TagIndex from pixelated.adapter.tag import Tag from mockito import * +from test.support import test_helper class TestPixelatedMail(unittest.TestCase): diff --git a/service/test/adapter/pixelated_mailbox_test.py b/service/test/unit/adapter/pixelated_mailbox_test.py index a6e4a1ab..d38cef5c 100644 --- a/service/test/adapter/pixelated_mailbox_test.py +++ b/service/test/unit/adapter/pixelated_mailbox_test.py @@ -17,8 +17,8 @@ import unittest from pixelated.adapter.pixelated_mail import PixelatedMail from pixelated.adapter.pixelated_mailbox import PixelatedMailbox -import test_helper from mockito import * +from test.support import test_helper class PixelatedMailboxTest(unittest.TestCase): diff --git a/service/test/adapter/pixelated_mailboxes_test.py b/service/test/unit/adapter/pixelated_mailboxes_test.py index dc7243f2..8314f7f8 100644 --- a/service/test/adapter/pixelated_mailboxes_test.py +++ b/service/test/unit/adapter/pixelated_mailboxes_test.py @@ -15,13 +15,12 @@ # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. import unittest -from test.adapter import test_helper +from test.support import test_helper from mockito import * import pixelated.adapter.soledad_querier querier = mock() -global querier -pixelated.adapter.soledad_querier.get_soledad_querier_instance = lambda x, y: querier +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 diff --git a/service/test/adapter/tag_index_test.py b/service/test/unit/adapter/tag_index_test.py index 21564fc5..21564fc5 100644 --- a/service/test/adapter/tag_index_test.py +++ b/service/test/unit/adapter/tag_index_test.py diff --git a/service/test/adapter/test_status.py b/service/test/unit/adapter/test_status.py index 7f644eca..bcdbb360 100644 --- a/service/test/adapter/test_status.py +++ b/service/test/unit/adapter/test_status.py @@ -16,7 +16,6 @@ import unittest from pixelated.adapter.status import Status -import test_helper class TestStatus(unittest.TestCase): diff --git a/service/test/adapter/test_tag.py b/service/test/unit/adapter/test_tag.py index fc14ff49..fc14ff49 100644 --- a/service/test/adapter/test_tag.py +++ b/service/test/unit/adapter/test_tag.py diff --git a/service/test/adapter/test_tag_service.py b/service/test/unit/adapter/test_tag_service.py index 5a70e82b..aeb1b503 100644 --- a/service/test/adapter/test_tag_service.py +++ b/service/test/unit/adapter/test_tag_service.py @@ -16,11 +16,12 @@ import unittest import tempfile -import test_helper + from pixelated.adapter.tag import Tag from pixelated.adapter.pixelated_mail import PixelatedMail from pixelated.adapter.tag_index import TagIndex from pixelated.adapter.tag_service import TagService +from test.support import test_helper class TagServiceTest(unittest.TestCase): diff --git a/service/test/bitmask_libraries/__init__.py b/service/test/unit/bitmask_libraries/__init__.py index e69de29b..e69de29b 100644 --- a/service/test/bitmask_libraries/__init__.py +++ b/service/test/unit/bitmask_libraries/__init__.py diff --git a/service/test/bitmask_libraries/abstract_leap_test.py b/service/test/unit/bitmask_libraries/abstract_leap_test.py index ddcfb08f..ddcfb08f 100644 --- a/service/test/bitmask_libraries/abstract_leap_test.py +++ b/service/test/unit/bitmask_libraries/abstract_leap_test.py diff --git a/service/test/bitmask_libraries/leap_srp_test.py b/service/test/unit/bitmask_libraries/leap_srp_test.py index 591929ce..591929ce 100644 --- a/service/test/bitmask_libraries/leap_srp_test.py +++ b/service/test/unit/bitmask_libraries/leap_srp_test.py diff --git a/service/test/bitmask_libraries/nicknym_test.py b/service/test/unit/bitmask_libraries/nicknym_test.py index 9d564abe..9d564abe 100644 --- a/service/test/bitmask_libraries/nicknym_test.py +++ b/service/test/unit/bitmask_libraries/nicknym_test.py diff --git a/service/test/bitmask_libraries/provider_test.py b/service/test/unit/bitmask_libraries/provider_test.py index 41cf3bf4..41cf3bf4 100644 --- a/service/test/bitmask_libraries/provider_test.py +++ b/service/test/unit/bitmask_libraries/provider_test.py diff --git a/service/test/bitmask_libraries/session_test.py b/service/test/unit/bitmask_libraries/session_test.py index 32d92f25..32d92f25 100644 --- a/service/test/bitmask_libraries/session_test.py +++ b/service/test/unit/bitmask_libraries/session_test.py diff --git a/service/test/bitmask_libraries/smtp_test.py b/service/test/unit/bitmask_libraries/smtp_test.py index 2bb3dcab..2bb3dcab 100644 --- a/service/test/bitmask_libraries/smtp_test.py +++ b/service/test/unit/bitmask_libraries/smtp_test.py diff --git a/service/test/bitmask_libraries/soledad_test.py b/service/test/unit/bitmask_libraries/soledad_test.py index 83a19fe1..83a19fe1 100644 --- a/service/test/bitmask_libraries/soledad_test.py +++ b/service/test/unit/bitmask_libraries/soledad_test.py diff --git a/service/test/search/test_search_query.py b/service/test/unit/search/test_search_query.py index 3bcbd219..3bcbd219 100644 --- a/service/test/search/test_search_query.py +++ b/service/test/unit/search/test_search_query.py diff --git a/service/test/user_agent_test.py b/service/test/unit/user_agent_test.py index be4d9354..22199333 100644 --- a/service/test/user_agent_test.py +++ b/service/test/unit/user_agent_test.py @@ -15,18 +15,17 @@ # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. import unittest +import json +import sys + import pixelated.user_agent -from pixelated.adapter.pixelated_mail import PixelatedMail -from pixelated.adapter.pixelated_mail import InputMail 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 -import test.adapter.test_helper as test_helper -import json +import test.support.test_helper as test_helper import pixelated.adapter.pixelated_mail -import sys import os |