2424from synapse .server_notices .resource_limits_server_notices import (
2525 ResourceLimitsServerNotices ,
2626)
27+ from synapse .types import JsonDict
2728from synapse .util import Clock
2829
2930from tests import unittest
3334
3435
3536class TestResourceLimitsServerNotices (unittest .HomeserverTestCase ):
36- def default_config (self ):
37+ def default_config (self ) -> JsonDict :
3738 config = default_config ("test" )
3839
3940 config .update (
@@ -86,18 +87,18 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
8687 self ._rlsn ._store .get_tags_for_room = Mock (return_value = make_awaitable ({})) # type: ignore[assignment]
8788
8889 @override_config ({"hs_disabled" : True })
89- def test_maybe_send_server_notice_disabled_hs (self ):
90+ def test_maybe_send_server_notice_disabled_hs (self ) -> None :
9091 """If the HS is disabled, we should not send notices"""
9192 self .get_success (self ._rlsn .maybe_send_server_notice_to_user (self .user_id ))
9293 self ._send_notice .assert_not_called ()
9394
9495 @override_config ({"limit_usage_by_mau" : False })
95- def test_maybe_send_server_notice_to_user_flag_off (self ):
96+ def test_maybe_send_server_notice_to_user_flag_off (self ) -> None :
9697 """If mau limiting is disabled, we should not send notices"""
9798 self .get_success (self ._rlsn .maybe_send_server_notice_to_user (self .user_id ))
9899 self ._send_notice .assert_not_called ()
99100
100- def test_maybe_send_server_notice_to_user_remove_blocked_notice (self ):
101+ def test_maybe_send_server_notice_to_user_remove_blocked_notice (self ) -> None :
101102 """Test when user has blocked notice, but should have it removed"""
102103
103104 self ._rlsn ._auth_blocking .check_auth_blocking = Mock (
@@ -114,7 +115,7 @@ def test_maybe_send_server_notice_to_user_remove_blocked_notice(self):
114115 self ._rlsn ._server_notices_manager .maybe_get_notice_room_for_user .assert_called_once ()
115116 self ._send_notice .assert_called_once ()
116117
117- def test_maybe_send_server_notice_to_user_remove_blocked_notice_noop (self ):
118+ def test_maybe_send_server_notice_to_user_remove_blocked_notice_noop (self ) -> None :
118119 """
119120 Test when user has blocked notice, but notice ought to be there (NOOP)
120121 """
@@ -134,7 +135,7 @@ def test_maybe_send_server_notice_to_user_remove_blocked_notice_noop(self):
134135
135136 self ._send_notice .assert_not_called ()
136137
137- def test_maybe_send_server_notice_to_user_add_blocked_notice (self ):
138+ def test_maybe_send_server_notice_to_user_add_blocked_notice (self ) -> None :
138139 """
139140 Test when user does not have blocked notice, but should have one
140141 """
@@ -147,7 +148,7 @@ def test_maybe_send_server_notice_to_user_add_blocked_notice(self):
147148 # Would be better to check contents, but 2 calls == set blocking event
148149 self .assertEqual (self ._send_notice .call_count , 2 )
149150
150- def test_maybe_send_server_notice_to_user_add_blocked_notice_noop (self ):
151+ def test_maybe_send_server_notice_to_user_add_blocked_notice_noop (self ) -> None :
151152 """
152153 Test when user does not have blocked notice, nor should they (NOOP)
153154 """
@@ -159,7 +160,7 @@ def test_maybe_send_server_notice_to_user_add_blocked_notice_noop(self):
159160
160161 self ._send_notice .assert_not_called ()
161162
162- def test_maybe_send_server_notice_to_user_not_in_mau_cohort (self ):
163+ def test_maybe_send_server_notice_to_user_not_in_mau_cohort (self ) -> None :
163164 """
164165 Test when user is not part of the MAU cohort - this should not ever
165166 happen - but ...
@@ -175,7 +176,9 @@ def test_maybe_send_server_notice_to_user_not_in_mau_cohort(self):
175176 self ._send_notice .assert_not_called ()
176177
177178 @override_config ({"mau_limit_alerting" : False })
178- def test_maybe_send_server_notice_when_alerting_suppressed_room_unblocked (self ):
179+ def test_maybe_send_server_notice_when_alerting_suppressed_room_unblocked (
180+ self ,
181+ ) -> None :
179182 """
180183 Test that when server is over MAU limit and alerting is suppressed, then
181184 an alert message is not sent into the room
@@ -191,7 +194,7 @@ def test_maybe_send_server_notice_when_alerting_suppressed_room_unblocked(self):
191194 self .assertEqual (self ._send_notice .call_count , 0 )
192195
193196 @override_config ({"mau_limit_alerting" : False })
194- def test_check_hs_disabled_unaffected_by_mau_alert_suppression (self ):
197+ def test_check_hs_disabled_unaffected_by_mau_alert_suppression (self ) -> None :
195198 """
196199 Test that when a server is disabled, that MAU limit alerting is ignored.
197200 """
@@ -207,7 +210,9 @@ def test_check_hs_disabled_unaffected_by_mau_alert_suppression(self):
207210 self .assertEqual (self ._send_notice .call_count , 2 )
208211
209212 @override_config ({"mau_limit_alerting" : False })
210- def test_maybe_send_server_notice_when_alerting_suppressed_room_blocked (self ):
213+ def test_maybe_send_server_notice_when_alerting_suppressed_room_blocked (
214+ self ,
215+ ) -> None :
211216 """
212217 When the room is already in a blocked state, test that when alerting
213218 is suppressed that the room is returned to an unblocked state.
@@ -242,7 +247,7 @@ class TestResourceLimitsServerNoticesWithRealRooms(unittest.HomeserverTestCase):
242247 sync .register_servlets ,
243248 ]
244249
245- def default_config (self ):
250+ def default_config (self ) -> JsonDict :
246251 c = super ().default_config ()
247252 c ["server_notices" ] = {
248253 "system_mxid_localpart" : "server" ,
@@ -270,7 +275,7 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
270275
271276 self .user_id = "@user_id:test"
272277
273- def test_server_notice_only_sent_once (self ):
278+ def test_server_notice_only_sent_once (self ) -> None :
274279 self .store .get_monthly_active_count = Mock (return_value = make_awaitable (1000 ))
275280
276281 self .store .user_last_seen_monthly_active = Mock (
@@ -306,7 +311,7 @@ def test_server_notice_only_sent_once(self):
306311
307312 self .assertEqual (count , 1 )
308313
309- def test_no_invite_without_notice (self ):
314+ def test_no_invite_without_notice (self ) -> None :
310315 """Tests that a user doesn't get invited to a server notices room without a
311316 server notice being sent.
312317
@@ -328,7 +333,7 @@ def test_no_invite_without_notice(self):
328333
329334 m .assert_called_once_with (user_id )
330335
331- def test_invite_with_notice (self ):
336+ def test_invite_with_notice (self ) -> None :
332337 """Tests that, if the MAU limit is hit, the server notices user invites each user
333338 to a room in which it has sent a notice.
334339 """
0 commit comments