This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add type hints for tests/unittest.py
.
#12347
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
742ad07
Add some `assert is not None` checks
richvdh 9e96e2d
Avoid re-typing some variables
richvdh c708141
Avoid attempting to assign to an unmodifiable `Mapping`
richvdh d3ea7d9
Define and use `CustomHeaderType`
richvdh 3d3c60a
unittest.py: type fixes
richvdh 761ce3d
Typing for `unittest.py`
richvdh 7206cc6
changelog
richvdh 6ae780e
Update tests/unittest.py
richvdh 2eb9d33
fix imports
richvdh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add type annotations for `tests/unittest.py`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1590,10 +1590,9 @@ def test_create_user_email_notif_for_new_users(self) -> None: | |
self.assertEqual("email", channel.json_body["threepids"][0]["medium"]) | ||
self.assertEqual("[email protected]", 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 @@ def test_create_user_email_no_notif_for_new_users(self) -> None: | |
self.assertEqual("email", channel.json_body["threepids"][0]["medium"]) | ||
self.assertEqual("[email protected]", 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 @@ def test_change_name_deactivate_user_user_directory(self) -> None: | |
|
||
# 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 @@ def test_get_pushers(self) -> None: | |
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 @@ def test_success(self) -> None: | |
# 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 @@ def test_success(self) -> None: | |
|
||
# 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 @@ def test_success(self) -> None: | |
|
||
# 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) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it quite annoying that mypy doesn't handle
assertIs(Not)None
the same way...python/mypy#5088 for cross-refs.