mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
tests: Call client methods with explicit keyword arguments.
This is a prep commit for tightening the types for our wrapped test client. The callers of the test client methods are refactored to either call them without unpacking at all or create a TypedDict for the keyword arguments to be unpacked. This allows the type checker to know exactly what keys are present and their corresponding type. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
committed by
Tim Abbott
parent
a3a0545aac
commit
4e518a3852
@@ -1,6 +1,6 @@
|
||||
import copy
|
||||
from contextlib import contextmanager
|
||||
from typing import TYPE_CHECKING, Any, Dict, Iterator, Mapping
|
||||
from typing import TYPE_CHECKING, Any, Dict, Iterator, TypedDict
|
||||
from unittest import mock
|
||||
|
||||
import orjson
|
||||
@@ -14,6 +14,10 @@ if TYPE_CHECKING:
|
||||
from django.test.client import _MonkeyPatchedWSGIResponse as TestHttpResponse
|
||||
|
||||
|
||||
class SCIMHeadersDict(TypedDict):
|
||||
HTTP_AUTHORIZATION: str
|
||||
|
||||
|
||||
class SCIMTestCase(ZulipTestCase):
|
||||
def setUp(self) -> None:
|
||||
super().setUp()
|
||||
@@ -22,7 +26,7 @@ class SCIMTestCase(ZulipTestCase):
|
||||
realm=self.realm, name=settings.SCIM_CONFIG["zulip"]["scim_client_name"]
|
||||
)
|
||||
|
||||
def scim_headers(self) -> Mapping[str, str]:
|
||||
def scim_headers(self) -> SCIMHeadersDict:
|
||||
return {"HTTP_AUTHORIZATION": f"Bearer {settings.SCIM_CONFIG['zulip']['bearer_token']}"}
|
||||
|
||||
def generate_user_schema(self, user_profile: UserProfile) -> Dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user