16
16
17
17
from parameterized import parameterized
18
18
19
+ from twisted .test .proto_helpers import MemoryReactor
20
+
19
21
import synapse .rest .admin
20
22
from synapse .api .errors import Codes
21
23
from synapse .rest .client import login
22
24
from synapse .server import HomeServer
23
25
from synapse .types import JsonDict
26
+ from synapse .util import Clock
24
27
25
28
from tests import unittest
26
29
@@ -31,7 +34,7 @@ class FederationTestCase(unittest.HomeserverTestCase):
31
34
login .register_servlets ,
32
35
]
33
36
34
- def prepare (self , reactor , clock , hs : HomeServer ):
37
+ def prepare (self , reactor : MemoryReactor , clock : Clock , hs : HomeServer ) -> None :
35
38
self .store = hs .get_datastore ()
36
39
self .register_user ("admin" , "pass" , admin = True )
37
40
self .admin_user_tok = self .login ("admin" , "pass" )
@@ -44,7 +47,7 @@ def prepare(self, reactor, clock, hs: HomeServer):
44
47
("/_synapse/admin/v1/federation/destinations/dummy" ,),
45
48
]
46
49
)
47
- def test_requester_is_no_admin (self , url : str ):
50
+ def test_requester_is_no_admin (self , url : str ) -> None :
48
51
"""
49
52
If the user is not a server admin, an error 403 is returned.
50
53
"""
@@ -62,7 +65,7 @@ def test_requester_is_no_admin(self, url: str):
62
65
self .assertEqual (HTTPStatus .FORBIDDEN , channel .code , msg = channel .json_body )
63
66
self .assertEqual (Codes .FORBIDDEN , channel .json_body ["errcode" ])
64
67
65
- def test_invalid_parameter (self ):
68
+ def test_invalid_parameter (self ) -> None :
66
69
"""
67
70
If parameters are invalid, an error is returned.
68
71
"""
@@ -117,7 +120,7 @@ def test_invalid_parameter(self):
117
120
self .assertEqual (HTTPStatus .NOT_FOUND , channel .code , msg = channel .json_body )
118
121
self .assertEqual (Codes .NOT_FOUND , channel .json_body ["errcode" ])
119
122
120
- def test_limit (self ):
123
+ def test_limit (self ) -> None :
121
124
"""
122
125
Testing list of destinations with limit
123
126
"""
@@ -137,7 +140,7 @@ def test_limit(self):
137
140
self .assertEqual (channel .json_body ["next_token" ], "5" )
138
141
self ._check_fields (channel .json_body ["destinations" ])
139
142
140
- def test_from (self ):
143
+ def test_from (self ) -> None :
141
144
"""
142
145
Testing list of destinations with a defined starting point (from)
143
146
"""
@@ -157,7 +160,7 @@ def test_from(self):
157
160
self .assertNotIn ("next_token" , channel .json_body )
158
161
self ._check_fields (channel .json_body ["destinations" ])
159
162
160
- def test_limit_and_from (self ):
163
+ def test_limit_and_from (self ) -> None :
161
164
"""
162
165
Testing list of destinations with a defined starting point and limit
163
166
"""
@@ -177,7 +180,7 @@ def test_limit_and_from(self):
177
180
self .assertEqual (len (channel .json_body ["destinations" ]), 10 )
178
181
self ._check_fields (channel .json_body ["destinations" ])
179
182
180
- def test_next_token (self ):
183
+ def test_next_token (self ) -> None :
181
184
"""
182
185
Testing that `next_token` appears at the right place
183
186
"""
@@ -238,7 +241,7 @@ def test_next_token(self):
238
241
self .assertEqual (len (channel .json_body ["destinations" ]), 1 )
239
242
self .assertNotIn ("next_token" , channel .json_body )
240
243
241
- def test_list_all_destinations (self ):
244
+ def test_list_all_destinations (self ) -> None :
242
245
"""
243
246
List all destinations.
244
247
"""
@@ -259,7 +262,7 @@ def test_list_all_destinations(self):
259
262
# Check that all fields are available
260
263
self ._check_fields (channel .json_body ["destinations" ])
261
264
262
- def test_order_by (self ):
265
+ def test_order_by (self ) -> None :
263
266
"""
264
267
Testing order list with parameter `order_by`
265
268
"""
@@ -268,7 +271,7 @@ def _order_test(
268
271
expected_destination_list : List [str ],
269
272
order_by : Optional [str ],
270
273
dir : Optional [str ] = None ,
271
- ):
274
+ ) -> None :
272
275
"""Request the list of destinations in a certain order.
273
276
Assert that order is what we expect
274
277
@@ -358,13 +361,13 @@ def _order_test(
358
361
[dest [0 ][0 ], dest [2 ][0 ], dest [1 ][0 ]], "last_successful_stream_ordering" , "b"
359
362
)
360
363
361
- def test_search_term (self ):
364
+ def test_search_term (self ) -> None :
362
365
"""Test that searching for a destination works correctly"""
363
366
364
367
def _search_test (
365
368
expected_destination : Optional [str ],
366
369
search_term : str ,
367
- ):
370
+ ) -> None :
368
371
"""Search for a destination and check that the returned destinationis a match
369
372
370
373
Args:
@@ -410,7 +413,7 @@ def _search_test(
410
413
_search_test (None , "foo" )
411
414
_search_test (None , "bar" )
412
415
413
- def test_get_single_destination (self ):
416
+ def test_get_single_destination (self ) -> None :
414
417
"""
415
418
Get one specific destinations.
416
419
"""
@@ -429,7 +432,7 @@ def test_get_single_destination(self):
429
432
# convert channel.json_body into a List
430
433
self ._check_fields ([channel .json_body ])
431
434
432
- def _create_destinations (self , number_destinations : int ):
435
+ def _create_destinations (self , number_destinations : int ) -> None :
433
436
"""Create a number of destinations
434
437
435
438
Args:
@@ -442,7 +445,7 @@ def _create_destinations(self, number_destinations: int):
442
445
self .store .set_destination_last_successful_stream_ordering (dest , 100 )
443
446
)
444
447
445
- def _check_fields (self , content : List [JsonDict ]):
448
+ def _check_fields (self , content : List [JsonDict ]) -> None :
446
449
"""Checks that the expected destination attributes are present in content
447
450
448
451
Args:
0 commit comments