summary refs log tree commit diff
path: root/tests/server.py
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2018-11-06 05:53:44 +1100
committerGitHub <noreply@github.com>2018-11-06 05:53:44 +1100
commitefdcbbe46bfe39f0dd3ef508bb08c37326892adc (patch)
tree79aa5f81a6c652e4b874b4083813d3928f82d21b /tests/server.py
parentAdd some tests for the HTTP pusher (#4149) (diff)
downloadsynapse-efdcbbe46bfe39f0dd3ef508bb08c37326892adc.tar.xz
Tests for user consent resource (#4140)
Diffstat (limited to 'tests/server.py')
-rw-r--r--tests/server.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/server.py b/tests/server.py
index cc6dbe04ac..f63f33c94f 100644
--- a/tests/server.py
+++ b/tests/server.py
@@ -104,10 +104,24 @@ class FakeSite:
         return FakeLogger()
 
 
-def make_request(method, path, content=b"", access_token=None, request=SynapseRequest):
+def make_request(
+    method, path, content=b"", access_token=None, request=SynapseRequest, shorthand=True
+):
     """
     Make a web request using the given method and path, feed it the
     content, and return the Request and the Channel underneath.
+
+    Args:
+        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).
+        content (bytes or dict): The body of the request. JSON-encoded, if
+        a dict.
+        shorthand: Whether to try and be helpful and prefix the given URL
+        with the usual REST API path, if it doesn't contain it.
+
+    Returns:
+        A synapse.http.site.SynapseRequest.
     """
     if not isinstance(method, bytes):
         method = method.encode('ascii')
@@ -115,8 +129,8 @@ def make_request(method, path, content=b"", access_token=None, request=SynapseRe
     if not isinstance(path, bytes):
         path = path.encode('ascii')
 
-    # Decorate it to be the full path
-    if not path.startswith(b"/_matrix"):
+    # Decorate it to be the full path, if we're using shorthand
+    if shorthand and not path.startswith(b"/_matrix"):
         path = b"/_matrix/client/r0/" + path
         path = path.replace(b"//", b"/")