mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 13:54:55 -04:00
Add type hints to synapse/tests/rest/admin
(#11590)
This commit is contained in:
parent
1847d027e6
commit
8428ef66c7
7 changed files with 74 additions and 57 deletions
|
@ -14,6 +14,7 @@
|
|||
import random
|
||||
import string
|
||||
from http import HTTPStatus
|
||||
from typing import Optional
|
||||
|
||||
from twisted.test.proto_helpers import MemoryReactor
|
||||
|
||||
|
@ -42,21 +43,27 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
self.url = "/_synapse/admin/v1/registration_tokens"
|
||||
|
||||
def _new_token(self, **kwargs) -> str:
|
||||
def _new_token(
|
||||
self,
|
||||
token: Optional[str] = None,
|
||||
uses_allowed: Optional[int] = None,
|
||||
pending: int = 0,
|
||||
completed: int = 0,
|
||||
expiry_time: Optional[int] = None,
|
||||
) -> str:
|
||||
"""Helper function to create a token."""
|
||||
token = kwargs.get(
|
||||
"token",
|
||||
"".join(random.choices(string.ascii_letters, k=8)),
|
||||
)
|
||||
if token is None:
|
||||
token = "".join(random.choices(string.ascii_letters, k=8))
|
||||
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_insert(
|
||||
"registration_tokens",
|
||||
{
|
||||
"token": token,
|
||||
"uses_allowed": kwargs.get("uses_allowed", None),
|
||||
"pending": kwargs.get("pending", 0),
|
||||
"completed": kwargs.get("completed", 0),
|
||||
"expiry_time": kwargs.get("expiry_time", None),
|
||||
"uses_allowed": uses_allowed,
|
||||
"pending": pending,
|
||||
"completed": completed,
|
||||
"expiry_time": expiry_time,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue