summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-02-19 11:26:32 +0000
committerErik Johnston <erik@matrix.org>2016-02-19 11:26:32 +0000
commitea7786e8cac34d11b248d89fc51b33f1ba247038 (patch)
tree048bfd6d659529f1f55f4d1564cd2cb76a347193 /tests
parentMerge pull request #582 from matrix-org/erikj/presence (diff)
parentDon't set currently_active for remote presence (diff)
downloadsynapse-ea7786e8cac34d11b248d89fc51b33f1ba247038.tar.xz
Merge pull request #586 from matrix-org/erikj/presence
Fix presence `currently_active`. Add presence metrics.
Diffstat (limited to 'tests')
-rw-r--r--tests/handlers/test_presence.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/handlers/test_presence.py b/tests/handlers/test_presence.py
index 197298db15..87c795fcfa 100644
--- a/tests/handlers/test_presence.py
+++ b/tests/handlers/test_presence.py
@@ -49,7 +49,7 @@ class PresenceUpdateTestCase(unittest.TestCase):
         self.assertEquals(new_state.status_msg, state.status_msg)
         self.assertEquals(state.last_federation_update_ts, now)
 
-        self.assertEquals(wheel_timer.insert.call_count, 2)
+        self.assertEquals(wheel_timer.insert.call_count, 3)
         wheel_timer.insert.assert_has_calls([
             call(
                 now=now,
@@ -60,7 +60,12 @@ class PresenceUpdateTestCase(unittest.TestCase):
                 now=now,
                 obj=user_id,
                 then=new_state.last_user_sync_ts + SYNC_ONLINE_TIMEOUT
-            )
+            ),
+            call(
+                now=now,
+                obj=user_id,
+                then=new_state.last_active_ts + LAST_ACTIVE_GRANULARITY
+            ),
         ], any_order=True)
 
     def test_online_to_online(self):
@@ -91,7 +96,7 @@ class PresenceUpdateTestCase(unittest.TestCase):
         self.assertEquals(new_state.status_msg, state.status_msg)
         self.assertEquals(state.last_federation_update_ts, now)
 
-        self.assertEquals(wheel_timer.insert.call_count, 2)
+        self.assertEquals(wheel_timer.insert.call_count, 3)
         wheel_timer.insert.assert_has_calls([
             call(
                 now=now,
@@ -102,7 +107,12 @@ class PresenceUpdateTestCase(unittest.TestCase):
                 now=now,
                 obj=user_id,
                 then=new_state.last_user_sync_ts + SYNC_ONLINE_TIMEOUT
-            )
+            ),
+            call(
+                now=now,
+                obj=user_id,
+                then=new_state.last_active_ts + LAST_ACTIVE_GRANULARITY
+            ),
         ], any_order=True)
 
     def test_online_to_online_last_active(self):
@@ -153,6 +163,7 @@ class PresenceUpdateTestCase(unittest.TestCase):
         prev_state = UserPresenceState.default(user_id)
         prev_state = prev_state.copy_and_replace(
             state=PresenceState.ONLINE,
+            last_active_ts=now,
         )
 
         new_state = prev_state.copy_and_replace(