summary refs log tree commit diff
path: root/tests/handlers
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-09-01 15:38:37 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-09-01 15:39:50 +0100
commit468d94c92066ddb76db7f38771e283c152cabb7d (patch)
treeb857c837ce5369b726ed138539815e2379247e6e /tests/handlers
parentFixed presence change that occurs -Xs ago (diff)
downloadsynapse-468d94c92066ddb76db7f38771e283c152cabb7d.tar.xz
Rename API-visible 'mtime' presence field to 'last_active'; slightly different semantics
Diffstat (limited to 'tests/handlers')
-rw-r--r--tests/handlers/test_presence.py29
-rw-r--r--tests/handlers/test_presencelike.py20
2 files changed, 32 insertions, 17 deletions
diff --git a/tests/handlers/test_presence.py b/tests/handlers/test_presence.py
index f37d9917fe..844c4e3fb7 100644
--- a/tests/handlers/test_presence.py
+++ b/tests/handlers/test_presence.py
@@ -213,7 +213,7 @@ class PresenceStateTestCase(unittest.TestCase):
                 state={
                     "presence": UNAVAILABLE,
                     "status_msg": "Away",
-                    "mtime": 1000000, # MockClock
+                    "last_active": 1000000, # MockClock
                 })
 
         yield self.handler.set_state(
@@ -621,6 +621,9 @@ class PresencePushTestCase(unittest.TestCase):
 
         # TODO(paul): Gut-wrenching
         self.handler._user_cachemap[self.u_apple] = UserPresenceCache()
+        self.handler._user_cachemap[self.u_apple].update(
+            {"presence": OFFLINE}, serial=0
+        )
         apple_set = self.handler._local_pushmap.setdefault("apple", set())
         apple_set.add(self.u_banana)
         apple_set.add(self.u_clementine)
@@ -640,7 +643,7 @@ class PresencePushTestCase(unittest.TestCase):
                     "user_id": "@apple:test",
                     "presence": ONLINE,
                     "state": ONLINE,
-                    "mtime_age": 0,
+                    "last_active_ago": 0,
                 }},
             ],
         )
@@ -673,7 +676,7 @@ class PresencePushTestCase(unittest.TestCase):
                 {"observed_user": self.u_banana,
                  "presence": ONLINE,
                  "state": ONLINE,
-                 "mtime_age": 2000},
+                 "last_active_ago": 2000},
                 {"observed_user": self.u_clementine,
                  "presence": OFFLINE,
                  "state": OFFLINE},
@@ -690,7 +693,7 @@ class PresencePushTestCase(unittest.TestCase):
                      "user_id": "@banana:test",
                      "presence": ONLINE,
                      "state": ONLINE,
-                     "mtime_age": 2000
+                     "last_active_ago": 2000
                 }},
             ]
         )
@@ -707,7 +710,7 @@ class PresencePushTestCase(unittest.TestCase):
                             {"user_id": "@apple:test",
                              "presence": u"online",
                              "state": u"online",
-                             "mtime_age": 0},
+                             "last_active_ago": 0},
                         ],
                     }
                 )
@@ -723,6 +726,9 @@ class PresencePushTestCase(unittest.TestCase):
 
         # TODO(paul): Gut-wrenching
         self.handler._user_cachemap[self.u_apple] = UserPresenceCache()
+        self.handler._user_cachemap[self.u_apple].update(
+            {"presence": OFFLINE}, serial=0
+        )
         apple_set = self.handler._remote_sendmap.setdefault("apple", set())
         apple_set.add(self.u_potato.domain)
 
@@ -750,7 +756,7 @@ class PresencePushTestCase(unittest.TestCase):
                     "push": [
                         {"user_id": "@potato:remote",
                          "state": "online",
-                         "mtime_age": 1000},
+                         "last_active_ago": 1000},
                     ],
                 }
             )
@@ -767,7 +773,7 @@ class PresencePushTestCase(unittest.TestCase):
                      "user_id": "@potato:remote",
                      "presence": ONLINE,
                      "state": ONLINE,
-                     "mtime_age": 1000,
+                     "last_active_ago": 1000,
                 }}
             ]
         )
@@ -777,7 +783,7 @@ class PresencePushTestCase(unittest.TestCase):
         state = yield self.handler.get_state(self.u_potato, self.u_apple)
 
         self.assertEquals(
-            {"state": ONLINE, "presence": ONLINE, "mtime_age": 3000},
+            {"state": ONLINE, "presence": ONLINE, "last_active_ago": 3000},
             state
         )
 
@@ -792,7 +798,7 @@ class PresencePushTestCase(unittest.TestCase):
         self.handler._user_cachemap[self.u_clementine].update(
             {
                 "presence": PresenceState.ONLINE,
-                "mtime": self.clock.time_msec(),
+                "last_active": self.clock.time_msec(),
             }, self.u_clementine
         )
 
@@ -811,7 +817,7 @@ class PresencePushTestCase(unittest.TestCase):
                      "user_id": "@clementine:test",
                      "presence": ONLINE,
                      "state": ONLINE,
-                     "mtime_age": 0,
+                     "last_active_ago": 0,
                 }}
             ]
         )
@@ -967,7 +973,8 @@ class PresencePollingTestCase(unittest.TestCase):
         def get_presence_state(user_localpart):
             return defer.succeed(
                     {"state": self.current_user_state[user_localpart],
-                     "status_msg": None}
+                     "status_msg": None,
+                     "mtime": 123456000}
             )
         self.datastore.get_presence_state = get_presence_state
 
diff --git a/tests/handlers/test_presencelike.py b/tests/handlers/test_presencelike.py
index 2402bed8d5..38cc34350b 100644
--- a/tests/handlers/test_presencelike.py
+++ b/tests/handlers/test_presencelike.py
@@ -166,7 +166,11 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
         # TODO(paul): Gut-wrenching
         from synapse.handlers.presence import UserPresenceCache
         self.handlers.presence_handler._user_cachemap[self.u_apple] = (
-                UserPresenceCache())
+            UserPresenceCache()
+        )
+        self.handlers.presence_handler._user_cachemap[self.u_apple].update(
+            {"presence": OFFLINE}, serial=0
+        )
         apple_set = self.handlers.presence_handler._local_pushmap.setdefault(
                 "apple", set())
         apple_set.add(self.u_banana)
@@ -184,7 +188,7 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
             {"observed_user": self.u_banana,
                 "presence": ONLINE,
                 "state": ONLINE,
-                "mtime_age": 0,
+                "last_active_ago": 0,
                 "displayname": "Frank",
                 "avatar_url": "http://foo"},
             {"observed_user": self.u_clementine,
@@ -202,7 +206,7 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
         statuscache = self.mock_update_client.call_args[1]["statuscache"]
         self.assertEquals({
             "presence": ONLINE,
-            "mtime": 1000000, # MockClock
+            "last_active": 1000000, # MockClock
             "displayname": "Frank",
             "avatar_url": "http://foo",
         }, statuscache.state)
@@ -225,7 +229,7 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
         statuscache = self.mock_update_client.call_args[1]["statuscache"]
         self.assertEquals({
             "presence": ONLINE,
-            "mtime": 1000000, # MockClock
+            "last_active": 1000000, # MockClock
             "displayname": "I am an Apple",
             "avatar_url": "http://foo",
         }, statuscache.state)
@@ -243,7 +247,11 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
         # TODO(paul): Gut-wrenching
         from synapse.handlers.presence import UserPresenceCache
         self.handlers.presence_handler._user_cachemap[self.u_apple] = (
-                UserPresenceCache())
+            UserPresenceCache()
+        )
+        self.handlers.presence_handler._user_cachemap[self.u_apple].update(
+            {"presence": OFFLINE}, serial=0
+        )
         apple_set = self.handlers.presence_handler._remote_sendmap.setdefault(
                 "apple", set())
         apple_set.add(self.u_potato.domain)
@@ -259,7 +267,7 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
                         {"user_id": "@apple:test",
                          "presence": "online",
                          "state": "online",
-                         "mtime_age": 0,
+                         "last_active_ago": 0,
                          "displayname": "Frank",
                          "avatar_url": "http://foo"},
                     ],