summary refs log tree commit diff
path: root/tests/api
diff options
context:
space:
mode:
authorpik <alexander.maznev@gmail.com>2017-03-23 11:42:07 -0300
committerpik <alexander.maznev@gmail.com>2017-03-23 11:42:07 -0300
commite56c79c114db2332a25dbf4b95c351a4d2684771 (patch)
tree36c5d4276d5ad89b3bef566d174aa9b2da4bfe1d /tests/api
parentMerge pull request #2005 from kfatehi/docs/readme (diff)
downloadsynapse-e56c79c114db2332a25dbf4b95c351a4d2684771.tar.xz
check_valid_filter using JSONSchema
 * add invalid filter tests

Signed-off-by: pik <alexander.maznev@gmail.com>
Diffstat (limited to 'tests/api')
-rw-r--r--tests/api/test_filtering.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/api/test_filtering.py b/tests/api/test_filtering.py
index 50e8607c14..ce4116ff56 100644
--- a/tests/api/test_filtering.py
+++ b/tests/api/test_filtering.py
@@ -23,6 +23,7 @@ from tests.utils import (
 
 from synapse.api.filtering import Filter
 from synapse.events import FrozenEvent
+from synapse.api.errors import SynapseError
 
 user_localpart = "test_user"
 
@@ -34,7 +35,6 @@ def MockEvent(**kwargs):
         kwargs["type"] = "fake_type"
     return FrozenEvent(kwargs)
 
-
 class FilteringTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
@@ -54,6 +54,22 @@ class FilteringTestCase(unittest.TestCase):
 
         self.datastore = hs.get_datastore()
 
+    def test_errors_on_invalid_filters(self):
+        invalid_filters = [
+            { "boom": {} },
+            { "account_data": "Hello World" },
+            { "event_fields": ["\\foo"] },
+            { "room": { "timeline" : { "limit" : 0 }, "state": { "not_bars": ["*"]} } },
+        ]
+        for filter in invalid_filters:
+            with self.assertRaises(SynapseError) as check_filter_error:
+                self.filtering.check_valid_filter(filter)
+                self.assertIsInstance(check_filter_error.exception, SynapseError)
+
+    def test_limits_are_applied(self):
+        #TODO
+        pass
+
     def test_definition_types_works_with_literals(self):
         definition = {
             "types": ["m.room.message", "org.matrix.foo.bar"]