From b230d58eaa32a7f115881cffbf5637d98d1e8299 Mon Sep 17 00:00:00 2001 From: sw00 Date: Sun, 25 Oct 2015 18:18:23 -0200 Subject: 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. --- service/test/unit/resources/test_root_resource.py | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 service/test/unit/resources/test_root_resource.py (limited to 'service/test') 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 = """ + + + $account_email + + """ + 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 = """ + + + hackerman@pixelated.org + + """ + + actual = request.written[0] + self.assertEquals(expected, actual) + + d.addCallback(assert_response) + return d -- cgit v1.2.3