Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 41cdb80

Browse files
committed
Add a redaction helper for tests
1 parent 3af20ea commit 41cdb80

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/rest/client/v1/utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,28 @@ def send_event(
143143

144144
return channel.json_body
145145

146+
def redact(
147+
self, room_id, event_id, txn_id=None, tok=None, expect_code=200
148+
):
149+
if txn_id is None:
150+
txn_id = "m%s" % (str(time.time()))
151+
152+
path = "/_matrix/client/r0/rooms/%s/redact/%s/%s" % (room_id, event_id, txn_id)
153+
if tok:
154+
path = path + "?access_token=%s" % tok
155+
156+
request, channel = make_request(
157+
self.hs.get_reactor(), "PUT", path, json.dumps({}).encode("utf8")
158+
)
159+
render(request, self.resource, self.hs.get_reactor())
160+
161+
assert int(channel.result["code"]) == expect_code, (
162+
"Expected: %d, got: %d, resp: %r"
163+
% (expect_code, int(channel.result["code"]), channel.result["body"])
164+
)
165+
166+
return channel.json_body
167+
146168
def _read_write_state(
147169
self,
148170
room_id: str,

0 commit comments

Comments
 (0)