summary refs log tree commit diff
path: root/tests/api
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2016-02-19 17:46:58 +0000
committerMark Haines <mark.haines@matrix.org>2016-02-19 17:55:28 +0000
commit5c79ef9396ffc1212676610d4bb9df00f1361126 (patch)
tree71118eeeb9322e6a581546b19da2aa1c518e9ae4 /tests/api
parentMerge pull request #590 from matrix-org/markjh/formatting (diff)
downloadsynapse-5c79ef9396ffc1212676610d4bb9df00f1361126.tar.xz
Test Filter.filter_rooms
Also check that the __repr__ method for FilterCollection does something
sensible.
Diffstat (limited to 'tests/api')
-rw-r--r--tests/api/test_filtering.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/api/test_filtering.py b/tests/api/test_filtering.py
index 4297a89f85..dcb6c5bc31 100644
--- a/tests/api/test_filtering.py
+++ b/tests/api/test_filtering.py
@@ -456,6 +456,22 @@ class FilteringTestCase(unittest.TestCase):
         results = user_filter.filter_room_state(events)
         self.assertEquals([], results)
 
+    def test_filter_rooms(self):
+        definition = {
+            "rooms": ["!allowed:example.com", "!excluded:example.com"],
+            "not_rooms": ["!excluded:example.com"],
+        }
+
+        room_ids = [
+            "!allowed:example.com",  # Allowed because in rooms and not in not_rooms.
+            "!excluded:example.com",  # Disallowed because in not_rooms.
+            "!not_included:example.com",  # Disallowed because not in rooms.
+        ]
+
+        filtered_room_ids = list(Filter(definition).filter_rooms(room_ids))
+
+        self.assertEquals(filtered_room_ids, ["!allowed:example.com"])
+
     @defer.inlineCallbacks
     def test_add_filter(self):
         user_filter_json = {
@@ -500,3 +516,5 @@ class FilteringTestCase(unittest.TestCase):
         )
 
         self.assertEquals(filter.get_filter_json(), user_filter_json)
+
+        self.assertRegexpMatches(repr(filter), r"<FilterCollection \{.*\}>")