summary refs log tree commit diff
path: root/tests/server.py
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2018-11-07 03:00:00 +1100
committerGitHub <noreply@github.com>2018-11-07 03:00:00 +1100
commite62f7f17b32fa51a818fdcfc756464692ddb9194 (patch)
treed34e06c6c32e0637bea8aa66bf516d419dce26b2 /tests/server.py
parentAdd config variables for enabling terms auth and the policy name (#4142) (diff)
downloadsynapse-e62f7f17b32fa51a818fdcfc756464692ddb9194.tar.xz
Remove some boilerplate in tests (#4156)
Diffstat (limited to 'tests/server.py')
-rw-r--r--tests/server.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/server.py b/tests/server.py
index f63f33c94f..984cfe26d4 100644
--- a/tests/server.py
+++ b/tests/server.py
@@ -34,6 +34,7 @@ class FakeChannel(object):
     wire).
     """
 
+    _reactor = attr.ib()
     result = attr.ib(default=attr.Factory(dict))
     _producer = None
 
@@ -63,6 +64,15 @@ class FakeChannel(object):
 
     def registerProducer(self, producer, streaming):
         self._producer = producer
+        self.producerStreaming = streaming
+
+        def _produce():
+            if self._producer:
+                self._producer.resumeProducing()
+                self._reactor.callLater(0.1, _produce)
+
+        if not streaming:
+            self._reactor.callLater(0.0, _produce)
 
     def unregisterProducer(self):
         if self._producer is None:
@@ -105,7 +115,13 @@ class FakeSite:
 
 
 def make_request(
-    method, path, content=b"", access_token=None, request=SynapseRequest, shorthand=True
+    reactor,
+    method,
+    path,
+    content=b"",
+    access_token=None,
+    request=SynapseRequest,
+    shorthand=True,
 ):
     """
     Make a web request using the given method and path, feed it the
@@ -138,7 +154,7 @@ def make_request(
         content = content.encode('utf8')
 
     site = FakeSite()
-    channel = FakeChannel()
+    channel = FakeChannel(reactor)
 
     req = request(site, channel)
     req.process = lambda: b""