summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorpik <alexander.maznev@gmail.com>2017-03-23 11:42:41 -0300
committerpik <alexander.maznev@gmail.com>2017-03-23 11:42:41 -0300
commit566641a0b5f04e444383d5e3a5493b22e551ff03 (patch)
tree61691bbc1bcc79c9a824dcdaf626cbd15adae97e /tests
parentAdd valid filter tests, flake8, fix typo (diff)
downloadsynapse-566641a0b5f04e444383d5e3a5493b22e551ff03.tar.xz
use jsonschema.FormatChecker for RoomID and UserID strings
 * use a valid filter in rest/client/v2_alpha test

Signed-off-by: pik <alexander.maznev@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/api/test_filtering.py15
-rw-r--r--tests/rest/client/v2_alpha/test_filter.py4
2 files changed, 13 insertions, 6 deletions
diff --git a/tests/api/test_filtering.py b/tests/api/test_filtering.py
index 1ce1acb3cf..dcceca7f3e 100644
--- a/tests/api/test_filtering.py
+++ b/tests/api/test_filtering.py
@@ -25,6 +25,8 @@ from synapse.api.filtering import Filter
 from synapse.events import FrozenEvent
 from synapse.api.errors import SynapseError
 
+import jsonschema
+
 user_localpart = "test_user"
 
 
@@ -61,7 +63,9 @@ class FilteringTestCase(unittest.TestCase):
             {"account_data": "Hello World"},
             {"event_fields": ["\\foo"]},
             {"room": {"timeline": {"limit": 0}, "state": {"not_bars": ["*"]}}},
-            {"event_format": "other"}
+            {"event_format": "other"},
+            {"room": {"not_rooms": ["#foo:pik-test"]}},
+            {"presence": {"senders": ["@bar;pik.test.com"]}}
         ]
         for filter in invalid_filters:
             with self.assertRaises(SynapseError) as check_filter_error:
@@ -76,8 +80,8 @@ class FilteringTestCase(unittest.TestCase):
                     "state": {"not_types": ["m.room.member"]},
                     "ephemeral": {"limit": 0, "not_types": ["*"]},
                     "include_leave": False,
-                    "rooms": ["#dee:pik-test"],
-                    "not_rooms": ["#gee:pik-test"],
+                    "rooms": ["!dee:pik-test"],
+                    "not_rooms": ["!gee:pik-test"],
                     "account_data": {"limit": 0, "types": ["*"]}
                 }
             },
@@ -108,7 +112,10 @@ class FilteringTestCase(unittest.TestCase):
             }
         ]
         for filter in valid_filters:
-            self.filtering.check_valid_filter(filter)
+            try:
+                self.filtering.check_valid_filter(filter)
+            except jsonschema.ValidationError as e:
+                self.fail(e)
 
     def test_limits_are_applied(self):
         # TODO
diff --git a/tests/rest/client/v2_alpha/test_filter.py b/tests/rest/client/v2_alpha/test_filter.py
index 3d27d03cbf..76b833e119 100644
--- a/tests/rest/client/v2_alpha/test_filter.py
+++ b/tests/rest/client/v2_alpha/test_filter.py
@@ -33,8 +33,8 @@ PATH_PREFIX = "/_matrix/client/v2_alpha"
 class FilterTestCase(unittest.TestCase):
 
     USER_ID = "@apple:test"
-    EXAMPLE_FILTER = {"type": ["m.*"]}
-    EXAMPLE_FILTER_JSON = '{"type": ["m.*"]}'
+    EXAMPLE_FILTER = {"room": {"timeline": {"types": ["m.room.message"]}}}
+    EXAMPLE_FILTER_JSON = '{"room": {"timeline": {"types": ["m.room.message"]}}}'
     TO_REGISTER = [filter]
 
     @defer.inlineCallbacks