diff options
author | sw00 <sett.wai@gmail.com> | 2015-11-10 00:09:18 -0200 |
---|---|---|
committer | sw00 <sett.wai@gmail.com> | 2015-11-10 00:09:18 -0200 |
commit | ef86d4458c21f1d722fb162423cd3dfeea055844 (patch) | |
tree | 00fe2ac113ca1d020d1f26a1f5d8d891109787c9 /service | |
parent | e2c83c13ba0ca1edf94b5af0408f17c0d1aa4e95 (diff) |
refactor unit test
don't use initialize method of root_resource in test
Diffstat (limited to 'service')
-rw-r--r-- | service/test/support/integration/app_test_client.py | 2 | ||||
-rw-r--r-- | service/test/unit/adapter/test_mail_service.py | 2 | ||||
-rw-r--r-- | service/test/unit/resources/test_root_resource.py | 28 |
3 files changed, 10 insertions, 22 deletions
diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index 369a393d..484bea6e 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -166,7 +166,7 @@ class AppTestClient(object): return mail_sender def _create_mail_service(self, mail_sender, mail_store, search_engine): - mail_service = MailService(mail_sender, mail_store, search_engine) + mail_service = MailService(mail_sender, mail_store, search_engine, self.MAIL_ADDRESS) return mail_service def _generate_soledad_test_folder_name(self, soledad_test_folder='/tmp/soledad-test/test'): diff --git a/service/test/unit/adapter/test_mail_service.py b/service/test/unit/adapter/test_mail_service.py index 6faf5140..1ec3806e 100644 --- a/service/test/unit/adapter/test_mail_service.py +++ b/service/test/unit/adapter/test_mail_service.py @@ -37,7 +37,7 @@ class TestMailService(unittest.TestCase): self.mail_sender = mock() self.search_engine = mock() - self.mail_service = MailService(self.mail_sender, self.mail_store, self.search_engine) + self.mail_service = MailService(self.mail_sender, self.mail_store, self.search_engine, 'acount@email') def tearDown(self): unstub() diff --git a/service/test/unit/resources/test_root_resource.py b/service/test/unit/resources/test_root_resource.py index 068a531f..4cdaf97a 100644 --- a/service/test/unit/resources/test_root_resource.py +++ b/service/test/unit/resources/test_root_resource.py @@ -1,4 +1,5 @@ import unittest +import re from mockito import mock, when from test.unit.resources import DummySite from twisted.web.test.requesthelper import DummyRequest @@ -6,20 +7,13 @@ from pixelated.resources.root_resource import RootResource class TestRootResource(unittest.TestCase): + MAIL_ADDRESS = 'test_user@pixelated-project.org' def setUp(self): - test_email = 'hackerman@pixelated-project.org' - mail_service = mock() - mail_service.account_email = test_email - root_resource = RootResource() - root_resource.initialize(mock(), mock(), mail_service, mock(), mock()) - root_resource._html_template = """ - <html> - <head> - <title>$account_email</title> - </head> - </html>""" + root_resource._mode = root_resource + root_resource.account_email = self.MAIL_ADDRESS + root_resource._html_template = "<html><head><title>$account_email</title></head></html>" self.web = DummySite(root_resource) def test_render_GET_should_template_account_email(self): @@ -28,15 +22,9 @@ class TestRootResource(unittest.TestCase): d = self.web.get(request) def assert_response(_): - expected = """ - <html> - <head> - <title>hackerman@pixelated.org</title> - </head> - </html>""" - - actual = request.written[0] - self.assertEquals(expected, actual) + expected = "<title>{0}</title>".format(self.MAIL_ADDRESS) + matches = re.findall(expected, request.written[0]) + self.assertEquals(len(matches), 1) d.addCallback(assert_response) return d |