summary refs log tree commit diff
path: root/tests/handlers/test_typing.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-12-10 19:39:01 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-12-10 19:39:01 +0000
commit9eb819e82801091362de7bd57c126ca5f60f1a8d (patch)
tree4beb4e888331d05d0adf8ef4544b7c766f1b9003 /tests/handlers/test_typing.py
parentImplement .cancel_call_later() in MockClock (diff)
downloadsynapse-9eb819e82801091362de7bd57c126ca5f60f1a8d.tar.xz
First hack at implementing timeouts in typing notification handler
Diffstat (limited to 'tests/handlers/test_typing.py')
-rw-r--r--tests/handlers/test_typing.py36
1 files changed, 33 insertions, 3 deletions
diff --git a/tests/handlers/test_typing.py b/tests/handlers/test_typing.py
index 7e6ed9a42f..6b9e22d396 100644
--- a/tests/handlers/test_typing.py
+++ b/tests/handlers/test_typing.py
@@ -238,9 +238,11 @@ class TypingNotificationsTestCase(unittest.TestCase):
 
         # Gut-wrenching
         from synapse.handlers.typing import RoomMember
-        self.handler._member_typing_until[
-            RoomMember(self.room_id, self.u_apple)
-        ] = 1002000
+        member = RoomMember(self.room_id, self.u_apple)
+        self.handler._member_typing_until[member] = 1002000
+        self.handler._member_typing_timer[member] = (
+            self.clock.call_later(1002, lambda: 0)
+        )
 
         yield self.handler.stopped_typing(
             target_user=self.u_apple,
@@ -256,3 +258,31 @@ class TypingNotificationsTestCase(unittest.TestCase):
         ])
 
         yield put_json.await_calls()
+
+    @defer.inlineCallbacks
+    def test_typing_timeout(self):
+        self.room_members = [self.u_apple, self.u_banana]
+
+        yield self.handler.started_typing(
+            target_user=self.u_apple,
+            auth_user=self.u_apple,
+            room_id=self.room_id,
+            timeout=10000,
+        )
+
+        self.mock_update_client.assert_has_calls([
+            call(observer_user=self.u_banana,
+                observed_user=self.u_apple,
+                room_id=self.room_id,
+                typing=True),
+        ])
+        self.mock_update_client.reset_mock()
+
+        self.clock.advance_time(11)
+
+        self.mock_update_client.assert_has_calls([
+            call(observer_user=self.u_banana,
+                observed_user=self.u_apple,
+                room_id=self.room_id,
+                typing=False),
+        ])