summary refs log tree commit diff
path: root/tests/rest/test_rooms.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-11-10 18:07:55 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-11-10 18:07:55 +0000
commit50c8e3fcda0a892e9205be046bf8e0a931514e15 (patch)
tree19138f9c475cb740eee159b8d2be40d630aef171 /tests/rest/test_rooms.py
parentVarious fixes to try & make openwebrtc safari extension work (still doesn't w... (diff)
downloadsynapse-50c8e3fcda0a892e9205be046bf8e0a931514e15.tar.xz
Initial (empty) test that room initialSync at least returns 200 OK
Diffstat (limited to 'tests/rest/test_rooms.py')
-rw-r--r--tests/rest/test_rooms.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/rest/test_rooms.py b/tests/rest/test_rooms.py
index 1ce9b8a83d..69dade4548 100644
--- a/tests/rest/test_rooms.py
+++ b/tests/rest/test_rooms.py
@@ -940,6 +940,59 @@ class RoomMessagesTestCase(RestTestCase):
         (code, response) = yield self.mock_resource.trigger("PUT", path, content)
         self.assertEquals(200, code, msg=str(response))
 
+
+class RoomInitialSyncTestCase(RestTestCase):
+    """ Tests /rooms/$room_id/initialSync. """
+    user_id = "@sid1:red"
+
+    @defer.inlineCallbacks
+    def setUp(self):
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
+        self.auth_user_id = self.user_id
+
+        state_handler = Mock(spec=["handle_new_event"])
+        state_handler.handle_new_event.return_value = True
+
+        persistence_service = Mock(spec=["get_latest_pdus_in_context"])
+        persistence_service.get_latest_pdus_in_context.return_value = []
+
+        hs = HomeServer(
+            "red",
+            db_pool=None,
+            http_client=None,
+            datastore=MemoryDataStore(),
+            replication_layer=Mock(),
+            state_handler=state_handler,
+            persistence_service=persistence_service,
+            ratelimiter=NonCallableMock(spec_set=[
+                "send_message",
+            ]),
+            config=NonCallableMock(),
+        )
+        self.ratelimiter = hs.get_ratelimiter()
+        self.ratelimiter.send_message.return_value = (True, 0)
+
+        hs.get_handlers().federation_handler = Mock()
+
+        def _get_user_by_token(token=None):
+            return {
+                "user": hs.parse_userid(self.auth_user_id),
+                "admin": False,
+                "device_id": None,
+            }
+        hs.get_auth().get_user_by_token = _get_user_by_token
+
+        synapse.rest.room.register_servlets(hs, self.mock_resource)
+
+        # create the room
+        self.room_id = yield self.create_room_as(self.user_id)
+
+    @defer.inlineCallbacks
+    def test_initial_sync(self):
+        (code, response) = yield self.mock_resource.trigger_get(
+                "/rooms/%s/initialSync" % self.room_id)
+        self.assertEquals(200, code)
+
 #        (code, response) = yield self.mock_resource.trigger("GET", path, None)
 #        self.assertEquals(200, code, msg=str(response))
 #        self.assert_dict(json.loads(content), response)