summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
authorsw00 <sett.wai@gmail.com>2015-10-25 18:18:23 -0200
committersw00 <sett.wai@gmail.com>2015-11-09 20:57:19 -0200
commitb230d58eaa32a7f115881cffbf5637d98d1e8299 (patch)
tree062c6c8a80ef2f2d50e1499e1e745468b6d32a07 /service/test
parentf2f5473ead184032d1de6208bc2530dfb88455fc (diff)
template user's email address into title
this should solve https://github.com/pixelated/pixelated-user-agent/issues/246 needed to inject leap_session into root resource to access user email on request.
Diffstat (limited to 'service/test')
-rw-r--r--service/test/unit/resources/test_root_resource.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/service/test/unit/resources/test_root_resource.py b/service/test/unit/resources/test_root_resource.py
new file mode 100644
index 00000000..dc1e97ae
--- /dev/null
+++ b/service/test/unit/resources/test_root_resource.py
@@ -0,0 +1,40 @@
+import unittest
+from mockito import mock, when
+from test.unit.resources import DummySite
+from twisted.web.test.requesthelper import DummyRequest
+from pixelated.resources.root_resource import RootResource
+
+
+class TestRootResource(unittest.TestCase):
+
+ def setUp(self):
+ leap_session = mock()
+ when(leap_session).account_email().thenReturn('hackerman@pixelated.org')
+ root_resource = RootResource()
+ root_resource.initialize(leap_session, mock(), mock(), mock(), mock(), mock())
+ 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):
+ request = DummyRequest([''])
+
+ 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)
+
+ d.addCallback(assert_response)
+ return d