mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-06 12:05:03 -04:00
Add more missing type hints to tests. (#15028)
This commit is contained in:
parent
4eed7b2ede
commit
30509a1010
14 changed files with 124 additions and 111 deletions
|
@ -14,7 +14,7 @@
|
|||
|
||||
|
||||
import json
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
from typing import Any, ContextManager, Dict, List, Optional, Tuple
|
||||
from unittest.mock import Mock, patch
|
||||
from urllib.parse import parse_qs
|
||||
|
||||
|
@ -77,14 +77,14 @@ class FakeOidcServer:
|
|||
|
||||
self._id_token_overrides: Dict[str, Any] = {}
|
||||
|
||||
def reset_mocks(self):
|
||||
def reset_mocks(self) -> None:
|
||||
self.request.reset_mock()
|
||||
self.get_jwks_handler.reset_mock()
|
||||
self.get_metadata_handler.reset_mock()
|
||||
self.get_userinfo_handler.reset_mock()
|
||||
self.post_token_handler.reset_mock()
|
||||
|
||||
def patch_homeserver(self, hs: HomeServer):
|
||||
def patch_homeserver(self, hs: HomeServer) -> ContextManager[Mock]:
|
||||
"""Patch the ``HomeServer`` HTTP client to handle requests through the ``FakeOidcServer``.
|
||||
|
||||
This patch should be used whenever the HS is expected to perform request to the
|
||||
|
@ -188,7 +188,7 @@ class FakeOidcServer:
|
|||
|
||||
return self._sign(logout_token)
|
||||
|
||||
def id_token_override(self, overrides: dict):
|
||||
def id_token_override(self, overrides: dict) -> ContextManager[dict]:
|
||||
"""Temporarily patch the ID token generated by the token endpoint."""
|
||||
return patch.object(self, "_id_token_overrides", overrides)
|
||||
|
||||
|
@ -247,7 +247,7 @@ class FakeOidcServer:
|
|||
metadata: bool = False,
|
||||
token: bool = False,
|
||||
userinfo: bool = False,
|
||||
):
|
||||
) -> ContextManager[Dict[str, Mock]]:
|
||||
"""A context which makes a set of endpoints return a 500 error.
|
||||
|
||||
Args:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue