diff --git a/tests/rest/client/test_account.py b/tests/rest/client/test_account.py
index a43a137273..1f9b65351e 100644
--- a/tests/rest/client/test_account.py
+++ b/tests/rest/client/test_account.py
@@ -949,7 +949,7 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
client_secret: str,
next_link: Optional[str] = None,
expect_code: int = 200,
- ) -> str:
+ ) -> Optional[str]:
"""Request a validation token to add an email address to a user's account
Args:
@@ -959,7 +959,8 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
expect_code: Expected return code of the call
Returns:
- The ID of the new threepid validation session
+ The ID of the new threepid validation session, or None if the response
+ did not contain a session ID.
"""
body = {"client_secret": client_secret, "email": email, "send_attempt": 1}
if next_link:
diff --git a/tests/rest/client/test_profile.py b/tests/rest/client/test_profile.py
index 29bed0e872..8de5a342ae 100644
--- a/tests/rest/client/test_profile.py
+++ b/tests/rest/client/test_profile.py
@@ -153,18 +153,22 @@ class ProfileTestCase(unittest.HomeserverTestCase):
)
self.assertEqual(channel.code, 400, channel.result)
- def _get_displayname(self, name: Optional[str] = None) -> str:
+ def _get_displayname(self, name: Optional[str] = None) -> Optional[str]:
channel = self.make_request(
"GET", "/profile/%s/displayname" % (name or self.owner,)
)
self.assertEqual(channel.code, 200, channel.result)
- return channel.json_body["displayname"]
+ # FIXME: If a user has no displayname set, Synapse returns 200 and omits a
+ # displayname from the response. This contradicts the spec, see #13137.
+ return channel.json_body.get("displayname")
- def _get_avatar_url(self, name: Optional[str] = None) -> str:
+ def _get_avatar_url(self, name: Optional[str] = None) -> Optional[str]:
channel = self.make_request(
"GET", "/profile/%s/avatar_url" % (name or self.owner,)
)
self.assertEqual(channel.code, 200, channel.result)
+ # FIXME: If a user has no avatar set, Synapse returns 200 and omits an
+ # avatar_url from the response. This contradicts the spec, see #13137.
return channel.json_body.get("avatar_url")
@unittest.override_config({"max_avatar_size": 50})
diff --git a/tests/rest/client/test_relations.py b/tests/rest/client/test_relations.py
index aa84906548..ad03eee17b 100644
--- a/tests/rest/client/test_relations.py
+++ b/tests/rest/client/test_relations.py
@@ -800,7 +800,7 @@ class RelationPaginationTestCase(BaseRelationsTestCase):
)
expected_event_ids.append(channel.json_body["event_id"])
- prev_token = ""
+ prev_token: Optional[str] = ""
found_event_ids: List[str] = []
for _ in range(20):
from_token = ""
|