summary refs log tree commit diff
path: root/tests/replication/slave/storage
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2016-04-21 15:25:47 +0100
committerMark Haines <mjark@negativecurvature.net>2016-04-21 15:25:58 +0100
commitc0d8e0eb6375d5b8754db420af43733a642c7f38 (patch)
treece92ec5a23e4fe26fb217a4ef24290fafae567c1 /tests/replication/slave/storage
parentMerge pull request #740 from matrix-org/erikj/state_cache (diff)
downloadsynapse-c0d8e0eb6375d5b8754db420af43733a642c7f38.tar.xz
Replicate push actions
Diffstat (limited to 'tests/replication/slave/storage')
-rw-r--r--tests/replication/slave/storage/test_events.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/replication/slave/storage/test_events.py b/tests/replication/slave/storage/test_events.py
index 41a626cf70..17587fda00 100644
--- a/tests/replication/slave/storage/test_events.py
+++ b/tests/replication/slave/storage/test_events.py
@@ -266,6 +266,47 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase):
             event.internal_metadata.stream_ordering
         )])
 
+    @defer.inlineCallbacks
+    def test_push_actions_for_user(self):
+        yield self.persist(type="m.room.create", creator=USER_ID)
+        yield self.persist(type="m.room.join", key=USER_ID, membership="join")
+        yield self.persist(
+            type="m.room.join", sender=USER_ID, key=USER_ID_2, membership="join"
+        )
+        event1 = yield self.persist(
+            type="m.room.message", msgtype="m.text", body="hello"
+        )
+        yield self.replicate()
+        yield self.check(
+            "get_unread_event_push_actions_by_room_for_user",
+            [ROOM_ID, USER_ID_2, event1.event_id],
+            {"highlight_count": 0, "notify_count": 0}
+        )
+
+        yield self.persist(
+            type="m.room.message", msgtype="m.text", body="world",
+            push_actions=[(USER_ID_2, ["notify"])],
+        )
+        yield self.replicate()
+        yield self.check(
+            "get_unread_event_push_actions_by_room_for_user",
+            [ROOM_ID, USER_ID_2, event1.event_id],
+            {"highlight_count": 0, "notify_count": 1}
+        )
+
+        yield self.persist(
+            type="m.room.message", msgtype="m.text", body="world",
+            push_actions=[(USER_ID_2, [
+                "notify", {"set_tweak": "highlight", "value": True}
+            ])],
+        )
+        yield self.replicate()
+        yield self.check(
+            "get_unread_event_push_actions_by_room_for_user",
+            [ROOM_ID, USER_ID_2, event1.event_id],
+            {"highlight_count": 1, "notify_count": 2}
+        )
+
     event_id = 0
 
     @defer.inlineCallbacks
@@ -273,6 +314,7 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase):
         self, sender=USER_ID, room_id=ROOM_ID, type={}, key=None, internal={},
         state=None, reset_state=False, backfill=False,
         depth=None, prev_events=[], auth_events=[], prev_state=[], redacts=None,
+        push_actions=[],
         **content
     ):
         """
@@ -305,6 +347,7 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase):
         self.event_id += 1
 
         context = EventContext(current_state=state)
+        context.push_actions = push_actions
 
         ordering = None
         if backfill: