Add get_state method to test RestHelper

pull/7230/head
Andrew Morgan 2020-04-07 12:35:43 +01:00
parent 9c8582dffe
commit 2facfc534c
1 changed files with 8 additions and 2 deletions
tests/rest/client/v1

View File

@ -142,7 +142,7 @@ class RestHelper(object):
return channel.json_body
def send_state(self, room_id, event_type, body, tok, expect_code=200, state_key=""):
def _read_write_state(self, room_id, event_type, body, tok, expect_code=200, state_key="", method="GET"):
path = "/_matrix/client/r0/rooms/%s/state/%s/%s" % (
room_id,
event_type,
@ -152,7 +152,7 @@ class RestHelper(object):
path = path + "?access_token=%s" % tok
request, channel = make_request(
self.hs.get_reactor(), "PUT", path, json.dumps(body).encode("utf8")
self.hs.get_reactor(), method, path, json.dumps(body).encode("utf8")
)
render(request, self.resource, self.hs.get_reactor())
@ -163,6 +163,12 @@ class RestHelper(object):
return channel.json_body
def get_state(self, room_id, event_type, tok, expect_code=200, state_key=""):
return self._read_write_state(room_id, event_type, {}, tok, expect_code, state_key, method="GET")
def send_state(self, room_id, event_type, body, tok, expect_code=200, state_key=""):
return self._read_write_state(room_id, event_type, body, tok, expect_code, state_key, method="PUT")
def upload_media(
self,
resource: Resource,