mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 03:44:56 -04:00
Add type hints for tests/unittest.py
. (#12347)
In particular, add type hints for get_success and friends, which are then helpful in a bunch of places.
This commit is contained in:
parent
33ebee47e4
commit
f0b03186d9
12 changed files with 97 additions and 48 deletions
|
@ -1590,10 +1590,9 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
self.assertEqual("email", channel.json_body["threepids"][0]["medium"])
|
||||
self.assertEqual("bob@bob.bob", channel.json_body["threepids"][0]["address"])
|
||||
|
||||
pushers = self.get_success(
|
||||
self.store.get_pushers_by({"user_name": "@bob:test"})
|
||||
pushers = list(
|
||||
self.get_success(self.store.get_pushers_by({"user_name": "@bob:test"}))
|
||||
)
|
||||
pushers = list(pushers)
|
||||
self.assertEqual(len(pushers), 1)
|
||||
self.assertEqual("@bob:test", pushers[0].user_name)
|
||||
|
||||
|
@ -1632,10 +1631,9 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
self.assertEqual("email", channel.json_body["threepids"][0]["medium"])
|
||||
self.assertEqual("bob@bob.bob", channel.json_body["threepids"][0]["address"])
|
||||
|
||||
pushers = self.get_success(
|
||||
self.store.get_pushers_by({"user_name": "@bob:test"})
|
||||
pushers = list(
|
||||
self.get_success(self.store.get_pushers_by({"user_name": "@bob:test"}))
|
||||
)
|
||||
pushers = list(pushers)
|
||||
self.assertEqual(len(pushers), 0)
|
||||
|
||||
def test_set_password(self) -> None:
|
||||
|
@ -2144,6 +2142,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# is in user directory
|
||||
profile = self.get_success(self.store.get_user_in_directory(self.other_user))
|
||||
assert profile is not None
|
||||
self.assertTrue(profile["display_name"] == "User")
|
||||
|
||||
# Deactivate user
|
||||
|
@ -2711,6 +2710,7 @@ class PushersRestTestCase(unittest.HomeserverTestCase):
|
|||
user_tuple = self.get_success(
|
||||
self.store.get_user_by_access_token(other_user_token)
|
||||
)
|
||||
assert user_tuple is not None
|
||||
token_id = user_tuple.token_id
|
||||
|
||||
self.get_success(
|
||||
|
@ -3676,6 +3676,7 @@ class ShadowBanRestTestCase(unittest.HomeserverTestCase):
|
|||
# The user starts off as not shadow-banned.
|
||||
other_user_token = self.login("user", "pass")
|
||||
result = self.get_success(self.store.get_user_by_access_token(other_user_token))
|
||||
assert result is not None
|
||||
self.assertFalse(result.shadow_banned)
|
||||
|
||||
channel = self.make_request("POST", self.url, access_token=self.admin_user_tok)
|
||||
|
@ -3684,6 +3685,7 @@ class ShadowBanRestTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# Ensure the user is shadow-banned (and the cache was cleared).
|
||||
result = self.get_success(self.store.get_user_by_access_token(other_user_token))
|
||||
assert result is not None
|
||||
self.assertTrue(result.shadow_banned)
|
||||
|
||||
# Un-shadow-ban the user.
|
||||
|
@ -3695,6 +3697,7 @@ class ShadowBanRestTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# Ensure the user is no longer shadow-banned (and the cache was cleared).
|
||||
result = self.get_success(self.store.get_user_by_access_token(other_user_token))
|
||||
assert result is not None
|
||||
self.assertFalse(result.shadow_banned)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue