summary refs log tree commit diff
path: root/tests/api
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2022-02-28 17:40:24 +0000
committerGitHub <noreply@github.com>2022-02-28 17:40:24 +0000
commit6c0b44a3d73f73dc5913f081418347645dc84d6f (patch)
treec5f902578af302b30d2be221fea51c49731f5b32 /tests/api
parentActually fix bad debug logging rejecting device list & signing key transactio... (diff)
downloadsynapse-6c0b44a3d73f73dc5913f081418347645dc84d6f.tar.xz
Fix `PushRuleEvaluator` and `Filter` to work on frozendicts (#12100)
* Fix `PushRuleEvaluator` to work on frozendicts

frozendicts do not (necessarily) inherit from dict, so this needs to handle
them correctly.

* Fix event filtering for frozen events

Looks like this one was introduced by #11194.
Diffstat (limited to 'tests/api')
-rw-r--r--tests/api/test_filtering.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/api/test_filtering.py b/tests/api/test_filtering.py
index 2525018e95..8c3354ce3c 100644
--- a/tests/api/test_filtering.py
+++ b/tests/api/test_filtering.py
@@ -18,6 +18,7 @@
 from unittest.mock import patch
 
 import jsonschema
+from frozendict import frozendict
 
 from synapse.api.constants import EventContentFields
 from synapse.api.errors import SynapseError
@@ -327,6 +328,15 @@ class FilteringTestCase(unittest.HomeserverTestCase):
 
         self.assertFalse(Filter(self.hs, definition)._check(event))
 
+        # check it works with frozendicts too
+        event = MockEvent(
+            sender="@foo:bar",
+            type="m.room.message",
+            room_id="!secretbase:unknown",
+            content=frozendict({EventContentFields.LABELS: ["#fun"]}),
+        )
+        self.assertTrue(Filter(self.hs, definition)._check(event))
+
     def test_filter_not_labels(self):
         definition = {"org.matrix.not_labels": ["#fun"]}
         event = MockEvent(