summary refs log tree commit diff
path: root/tests/server.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2020-11-13 22:39:09 +0000
committerRichard van der Hoff <richard@matrix.org>2020-11-15 23:09:03 +0000
commit9debe657a39a234d574e949ae8faf3f5ed027c09 (patch)
tree898ade91a556963701584ad0724d57aff45476ae /tests/server.py
parentpass a Site into RestHelper (diff)
downloadsynapse-9debe657a39a234d574e949ae8faf3f5ed027c09.tar.xz
pass a Site into make_request
Diffstat (limited to 'tests/server.py')
-rw-r--r--tests/server.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/server.py b/tests/server.py
index 3dd2cfc072..b9ccde4962 100644
--- a/tests/server.py
+++ b/tests/server.py
@@ -21,6 +21,7 @@ from twisted.python.failure import Failure
 from twisted.test.proto_helpers import AccumulatingProtocol, MemoryReactorClock
 from twisted.web.http import unquote
 from twisted.web.http_headers import Headers
+from twisted.web.resource import IResource
 from twisted.web.server import Site
 
 from synapse.http.site import SynapseRequest
@@ -128,9 +129,21 @@ class FakeSite:
     site_tag = "test"
     access_logger = logging.getLogger("synapse.access.http.fake")
 
+    def __init__(self, resource: IResource):
+        """
+
+        Args:
+            resource: the resource to be used for rendering all requests
+        """
+        self._resource = resource
+
+    def getResourceFor(self, request):
+        return self._resource
+
 
 def make_request(
     reactor,
+    site: Site,
     method,
     path,
     content=b"",
@@ -145,6 +158,8 @@ def make_request(
     content, and return the Request and the Channel underneath.
 
     Args:
+        site: The twisted Site to associate with the Channel
+
         method (bytes/unicode): The HTTP request method ("verb").
         path (bytes/unicode): The HTTP path, suitably URL encoded (e.g.
         escaped UTF-8 & spaces and such).
@@ -181,7 +196,6 @@ def make_request(
     if isinstance(content, str):
         content = content.encode("utf8")
 
-    site = FakeSite()
     channel = FakeChannel(site, reactor)
 
     req = request(channel)