mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-23 19:51:13 -04:00
Properly typecheck tests.api (#14983)
This commit is contained in:
parent
b2d97bac09
commit
6e6edea6c1
7 changed files with 141 additions and 111 deletions
|
@ -6,7 +6,7 @@ from tests import unittest
|
|||
|
||||
|
||||
class TestRatelimiter(unittest.HomeserverTestCase):
|
||||
def test_allowed_via_can_do_action(self):
|
||||
def test_allowed_via_can_do_action(self) -> None:
|
||||
limiter = Ratelimiter(
|
||||
store=self.hs.get_datastores().main,
|
||||
clock=self.clock,
|
||||
|
@ -31,7 +31,7 @@ class TestRatelimiter(unittest.HomeserverTestCase):
|
|||
self.assertTrue(allowed)
|
||||
self.assertEqual(20.0, time_allowed)
|
||||
|
||||
def test_allowed_appservice_ratelimited_via_can_requester_do_action(self):
|
||||
def test_allowed_appservice_ratelimited_via_can_requester_do_action(self) -> None:
|
||||
appservice = ApplicationService(
|
||||
token="fake_token",
|
||||
id="foo",
|
||||
|
@ -64,7 +64,7 @@ class TestRatelimiter(unittest.HomeserverTestCase):
|
|||
self.assertTrue(allowed)
|
||||
self.assertEqual(20.0, time_allowed)
|
||||
|
||||
def test_allowed_appservice_via_can_requester_do_action(self):
|
||||
def test_allowed_appservice_via_can_requester_do_action(self) -> None:
|
||||
appservice = ApplicationService(
|
||||
token="fake_token",
|
||||
id="foo",
|
||||
|
@ -97,7 +97,7 @@ class TestRatelimiter(unittest.HomeserverTestCase):
|
|||
self.assertTrue(allowed)
|
||||
self.assertEqual(-1, time_allowed)
|
||||
|
||||
def test_allowed_via_ratelimit(self):
|
||||
def test_allowed_via_ratelimit(self) -> None:
|
||||
limiter = Ratelimiter(
|
||||
store=self.hs.get_datastores().main,
|
||||
clock=self.clock,
|
||||
|
@ -120,7 +120,7 @@ class TestRatelimiter(unittest.HomeserverTestCase):
|
|||
limiter.ratelimit(None, key="test_id", _time_now_s=10)
|
||||
)
|
||||
|
||||
def test_allowed_via_can_do_action_and_overriding_parameters(self):
|
||||
def test_allowed_via_can_do_action_and_overriding_parameters(self) -> None:
|
||||
"""Test that we can override options of can_do_action that would otherwise fail
|
||||
an action
|
||||
"""
|
||||
|
@ -169,7 +169,7 @@ class TestRatelimiter(unittest.HomeserverTestCase):
|
|||
self.assertTrue(allowed)
|
||||
self.assertEqual(1.0, time_allowed)
|
||||
|
||||
def test_allowed_via_ratelimit_and_overriding_parameters(self):
|
||||
def test_allowed_via_ratelimit_and_overriding_parameters(self) -> None:
|
||||
"""Test that we can override options of the ratelimit method that would otherwise
|
||||
fail an action
|
||||
"""
|
||||
|
@ -204,7 +204,7 @@ class TestRatelimiter(unittest.HomeserverTestCase):
|
|||
limiter.ratelimit(None, key=("test_id",), _time_now_s=1, burst_count=10)
|
||||
)
|
||||
|
||||
def test_pruning(self):
|
||||
def test_pruning(self) -> None:
|
||||
limiter = Ratelimiter(
|
||||
store=self.hs.get_datastores().main,
|
||||
clock=self.clock,
|
||||
|
@ -223,7 +223,7 @@ class TestRatelimiter(unittest.HomeserverTestCase):
|
|||
|
||||
self.assertNotIn("test_id_1", limiter.actions)
|
||||
|
||||
def test_db_user_override(self):
|
||||
def test_db_user_override(self) -> None:
|
||||
"""Test that users that have ratelimiting disabled in the DB aren't
|
||||
ratelimited.
|
||||
"""
|
||||
|
@ -250,7 +250,7 @@ class TestRatelimiter(unittest.HomeserverTestCase):
|
|||
for _ in range(20):
|
||||
self.get_success_or_raise(limiter.ratelimit(requester, _time_now_s=0))
|
||||
|
||||
def test_multiple_actions(self):
|
||||
def test_multiple_actions(self) -> None:
|
||||
limiter = Ratelimiter(
|
||||
store=self.hs.get_datastores().main,
|
||||
clock=self.clock,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue