11import synapse
22from synapse .app .phone_stats_home import start_phone_stats_home
33from synapse .rest .client import login , room
4+ from synapse .server import HomeServer
5+ from synapse .util import Clock
46
57from tests import unittest
8+ from tests .server import ThreadedMemoryReactorClock
69from tests .unittest import HomeserverTestCase
710
811FIVE_MINUTES_IN_SECONDS = 300
@@ -19,7 +22,7 @@ class PhoneHomeTestCase(HomeserverTestCase):
1922 # Override the retention time for the user_ips table because otherwise it
2023 # gets pruned too aggressively for our R30 test.
2124 @unittest .override_config ({"user_ips_max_age" : "365d" })
22- def test_r30_minimum_usage (self ):
25+ def test_r30_minimum_usage (self ) -> None :
2326 """
2427 Tests the minimum amount of interaction necessary for the R30 metric
2528 to consider a user 'retained'.
@@ -68,7 +71,7 @@ def test_r30_minimum_usage(self):
6871 r30_results = self .get_success (self .hs .get_datastores ().main .count_r30_users ())
6972 self .assertEqual (r30_results , {"all" : 0 })
7073
71- def test_r30_minimum_usage_using_default_config (self ):
74+ def test_r30_minimum_usage_using_default_config (self ) -> None :
7275 """
7376 Tests the minimum amount of interaction necessary for the R30 metric
7477 to consider a user 'retained'.
@@ -122,7 +125,7 @@ def test_r30_minimum_usage_using_default_config(self):
122125 r30_results = self .get_success (self .hs .get_datastores ().main .count_r30_users ())
123126 self .assertEqual (r30_results , {"all" : 0 })
124127
125- def test_r30_user_must_be_retained_for_at_least_a_month (self ):
128+ def test_r30_user_must_be_retained_for_at_least_a_month (self ) -> None :
126129 """
127130 Tests that a newly-registered user must be retained for a whole month
128131 before appearing in the R30 statistic, even if they post every day
@@ -164,12 +167,14 @@ class PhoneHomeR30V2TestCase(HomeserverTestCase):
164167 login .register_servlets ,
165168 ]
166169
167- def _advance_to (self , desired_time_secs : float ):
170+ def _advance_to (self , desired_time_secs : float ) -> None :
168171 now = self .hs .get_clock ().time ()
169172 assert now < desired_time_secs
170173 self .reactor .advance (desired_time_secs - now )
171174
172- def make_homeserver (self , reactor , clock ):
175+ def make_homeserver (
176+ self , reactor : ThreadedMemoryReactorClock , clock : Clock
177+ ) -> HomeServer :
173178 hs = super (PhoneHomeR30V2TestCase , self ).make_homeserver (reactor , clock )
174179
175180 # We don't want our tests to actually report statistics, so check
@@ -181,7 +186,7 @@ def make_homeserver(self, reactor, clock):
181186 start_phone_stats_home (hs )
182187 return hs
183188
184- def test_r30v2_minimum_usage (self ):
189+ def test_r30v2_minimum_usage (self ) -> None :
185190 """
186191 Tests the minimum amount of interaction necessary for the R30v2 metric
187192 to consider a user 'retained'.
@@ -250,7 +255,7 @@ def test_r30v2_minimum_usage(self):
250255 r30_results , {"all" : 0 , "android" : 0 , "electron" : 0 , "ios" : 0 , "web" : 0 }
251256 )
252257
253- def test_r30v2_user_must_be_retained_for_at_least_a_month (self ):
258+ def test_r30v2_user_must_be_retained_for_at_least_a_month (self ) -> None :
254259 """
255260 Tests that a newly-registered user must be retained for a whole month
256261 before appearing in the R30v2 statistic, even if they post every day
@@ -316,7 +321,7 @@ def test_r30v2_user_must_be_retained_for_at_least_a_month(self):
316321 r30_results , {"all" : 1 , "android" : 1 , "electron" : 0 , "ios" : 0 , "web" : 0 }
317322 )
318323
319- def test_r30v2_returning_dormant_users_not_counted (self ):
324+ def test_r30v2_returning_dormant_users_not_counted (self ) -> None :
320325 """
321326 Tests that dormant users (users inactive for a long time) do not
322327 contribute to R30v2 when they return for just a single day.
0 commit comments