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/test/unit/resources | |
parent | e2c83c13ba0ca1edf94b5af0408f17c0d1aa4e95 (diff) |
refactor unit test
don't use initialize method of root_resource in test
Diffstat (limited to 'service/test/unit/resources')
-rw-r--r-- | service/test/unit/resources/test_root_resource.py | 28 |
1 files changed, 8 insertions, 20 deletions
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 |