diff options
author | Erik Johnston <erik@matrix.org> | 2018-08-09 10:16:29 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2018-08-09 10:16:29 +0100 |
commit | 484a0ebdfcae39be59ff8d8da948a62f5cce110c (patch) | |
tree | 2848d6347df8b04faa727c325c6ed19826061b91 /tests/server.py | |
parent | Update workers.rst with new paths (diff) | |
parent | Merge pull request #3632 from matrix-org/erikj/refactor_repl_servlet (diff) | |
download | synapse-484a0ebdfcae39be59ff8d8da948a62f5cce110c.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/split_profiles
Diffstat (limited to 'tests/server.py')
-rw-r--r-- | tests/server.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/server.py b/tests/server.py index c611dd6059..e249668d21 100644 --- a/tests/server.py +++ b/tests/server.py @@ -11,6 +11,7 @@ from twisted.python.failure import Failure from twisted.test.proto_helpers import MemoryReactorClock from synapse.http.site import SynapseRequest +from synapse.util import Clock from tests.utils import setup_test_homeserver as _sth @@ -28,7 +29,13 @@ class FakeChannel(object): def json_body(self): if not self.result: raise Exception("No result yet.") - return json.loads(self.result["body"]) + return json.loads(self.result["body"].decode('utf8')) + + @property + def code(self): + if not self.result: + raise Exception("No result yet.") + return int(self.result["code"]) def writeHeaders(self, version, code, reason, headers): self.result["version"] = version @@ -79,11 +86,16 @@ def make_request(method, path, content=b""): Make a web request using the given method and path, feed it the content, and return the Request and the Channel underneath. """ + if not isinstance(method, bytes): + method = method.encode('ascii') + + if not isinstance(path, bytes): + path = path.encode('ascii') # Decorate it to be the full path if not path.startswith(b"/_matrix"): path = b"/_matrix/client/r0/" + path - path = path.replace("//", "/") + path = path.replace(b"//", b"/") if isinstance(content, text_type): content = content.encode('utf8') @@ -191,3 +203,9 @@ def setup_test_homeserver(*args, **kwargs): clock.threadpool = ThreadPool() pool.threadpool = ThreadPool() return d + + +def get_clock(): + clock = ThreadedMemoryReactorClock() + hs_clock = Clock(clock) + return (clock, hs_clock) |