summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-12-11 17:31:56 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-12-11 17:54:42 +0000
commit1f26e56de003fcf0fe8a8f064611ca40e997a3e6 (patch)
tree29457b38a4e2be13e682614a25227e814009b6f2 /tests
parentInitial hack at unit tests of room typing REST API (diff)
downloadsynapse-1f26e56de003fcf0fe8a8f064611ca40e997a3e6.tar.xz
Actually unit-test the event stream around REST typing tests
Diffstat (limited to 'tests')
-rw-r--r--tests/rest/test_rooms.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/rest/test_rooms.py b/tests/rest/test_rooms.py
index 5273105304..a34f832758 100644
--- a/tests/rest/test_rooms.py
+++ b/tests/rest/test_rooms.py
@@ -1095,6 +1095,8 @@ class RoomTypingTestCase(RestTestCase):
         )
         self.hs = hs
 
+        self.event_source = hs.get_event_sources().sources["typing"]
+
         self.ratelimiter = hs.get_ratelimiter()
         self.ratelimiter.send_message.return_value = (True, 0)
 
@@ -1116,6 +1118,8 @@ class RoomTypingTestCase(RestTestCase):
         synapse.rest.room.register_servlets(hs, self.mock_resource)
 
         self.room_id = yield self.create_room_as(self.user_id)
+        # Need another user to make notifications actually work
+        yield self.join(self.room_id, user="@jim:red")
 
     def tearDown(self):
         self.hs.get_handlers().typing_notification_handler.tearDown()
@@ -1128,6 +1132,16 @@ class RoomTypingTestCase(RestTestCase):
         )
         self.assertEquals(200, code)
 
+        self.assertEquals(self.event_source.get_current_key(), 1)
+        self.assertEquals(
+            self.event_source.get_new_events_for_user(self.user_id, 0, None)[0],
+            [
+                {"type": "m.typing",
+                 "room_id": self.room_id,
+                 "typing": [self.user_id]},
+            ]
+        )
+
     @defer.inlineCallbacks
     def test_set_not_typing(self):
         (code, _) = yield self.mock_resource.trigger("PUT",