summary refs log tree commit diff
path: root/tests/rest
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-01-27 13:03:31 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-01-27 13:03:31 +0000
commit39c1892b22012e20ce6f43e92b01f6fad780081d (patch)
tree9b2d03e6382a18d61b5ead4bda9291e63349b6c4 /tests/rest
parentInitial trivial REST test of v2_alpha filter API (diff)
downloadsynapse-39c1892b22012e20ce6f43e92b01f6fad780081d.tar.xz
Minor changes to v2_alpha filter REST test to allow the setUp method to be shareable
Diffstat (limited to 'tests/rest')
-rw-r--r--tests/rest/client/v2_alpha/test_filter.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/rest/client/v2_alpha/test_filter.py b/tests/rest/client/v2_alpha/test_filter.py
index 1d1273ab9a..91b19e88ff 100644
--- a/tests/rest/client/v2_alpha/test_filter.py
+++ b/tests/rest/client/v2_alpha/test_filter.py
@@ -25,11 +25,12 @@ from synapse.rest.client.v2_alpha import filter
 from synapse.types import UserID
 
 
-myid = "@apple:test"
 PATH_PREFIX = "/_matrix/client/v2_alpha"
 
 
 class FilterTestCase(unittest.TestCase):
+    USER_ID = "@apple:test"
+    TO_REGISTER = [filter]
 
     def setUp(self):
         self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
@@ -50,25 +51,26 @@ class FilterTestCase(unittest.TestCase):
 
         def _get_user_by_token(token=None):
             return {
-                "user": UserID.from_string(myid),
+                "user": UserID.from_string(self.USER_ID),
                 "admin": False,
                 "device_id": None,
             }
         hs.get_auth().get_user_by_token = _get_user_by_token
 
-        filter.register_servlets(hs, self.mock_resource)
+        for r in self.TO_REGISTER:
+            r.register_servlets(hs, self.mock_resource)
 
     @defer.inlineCallbacks
     def test_filter(self):
         (code, response) = yield self.mock_resource.trigger("POST",
-            "/user/%s/filter" % (myid),
+            "/user/%s/filter" % (self.USER_ID),
             '{"type": ["m.*"]}'
         )
         self.assertEquals(200, code)
         self.assertEquals({"filter_id": "0"}, response)
 
         (code, response) = yield self.mock_resource.trigger("GET",
-            "/user/%s/filter/0" % (myid), None
+            "/user/%s/filter/0" % (self.USER_ID), None
         )
         self.assertEquals(200, code)
         self.assertEquals({"type": ["m.*"]}, response)