Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 02cad91

Browse files
author
David Robertson
committed
Proper types for tests.test_terms_auth
1 parent d0fed7a commit 02cad91

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

mypy.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ exclude = (?x)
3535
|tests/module_api/test_api.py
3636
|tests/rest/media/v1/test_media_storage.py
3737
|tests/server.py
38-
|tests/test_terms_auth.py
3938
)$
4039

4140
[mypy-synapse.federation.transport.client]
@@ -119,6 +118,9 @@ disallow_untyped_defs = True
119118
[mypy-tests.test_state]
120119
disallow_untyped_defs = True
121120

121+
[mypy-tests.test_terms_auth]
122+
disallow_untyped_defs = True
123+
122124
[mypy-tests.types.*]
123125
disallow_untyped_defs = True
124126

tests/test_terms_auth.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414

1515
from unittest.mock import Mock
1616

17-
from twisted.test.proto_helpers import MemoryReactorClock
17+
from twisted.internet.interfaces import IReactorTime
18+
from twisted.test.proto_helpers import MemoryReactor, MemoryReactorClock
1819

1920
from synapse.rest.client.register import register_servlets
21+
from synapse.server import HomeServer
22+
from synapse.types import JsonDict
2023
from synapse.util import Clock
2124

2225
from tests import unittest
@@ -25,7 +28,7 @@
2528
class TermsTestCase(unittest.HomeserverTestCase):
2629
servlets = [register_servlets]
2730

28-
def default_config(self):
31+
def default_config(self) -> JsonDict:
2932
config = super().default_config()
3033
config.update(
3134
{
@@ -40,17 +43,21 @@ def default_config(self):
4043
)
4144
return config
4245

43-
def prepare(self, reactor, clock, hs):
44-
self.clock = MemoryReactorClock()
46+
def prepare(
47+
self, reactor: MemoryReactor, clock: Clock, homeserver: HomeServer
48+
) -> None:
49+
# type-ignore: mypy-zope doesn't seem to recognise that MemoryReactorClock
50+
# implements IReactorTime, via inheritance from twisted.internet.testing.Clock
51+
self.clock: IReactorTime = MemoryReactorClock() # type: ignore[assignment]
4552
self.hs_clock = Clock(self.clock)
4653
self.url = "/_matrix/client/r0/register"
4754
self.registration_handler = Mock()
4855
self.auth_handler = Mock()
4956
self.device_handler = Mock()
5057

51-
def test_ui_auth(self):
58+
def test_ui_auth(self) -> None:
5259
# Do a UI auth request
53-
request_data = {"username": "kermit", "password": "monkey"}
60+
request_data: JsonDict = {"username": "kermit", "password": "monkey"}
5461
channel = self.make_request(b"POST", self.url, request_data)
5562

5663
self.assertEqual(channel.code, 401, channel.result)

0 commit comments

Comments
 (0)