diff options
author | Richard van der Hoff <richard@matrix.org> | 2020-11-13 23:11:43 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2020-11-15 23:09:03 +0000 |
commit | cfd895a22e7563b6b22141d14d9c8aebf177df44 (patch) | |
tree | 0a2259d1f2d45646b946c7f060ae6dfc97edef8d /tests/http | |
parent | fix dict handling for make_request() (diff) | |
download | synapse-cfd895a22e7563b6b22141d14d9c8aebf177df44.tar.xz |
use global make_request() directly where we have a custom Resource
Where we want to render a request against a specific Resource, call the global make_request() function rather than the one in HomeserverTestCase, allowing us to pass in an appropriate `Site`.
Diffstat (limited to 'tests/http')
-rw-r--r-- | tests/http/test_additional_resource.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/http/test_additional_resource.py b/tests/http/test_additional_resource.py index 62d36c2906..e835512a41 100644 --- a/tests/http/test_additional_resource.py +++ b/tests/http/test_additional_resource.py @@ -17,6 +17,7 @@ from synapse.http.additional_resource import AdditionalResource from synapse.http.server import respond_with_json +from tests.server import FakeSite, make_request, render from tests.unittest import HomeserverTestCase @@ -43,20 +44,20 @@ class AdditionalResourceTests(HomeserverTestCase): def test_async(self): handler = _AsyncTestCustomEndpoint({}, None).handle_request - self.resource = AdditionalResource(self.hs, handler) + resource = AdditionalResource(self.hs, handler) - request, channel = self.make_request("GET", "/") - self.render(request) + request, channel = make_request(self.reactor, FakeSite(resource), "GET", "/") + render(request, resource, self.reactor) self.assertEqual(request.code, 200) self.assertEqual(channel.json_body, {"some_key": "some_value_async"}) def test_sync(self): handler = _SyncTestCustomEndpoint({}, None).handle_request - self.resource = AdditionalResource(self.hs, handler) + resource = AdditionalResource(self.hs, handler) - request, channel = self.make_request("GET", "/") - self.render(request) + request, channel = make_request(self.reactor, FakeSite(resource), "GET", "/") + render(request, resource, self.reactor) self.assertEqual(request.code, 200) self.assertEqual(channel.json_body, {"some_key": "some_value_sync"}) |