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

Improve the tests for relations #12113

Merged
merged 9 commits into from
Mar 2, 2022
Next Next commit
Consistently use f-strings in relations tests and other minor improve…
…ments.

Via running:

    pyupgrade --py37-plus tests/rest/client/test_relations.py
clokep committed Mar 1, 2022
commit 3fd9ab254e17acd7f5c5480fe84cea0bf42318c5
23 changes: 9 additions & 14 deletions tests/rest/client/test_relations.py
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ def test_send_relation(self) -> None:

channel = self.make_request(
"GET",
"/rooms/%s/event/%s" % (self.room, event_id),
f"/rooms/{self.room}/event/{event_id}",
access_token=self.user_token,
)
self.assertEqual(200, channel.code, channel.json_body)
@@ -317,9 +317,7 @@ def test_pagination_from_sync_and_messages(self) -> None:

# Request /sync, limiting it such that only the latest event is returned
# (and not the relation).
filter = urllib.parse.quote_plus(
'{"room": {"timeline": {"limit": 1}}}'.encode()
)
filter = urllib.parse.quote_plus(b'{"room": {"timeline": {"limit": 1}}}')
channel = self.make_request(
"GET", f"/sync?filter={filter}", access_token=self.user_token
)
@@ -575,16 +573,15 @@ def test_aggregation_redactions(self) -> None:
# Now lets redact one of the 'a' reactions
channel = self.make_request(
"POST",
"/_matrix/client/r0/rooms/%s/redact/%s" % (self.room, to_redact_event_id),
f"/_matrix/client/r0/rooms/{self.room}/redact/{to_redact_event_id}",
access_token=self.user_token,
content={},
)
self.assertEqual(200, channel.code, channel.json_body)

channel = self.make_request(
"GET",
"/_matrix/client/unstable/rooms/%s/aggregations/%s"
% (self.room, self.parent_id),
f"/_matrix/client/unstable/rooms/{self.room}/aggregations/{self.parent_id}",
access_token=self.user_token,
)
self.assertEqual(200, channel.code, channel.json_body)
@@ -986,9 +983,7 @@ def assert_bundle(event_json: JsonDict) -> None:

# Request sync, but limit the timeline so it becomes limited (and includes
# bundled aggregations).
filter = urllib.parse.quote_plus(
'{"room": {"timeline": {"limit": 2}}}'.encode()
)
filter = urllib.parse.quote_plus(b'{"room": {"timeline": {"limit": 2}}}')
channel = self.make_request(
"GET", f"/sync?filter={filter}", access_token=self.user_token
)
@@ -1053,7 +1048,7 @@ def test_multi_edit(self) -> None:

channel = self.make_request(
"GET",
"/rooms/%s/event/%s" % (self.room, self.parent_id),
f"/rooms/{self.room}/event/{self.parent_id}",
access_token=self.user_token,
)
self.assertEqual(200, channel.code, channel.json_body)
@@ -1096,7 +1091,7 @@ def test_edit_reply(self) -> None:

channel = self.make_request(
"GET",
"/rooms/%s/event/%s" % (self.room, reply),
f"/rooms/{self.room}/event/{reply}",
access_token=self.user_token,
)
self.assertEqual(200, channel.code, channel.json_body)
@@ -1198,7 +1193,7 @@ def test_edit_edit(self) -> None:
# Request the original event.
channel = self.make_request(
"GET",
"/rooms/%s/event/%s" % (self.room, self.parent_id),
f"/rooms/{self.room}/event/{self.parent_id}",
access_token=self.user_token,
)
self.assertEqual(200, channel.code, channel.json_body)
@@ -1343,7 +1338,7 @@ def test_unknown_relations(self) -> None:
# When bundling the unknown relation is not included.
channel = self.make_request(
"GET",
"/rooms/%s/event/%s" % (self.room, self.parent_id),
f"/rooms/{self.room}/event/{self.parent_id}",
access_token=self.user_token,
)
self.assertEqual(200, channel.code, channel.json_body)