diff options
author | Richard van der Hoff <richard@matrix.org> | 2020-12-02 15:26:25 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2020-12-02 16:30:01 +0000 |
commit | 7ea85302f3ce59cdb38bceb1c2aeea2d690e2dbb (patch) | |
tree | 2636a3544e0ced69fcb04996a2eb3c8cbe4b21ef /tests/replication/_base.py | |
parent | Add `create_resource_dict` method to HomeserverTestCase (diff) | |
download | synapse-7ea85302f3ce59cdb38bceb1c2aeea2d690e2dbb.tar.xz |
fix up various test cases
A few test cases were relying on being able to mount non-client servlets on the test resource. it's better to give them their own Resources.
Diffstat (limited to 'tests/replication/_base.py')
-rw-r--r-- | tests/replication/_base.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/replication/_base.py b/tests/replication/_base.py index 295c5d58a6..79738ab46f 100644 --- a/tests/replication/_base.py +++ b/tests/replication/_base.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging -from typing import Any, Callable, List, Optional, Tuple +from typing import Any, Callable, Dict, List, Optional, Tuple import attr @@ -21,6 +21,7 @@ from twisted.internet.interfaces import IConsumer, IPullProducer, IReactorTime from twisted.internet.protocol import Protocol from twisted.internet.task import LoopingCall from twisted.web.http import HTTPChannel +from twisted.web.resource import Resource from synapse.app.generic_worker import ( GenericWorkerReplicationHandler, @@ -28,7 +29,7 @@ from synapse.app.generic_worker import ( ) from synapse.http.server import JsonResource from synapse.http.site import SynapseRequest, SynapseSite -from synapse.replication.http import ReplicationRestResource, streams +from synapse.replication.http import ReplicationRestResource from synapse.replication.tcp.handler import ReplicationCommandHandler from synapse.replication.tcp.protocol import ClientReplicationStreamProtocol from synapse.replication.tcp.resource import ReplicationStreamProtocolFactory @@ -54,10 +55,6 @@ class BaseStreamTestCase(unittest.HomeserverTestCase): if not hiredis: skip = "Requires hiredis" - servlets = [ - streams.register_servlets, - ] - def prepare(self, reactor, clock, hs): # build a replication server server_factory = ReplicationStreamProtocolFactory(hs) @@ -88,6 +85,11 @@ class BaseStreamTestCase(unittest.HomeserverTestCase): self._client_transport = None self._server_transport = None + def create_resource_dict(self) -> Dict[str, Resource]: + d = super().create_resource_dict() + d["/_synapse/replication"] = ReplicationRestResource(self.hs) + return d + def _get_worker_hs_config(self) -> dict: config = self.default_config() config["worker_app"] = "synapse.app.generic_worker" |