mirror of
https://mau.dev/maunium/synapse.git
synced 2024-09-05 09:02:13 +00:00
Minor changes to v2_alpha filter REST test to allow the setUp method to be shareable
This commit is contained in:
parent
37b8a71f10
commit
39c1892b22
@ -25,11 +25,12 @@ from synapse.rest.client.v2_alpha import filter
|
|||||||
from synapse.types import UserID
|
from synapse.types import UserID
|
||||||
|
|
||||||
|
|
||||||
myid = "@apple:test"
|
|
||||||
PATH_PREFIX = "/_matrix/client/v2_alpha"
|
PATH_PREFIX = "/_matrix/client/v2_alpha"
|
||||||
|
|
||||||
|
|
||||||
class FilterTestCase(unittest.TestCase):
|
class FilterTestCase(unittest.TestCase):
|
||||||
|
USER_ID = "@apple:test"
|
||||||
|
TO_REGISTER = [filter]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
|
self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
|
||||||
@ -50,25 +51,26 @@ class FilterTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def _get_user_by_token(token=None):
|
def _get_user_by_token(token=None):
|
||||||
return {
|
return {
|
||||||
"user": UserID.from_string(myid),
|
"user": UserID.from_string(self.USER_ID),
|
||||||
"admin": False,
|
"admin": False,
|
||||||
"device_id": None,
|
"device_id": None,
|
||||||
}
|
}
|
||||||
hs.get_auth().get_user_by_token = _get_user_by_token
|
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
|
@defer.inlineCallbacks
|
||||||
def test_filter(self):
|
def test_filter(self):
|
||||||
(code, response) = yield self.mock_resource.trigger("POST",
|
(code, response) = yield self.mock_resource.trigger("POST",
|
||||||
"/user/%s/filter" % (myid),
|
"/user/%s/filter" % (self.USER_ID),
|
||||||
'{"type": ["m.*"]}'
|
'{"type": ["m.*"]}'
|
||||||
)
|
)
|
||||||
self.assertEquals(200, code)
|
self.assertEquals(200, code)
|
||||||
self.assertEquals({"filter_id": "0"}, response)
|
self.assertEquals({"filter_id": "0"}, response)
|
||||||
|
|
||||||
(code, response) = yield self.mock_resource.trigger("GET",
|
(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(200, code)
|
||||||
self.assertEquals({"type": ["m.*"]}, response)
|
self.assertEquals({"type": ["m.*"]}, response)
|
||||||
|
Loading…
Reference in New Issue
Block a user