summary refs log tree commit diff
path: root/tests/handlers/test_presence.py
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2021-03-22 14:28:19 +0100
committerGitHub <noreply@github.com>2021-03-22 14:28:19 +0100
commite09838c78fe63a7d702ac87dca8365310457bef5 (patch)
treee4877c8022cda6b7953edc8066a6af8dc329082a /tests/handlers/test_presence.py
parentfix mypy (diff)
parentIncorporate review (diff)
downloadsynapse-e09838c78fe63a7d702ac87dca8365310457bef5.tar.xz
Merge pull request #9644 from matrix-org/babolivier/msc3026
Implement MSC3026: busy presence state
Diffstat (limited to 'tests/handlers/test_presence.py')
-rw-r--r--tests/handlers/test_presence.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/handlers/test_presence.py b/tests/handlers/test_presence.py
index 996c614198..77330f59a9 100644
--- a/tests/handlers/test_presence.py
+++ b/tests/handlers/test_presence.py
@@ -310,6 +310,26 @@ class PresenceTimeoutTestCase(unittest.TestCase):
         self.assertIsNotNone(new_state)
         self.assertEquals(new_state.state, PresenceState.UNAVAILABLE)
 
+    def test_busy_no_idle(self):
+        """
+        Tests that a user setting their presence to busy but idling doesn't turn their
+        presence state into unavailable.
+        """
+        user_id = "@foo:bar"
+        now = 5000000
+
+        state = UserPresenceState.default(user_id)
+        state = state.copy_and_replace(
+            state=PresenceState.BUSY,
+            last_active_ts=now - IDLE_TIMER - 1,
+            last_user_sync_ts=now,
+        )
+
+        new_state = handle_timeout(state, is_mine=True, syncing_user_ids=set(), now=now)
+
+        self.assertIsNotNone(new_state)
+        self.assertEquals(new_state.state, PresenceState.BUSY)
+
     def test_sync_timeout(self):
         user_id = "@foo:bar"
         now = 5000000