mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 01:19:21 -05:00
[pyupgrade] tests/
(#10347)
This commit is contained in:
parent
879d8c1ee1
commit
89cfc3dd98
1
changelog.d/10347.misc
Normal file
1
changelog.d/10347.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Run `pyupgrade` on the codebase.
|
@ -43,7 +43,7 @@ class ConfigLoadingTestCase(unittest.TestCase):
|
|||||||
def test_generates_and_loads_macaroon_secret_key(self):
|
def test_generates_and_loads_macaroon_secret_key(self):
|
||||||
self.generate_config()
|
self.generate_config()
|
||||||
|
|
||||||
with open(self.file, "r") as f:
|
with open(self.file) as f:
|
||||||
raw = yaml.safe_load(f)
|
raw = yaml.safe_load(f)
|
||||||
self.assertIn("macaroon_secret_key", raw)
|
self.assertIn("macaroon_secret_key", raw)
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class ConfigLoadingTestCase(unittest.TestCase):
|
|||||||
def generate_config_and_remove_lines_containing(self, needle):
|
def generate_config_and_remove_lines_containing(self, needle):
|
||||||
self.generate_config()
|
self.generate_config()
|
||||||
|
|
||||||
with open(self.file, "r") as f:
|
with open(self.file) as f:
|
||||||
contents = f.readlines()
|
contents = f.readlines()
|
||||||
contents = [line for line in contents if needle not in line]
|
contents = [line for line in contents if needle not in line]
|
||||||
with open(self.file, "w") as f:
|
with open(self.file, "w") as f:
|
||||||
|
@ -103,7 +103,7 @@ class ProfileTestCase(unittest.HomeserverTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
(self.get_success(self.store.get_profile_displayname(self.frank.localpart)))
|
self.get_success(self.store.get_profile_displayname(self.frank.localpart))
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_set_my_name_if_disabled(self):
|
def test_set_my_name_if_disabled(self):
|
||||||
|
@ -273,7 +273,7 @@ class MatrixFederationAgentTests(unittest.TestCase):
|
|||||||
self.assertEqual(response.code, 200)
|
self.assertEqual(response.code, 200)
|
||||||
|
|
||||||
# Send the body
|
# Send the body
|
||||||
request.write('{ "a": 1 }'.encode("ascii"))
|
request.write(b'{ "a": 1 }')
|
||||||
request.finish()
|
request.finish()
|
||||||
|
|
||||||
self.reactor.pump((0.1,))
|
self.reactor.pump((0.1,))
|
||||||
|
@ -102,7 +102,7 @@ class FederationClientTests(HomeserverTestCase):
|
|||||||
self.assertNoResult(test_d)
|
self.assertNoResult(test_d)
|
||||||
|
|
||||||
# Send it the HTTP response
|
# Send it the HTTP response
|
||||||
res_json = '{ "a": 1 }'.encode("ascii")
|
res_json = b'{ "a": 1 }'
|
||||||
protocol.dataReceived(
|
protocol.dataReceived(
|
||||||
b"HTTP/1.1 200 OK\r\n"
|
b"HTTP/1.1 200 OK\r\n"
|
||||||
b"Server: Fake\r\n"
|
b"Server: Fake\r\n"
|
||||||
@ -339,10 +339,8 @@ class FederationClientTests(HomeserverTestCase):
|
|||||||
|
|
||||||
# Send it the HTTP response
|
# Send it the HTTP response
|
||||||
client.dataReceived(
|
client.dataReceived(
|
||||||
(
|
b"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n"
|
||||||
b"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n"
|
b"Server: Fake\r\n\r\n"
|
||||||
b"Server: Fake\r\n\r\n"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Push by enough to time it out
|
# Push by enough to time it out
|
||||||
|
@ -550,12 +550,12 @@ class FakeRedisPubSubProtocol(Protocol):
|
|||||||
if obj is None:
|
if obj is None:
|
||||||
return "$-1\r\n"
|
return "$-1\r\n"
|
||||||
if isinstance(obj, str):
|
if isinstance(obj, str):
|
||||||
return "${len}\r\n{str}\r\n".format(len=len(obj), str=obj)
|
return f"${len(obj)}\r\n{obj}\r\n"
|
||||||
if isinstance(obj, int):
|
if isinstance(obj, int):
|
||||||
return ":{val}\r\n".format(val=obj)
|
return f":{obj}\r\n"
|
||||||
if isinstance(obj, (list, tuple)):
|
if isinstance(obj, (list, tuple)):
|
||||||
items = "".join(self.encode(a) for a in obj)
|
items = "".join(self.encode(a) for a in obj)
|
||||||
return "*{len}\r\n{items}".format(len=len(obj), items=items)
|
return f"*{len(obj)}\r\n{items}"
|
||||||
|
|
||||||
raise Exception("Unrecognized type for encoding redis: %r: %r", type(obj), obj)
|
raise Exception("Unrecognized type for encoding redis: %r: %r", type(obj), obj)
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class MediaRepoShardTestCase(BaseMultiWorkerStreamTestCase):
|
|||||||
self.reactor,
|
self.reactor,
|
||||||
FakeSite(resource),
|
FakeSite(resource),
|
||||||
"GET",
|
"GET",
|
||||||
"/{}/{}".format(target, media_id),
|
f"/{target}/{media_id}",
|
||||||
shorthand=False,
|
shorthand=False,
|
||||||
access_token=self.access_token,
|
access_token=self.access_token,
|
||||||
await_result=False,
|
await_result=False,
|
||||||
@ -113,7 +113,7 @@ class MediaRepoShardTestCase(BaseMultiWorkerStreamTestCase):
|
|||||||
self.assertEqual(request.method, b"GET")
|
self.assertEqual(request.method, b"GET")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
request.path,
|
request.path,
|
||||||
"/_matrix/media/r0/download/{}/{}".format(target, media_id).encode("utf-8"),
|
f"/_matrix/media/r0/download/{target}/{media_id}".encode("utf-8"),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
request.requestHeaders.getRawHeaders(b"host"), [target.encode("utf-8")]
|
request.requestHeaders.getRawHeaders(b"host"), [target.encode("utf-8")]
|
||||||
|
@ -211,7 +211,7 @@ class EventPersisterShardTestCase(BaseMultiWorkerStreamTestCase):
|
|||||||
self.reactor,
|
self.reactor,
|
||||||
sync_hs_site,
|
sync_hs_site,
|
||||||
"GET",
|
"GET",
|
||||||
"/sync?since={}".format(next_batch),
|
f"/sync?since={next_batch}",
|
||||||
access_token=access_token,
|
access_token=access_token,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ class EventPersisterShardTestCase(BaseMultiWorkerStreamTestCase):
|
|||||||
self.reactor,
|
self.reactor,
|
||||||
sync_hs_site,
|
sync_hs_site,
|
||||||
"GET",
|
"GET",
|
||||||
"/sync?since={}".format(vector_clock_token),
|
f"/sync?since={vector_clock_token}",
|
||||||
access_token=access_token,
|
access_token=access_token,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ class EventPersisterShardTestCase(BaseMultiWorkerStreamTestCase):
|
|||||||
self.reactor,
|
self.reactor,
|
||||||
sync_hs_site,
|
sync_hs_site,
|
||||||
"GET",
|
"GET",
|
||||||
"/sync?since={}".format(next_batch),
|
f"/sync?since={next_batch}",
|
||||||
access_token=access_token,
|
access_token=access_token,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class DeleteGroupTestCase(unittest.HomeserverTestCase):
|
|||||||
# Create a new group
|
# Create a new group
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/create_group".encode("ascii"),
|
b"/create_group",
|
||||||
access_token=self.admin_user_tok,
|
access_token=self.admin_user_tok,
|
||||||
content={"localpart": "test"},
|
content={"localpart": "test"},
|
||||||
)
|
)
|
||||||
@ -129,9 +129,7 @@ class DeleteGroupTestCase(unittest.HomeserverTestCase):
|
|||||||
|
|
||||||
def _get_groups_user_is_in(self, access_token):
|
def _get_groups_user_is_in(self, access_token):
|
||||||
"""Returns the list of groups the user is in (given their access token)"""
|
"""Returns the list of groups the user is in (given their access token)"""
|
||||||
channel = self.make_request(
|
channel = self.make_request("GET", b"/joined_groups", access_token=access_token)
|
||||||
"GET", "/joined_groups".encode("ascii"), access_token=access_token
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||||
|
|
||||||
|
@ -535,7 +535,7 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(count, 0, msg="Rows not purged in {}".format(table))
|
self.assertEqual(count, 0, msg=f"Rows not purged in {table}")
|
||||||
|
|
||||||
def _assert_peek(self, room_id, expect_code):
|
def _assert_peek(self, room_id, expect_code):
|
||||||
"""Assert that the admin user can (or cannot) peek into the room."""
|
"""Assert that the admin user can (or cannot) peek into the room."""
|
||||||
@ -599,7 +599,7 @@ class PurgeRoomTestCase(unittest.HomeserverTestCase):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(count, 0, msg="Rows not purged in {}".format(table))
|
self.assertEqual(count, 0, msg=f"Rows not purged in {table}")
|
||||||
|
|
||||||
|
|
||||||
class RoomTestCase(unittest.HomeserverTestCase):
|
class RoomTestCase(unittest.HomeserverTestCase):
|
||||||
@ -1280,7 +1280,7 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||||||
self.public_room_id = self.helper.create_room_as(
|
self.public_room_id = self.helper.create_room_as(
|
||||||
self.creator, tok=self.creator_tok, is_public=True
|
self.creator, tok=self.creator_tok, is_public=True
|
||||||
)
|
)
|
||||||
self.url = "/_synapse/admin/v1/join/{}".format(self.public_room_id)
|
self.url = f"/_synapse/admin/v1/join/{self.public_room_id}"
|
||||||
|
|
||||||
def test_requester_is_no_admin(self):
|
def test_requester_is_no_admin(self):
|
||||||
"""
|
"""
|
||||||
@ -1420,7 +1420,7 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||||||
private_room_id = self.helper.create_room_as(
|
private_room_id = self.helper.create_room_as(
|
||||||
self.creator, tok=self.creator_tok, is_public=False
|
self.creator, tok=self.creator_tok, is_public=False
|
||||||
)
|
)
|
||||||
url = "/_synapse/admin/v1/join/{}".format(private_room_id)
|
url = f"/_synapse/admin/v1/join/{private_room_id}"
|
||||||
body = json.dumps({"user_id": self.second_user_id})
|
body = json.dumps({"user_id": self.second_user_id})
|
||||||
|
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
@ -1463,7 +1463,7 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||||||
|
|
||||||
# Join user to room.
|
# Join user to room.
|
||||||
|
|
||||||
url = "/_synapse/admin/v1/join/{}".format(private_room_id)
|
url = f"/_synapse/admin/v1/join/{private_room_id}"
|
||||||
body = json.dumps({"user_id": self.second_user_id})
|
body = json.dumps({"user_id": self.second_user_id})
|
||||||
|
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
@ -1493,7 +1493,7 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||||||
private_room_id = self.helper.create_room_as(
|
private_room_id = self.helper.create_room_as(
|
||||||
self.admin_user, tok=self.admin_user_tok, is_public=False
|
self.admin_user, tok=self.admin_user_tok, is_public=False
|
||||||
)
|
)
|
||||||
url = "/_synapse/admin/v1/join/{}".format(private_room_id)
|
url = f"/_synapse/admin/v1/join/{private_room_id}"
|
||||||
body = json.dumps({"user_id": self.second_user_id})
|
body = json.dumps({"user_id": self.second_user_id})
|
||||||
|
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
@ -1633,7 +1633,7 @@ class MakeRoomAdminTestCase(unittest.HomeserverTestCase):
|
|||||||
|
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/_synapse/admin/v1/rooms/{}/make_room_admin".format(room_id),
|
f"/_synapse/admin/v1/rooms/{room_id}/make_room_admin",
|
||||||
content={},
|
content={},
|
||||||
access_token=self.admin_user_tok,
|
access_token=self.admin_user_tok,
|
||||||
)
|
)
|
||||||
@ -1660,7 +1660,7 @@ class MakeRoomAdminTestCase(unittest.HomeserverTestCase):
|
|||||||
|
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/_synapse/admin/v1/rooms/{}/make_room_admin".format(room_id),
|
f"/_synapse/admin/v1/rooms/{room_id}/make_room_admin",
|
||||||
content={},
|
content={},
|
||||||
access_token=self.admin_user_tok,
|
access_token=self.admin_user_tok,
|
||||||
)
|
)
|
||||||
@ -1686,7 +1686,7 @@ class MakeRoomAdminTestCase(unittest.HomeserverTestCase):
|
|||||||
|
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/_synapse/admin/v1/rooms/{}/make_room_admin".format(room_id),
|
f"/_synapse/admin/v1/rooms/{room_id}/make_room_admin",
|
||||||
content={"user_id": self.second_user_id},
|
content={"user_id": self.second_user_id},
|
||||||
access_token=self.admin_user_tok,
|
access_token=self.admin_user_tok,
|
||||||
)
|
)
|
||||||
@ -1720,7 +1720,7 @@ class MakeRoomAdminTestCase(unittest.HomeserverTestCase):
|
|||||||
|
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/_synapse/admin/v1/rooms/{}/make_room_admin".format(room_id),
|
f"/_synapse/admin/v1/rooms/{room_id}/make_room_admin",
|
||||||
content={},
|
content={},
|
||||||
access_token=self.admin_user_tok,
|
access_token=self.admin_user_tok,
|
||||||
)
|
)
|
||||||
|
@ -1206,7 +1206,7 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||||||
reason = "hello"
|
reason = "hello"
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/_matrix/client/r0/rooms/{}/join".format(self.room_id),
|
f"/_matrix/client/r0/rooms/{self.room_id}/join",
|
||||||
content={"reason": reason},
|
content={"reason": reason},
|
||||||
access_token=self.second_tok,
|
access_token=self.second_tok,
|
||||||
)
|
)
|
||||||
@ -1220,7 +1220,7 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||||||
reason = "hello"
|
reason = "hello"
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/_matrix/client/r0/rooms/{}/leave".format(self.room_id),
|
f"/_matrix/client/r0/rooms/{self.room_id}/leave",
|
||||||
content={"reason": reason},
|
content={"reason": reason},
|
||||||
access_token=self.second_tok,
|
access_token=self.second_tok,
|
||||||
)
|
)
|
||||||
@ -1234,7 +1234,7 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||||||
reason = "hello"
|
reason = "hello"
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/_matrix/client/r0/rooms/{}/kick".format(self.room_id),
|
f"/_matrix/client/r0/rooms/{self.room_id}/kick",
|
||||||
content={"reason": reason, "user_id": self.second_user_id},
|
content={"reason": reason, "user_id": self.second_user_id},
|
||||||
access_token=self.second_tok,
|
access_token=self.second_tok,
|
||||||
)
|
)
|
||||||
@ -1248,7 +1248,7 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||||||
reason = "hello"
|
reason = "hello"
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/_matrix/client/r0/rooms/{}/ban".format(self.room_id),
|
f"/_matrix/client/r0/rooms/{self.room_id}/ban",
|
||||||
content={"reason": reason, "user_id": self.second_user_id},
|
content={"reason": reason, "user_id": self.second_user_id},
|
||||||
access_token=self.creator_tok,
|
access_token=self.creator_tok,
|
||||||
)
|
)
|
||||||
@ -1260,7 +1260,7 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||||||
reason = "hello"
|
reason = "hello"
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/_matrix/client/r0/rooms/{}/unban".format(self.room_id),
|
f"/_matrix/client/r0/rooms/{self.room_id}/unban",
|
||||||
content={"reason": reason, "user_id": self.second_user_id},
|
content={"reason": reason, "user_id": self.second_user_id},
|
||||||
access_token=self.creator_tok,
|
access_token=self.creator_tok,
|
||||||
)
|
)
|
||||||
@ -1272,7 +1272,7 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||||||
reason = "hello"
|
reason = "hello"
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/_matrix/client/r0/rooms/{}/invite".format(self.room_id),
|
f"/_matrix/client/r0/rooms/{self.room_id}/invite",
|
||||||
content={"reason": reason, "user_id": self.second_user_id},
|
content={"reason": reason, "user_id": self.second_user_id},
|
||||||
access_token=self.creator_tok,
|
access_token=self.creator_tok,
|
||||||
)
|
)
|
||||||
@ -1291,7 +1291,7 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||||||
reason = "hello"
|
reason = "hello"
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST",
|
"POST",
|
||||||
"/_matrix/client/r0/rooms/{}/leave".format(self.room_id),
|
f"/_matrix/client/r0/rooms/{self.room_id}/leave",
|
||||||
content={"reason": reason},
|
content={"reason": reason},
|
||||||
access_token=self.second_tok,
|
access_token=self.second_tok,
|
||||||
)
|
)
|
||||||
|
@ -273,7 +273,7 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||||||
|
|
||||||
prev_token = None
|
prev_token = None
|
||||||
found_event_ids = []
|
found_event_ids = []
|
||||||
encoded_key = urllib.parse.quote_plus("👍".encode("utf-8"))
|
encoded_key = urllib.parse.quote_plus("👍".encode())
|
||||||
for _ in range(20):
|
for _ in range(20):
|
||||||
from_token = ""
|
from_token = ""
|
||||||
if prev_token:
|
if prev_token:
|
||||||
|
@ -41,7 +41,7 @@ class ReportEventTestCase(unittest.HomeserverTestCase):
|
|||||||
self.helper.join(self.room_id, user=self.admin_user, tok=self.admin_user_tok)
|
self.helper.join(self.room_id, user=self.admin_user, tok=self.admin_user_tok)
|
||||||
resp = self.helper.send(self.room_id, tok=self.admin_user_tok)
|
resp = self.helper.send(self.room_id, tok=self.admin_user_tok)
|
||||||
self.event_id = resp["event_id"]
|
self.event_id = resp["event_id"]
|
||||||
self.report_path = "rooms/{}/report/{}".format(self.room_id, self.event_id)
|
self.report_path = f"rooms/{self.room_id}/report/{self.event_id}"
|
||||||
|
|
||||||
def test_reason_str_and_score_int(self):
|
def test_reason_str_and_score_int(self):
|
||||||
data = {"reason": "this makes me sad", "score": -100}
|
data = {"reason": "this makes me sad", "score": -100}
|
||||||
|
@ -310,7 +310,7 @@ class MediaRepoTests(unittest.HomeserverTestCase):
|
|||||||
correctly decode it as the UTF-8 string, and use filename* in the
|
correctly decode it as the UTF-8 string, and use filename* in the
|
||||||
response.
|
response.
|
||||||
"""
|
"""
|
||||||
filename = parse.quote("\u2603".encode("utf8")).encode("ascii")
|
filename = parse.quote("\u2603".encode()).encode("ascii")
|
||||||
channel = self._req(
|
channel = self._req(
|
||||||
b"inline; filename*=utf-8''" + filename + self.test_image.extension
|
b"inline; filename*=utf-8''" + filename + self.test_image.extension
|
||||||
)
|
)
|
||||||
|
@ -59,5 +59,5 @@ class DirectoryStoreTestCase(HomeserverTestCase):
|
|||||||
self.assertEqual(self.room.to_string(), room_id)
|
self.assertEqual(self.room.to_string(), room_id)
|
||||||
|
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
(self.get_success(self.store.get_association_from_room_alias(self.alias)))
|
self.get_success(self.store.get_association_from_room_alias(self.alias))
|
||||||
)
|
)
|
||||||
|
@ -45,11 +45,7 @@ class ProfileStoreTestCase(unittest.HomeserverTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
(
|
self.get_success(self.store.get_profile_displayname(self.u_frank.localpart))
|
||||||
self.get_success(
|
|
||||||
self.store.get_profile_displayname(self.u_frank.localpart)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_avatar_url(self):
|
def test_avatar_url(self):
|
||||||
@ -76,9 +72,5 @@ class ProfileStoreTestCase(unittest.HomeserverTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
(
|
self.get_success(self.store.get_profile_avatar_url(self.u_frank.localpart))
|
||||||
self.get_success(
|
|
||||||
self.store.get_profile_avatar_url(self.u_frank.localpart)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
@ -75,7 +75,7 @@ class PurgeTests(HomeserverTestCase):
|
|||||||
token = self.get_success(
|
token = self.get_success(
|
||||||
self.store.get_topological_token_for_event(last["event_id"])
|
self.store.get_topological_token_for_event(last["event_id"])
|
||||||
)
|
)
|
||||||
event = "t{}-{}".format(token.topological + 1, token.stream + 1)
|
event = f"t{token.topological + 1}-{token.stream + 1}"
|
||||||
|
|
||||||
# Purge everything before this topological token
|
# Purge everything before this topological token
|
||||||
f = self.get_failure(
|
f = self.get_failure(
|
||||||
|
@ -49,7 +49,7 @@ class RoomStoreTestCase(HomeserverTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_room_unknown_room(self):
|
def test_get_room_unknown_room(self):
|
||||||
self.assertIsNone((self.get_success(self.store.get_room("!uknown:test"))))
|
self.assertIsNone(self.get_success(self.store.get_room("!uknown:test")))
|
||||||
|
|
||||||
def test_get_room_with_stats(self):
|
def test_get_room_with_stats(self):
|
||||||
self.assertDictContainsSubset(
|
self.assertDictContainsSubset(
|
||||||
|
@ -103,6 +103,4 @@ class MapUsernameTestCase(unittest.TestCase):
|
|||||||
def testNonAscii(self):
|
def testNonAscii(self):
|
||||||
# this should work with either a unicode or a bytes
|
# this should work with either a unicode or a bytes
|
||||||
self.assertEqual(map_username_to_mxid_localpart("têst"), "t=c3=aast")
|
self.assertEqual(map_username_to_mxid_localpart("têst"), "t=c3=aast")
|
||||||
self.assertEqual(
|
self.assertEqual(map_username_to_mxid_localpart("têst".encode()), "t=c3=aast")
|
||||||
map_username_to_mxid_localpart("têst".encode("utf-8")), "t=c3=aast"
|
|
||||||
)
|
|
||||||
|
@ -140,7 +140,7 @@ class TestCase(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
self.assertEquals(attrs[key], getattr(obj, key))
|
self.assertEquals(attrs[key], getattr(obj, key))
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
raise (type(e))("Assert error for '.{}':".format(key)) from e
|
raise (type(e))(f"Assert error for '.{key}':") from e
|
||||||
|
|
||||||
def assert_dict(self, required, actual):
|
def assert_dict(self, required, actual):
|
||||||
"""Does a partial assert of a dict.
|
"""Does a partial assert of a dict.
|
||||||
|
Loading…
Reference in New Issue
Block a user