summary refs log tree commit diff
path: root/tests/rest/admin/test_registration_tokens.py
diff options
context:
space:
mode:
authorDirk Klimpel <5740567+dklimpel@users.noreply.github.com>2021-12-16 20:59:56 +0100
committerGitHub <noreply@github.com>2021-12-16 14:59:56 -0500
commit8428ef66c73efcc01cdbe05ac8bc1c99c4c20a20 (patch)
tree071c623f9456559deb3aa2e3cae76a376b2cbdd1 /tests/rest/admin/test_registration_tokens.py
parentAdd type hints to `synapse/storage/databases/main/transactions.py` (#11589) (diff)
downloadsynapse-8428ef66c73efcc01cdbe05ac8bc1c99c4c20a20.tar.xz
Add type hints to `synapse/tests/rest/admin` (#11590)
Diffstat (limited to 'tests/rest/admin/test_registration_tokens.py')
-rw-r--r--tests/rest/admin/test_registration_tokens.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/tests/rest/admin/test_registration_tokens.py b/tests/rest/admin/test_registration_tokens.py
index 350a62dda6..81f3ac7f04 100644
--- a/tests/rest/admin/test_registration_tokens.py
+++ b/tests/rest/admin/test_registration_tokens.py
@@ -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,
                 },
             )
         )