1
1
import synapse
2
2
from synapse .app .phone_stats_home import start_phone_stats_home
3
3
from synapse .rest .client import login , room
4
+ from synapse .server import HomeServer
5
+ from synapse .util import Clock
4
6
5
7
from tests import unittest
8
+ from tests .server import ThreadedMemoryReactorClock
6
9
from tests .unittest import HomeserverTestCase
7
10
8
11
FIVE_MINUTES_IN_SECONDS = 300
@@ -19,7 +22,7 @@ class PhoneHomeTestCase(HomeserverTestCase):
19
22
# Override the retention time for the user_ips table because otherwise it
20
23
# gets pruned too aggressively for our R30 test.
21
24
@unittest .override_config ({"user_ips_max_age" : "365d" })
22
- def test_r30_minimum_usage (self ):
25
+ def test_r30_minimum_usage (self ) -> None :
23
26
"""
24
27
Tests the minimum amount of interaction necessary for the R30 metric
25
28
to consider a user 'retained'.
@@ -68,7 +71,7 @@ def test_r30_minimum_usage(self):
68
71
r30_results = self .get_success (self .hs .get_datastores ().main .count_r30_users ())
69
72
self .assertEqual (r30_results , {"all" : 0 })
70
73
71
- def test_r30_minimum_usage_using_default_config (self ):
74
+ def test_r30_minimum_usage_using_default_config (self ) -> None :
72
75
"""
73
76
Tests the minimum amount of interaction necessary for the R30 metric
74
77
to consider a user 'retained'.
@@ -122,7 +125,7 @@ def test_r30_minimum_usage_using_default_config(self):
122
125
r30_results = self .get_success (self .hs .get_datastores ().main .count_r30_users ())
123
126
self .assertEqual (r30_results , {"all" : 0 })
124
127
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 :
126
129
"""
127
130
Tests that a newly-registered user must be retained for a whole month
128
131
before appearing in the R30 statistic, even if they post every day
@@ -164,12 +167,14 @@ class PhoneHomeR30V2TestCase(HomeserverTestCase):
164
167
login .register_servlets ,
165
168
]
166
169
167
- def _advance_to (self , desired_time_secs : float ):
170
+ def _advance_to (self , desired_time_secs : float ) -> None :
168
171
now = self .hs .get_clock ().time ()
169
172
assert now < desired_time_secs
170
173
self .reactor .advance (desired_time_secs - now )
171
174
172
- def make_homeserver (self , reactor , clock ):
175
+ def make_homeserver (
176
+ self , reactor : ThreadedMemoryReactorClock , clock : Clock
177
+ ) -> HomeServer :
173
178
hs = super (PhoneHomeR30V2TestCase , self ).make_homeserver (reactor , clock )
174
179
175
180
# We don't want our tests to actually report statistics, so check
@@ -181,7 +186,7 @@ def make_homeserver(self, reactor, clock):
181
186
start_phone_stats_home (hs )
182
187
return hs
183
188
184
- def test_r30v2_minimum_usage (self ):
189
+ def test_r30v2_minimum_usage (self ) -> None :
185
190
"""
186
191
Tests the minimum amount of interaction necessary for the R30v2 metric
187
192
to consider a user 'retained'.
@@ -250,7 +255,7 @@ def test_r30v2_minimum_usage(self):
250
255
r30_results , {"all" : 0 , "android" : 0 , "electron" : 0 , "ios" : 0 , "web" : 0 }
251
256
)
252
257
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 :
254
259
"""
255
260
Tests that a newly-registered user must be retained for a whole month
256
261
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):
316
321
r30_results , {"all" : 1 , "android" : 1 , "electron" : 0 , "ios" : 0 , "web" : 0 }
317
322
)
318
323
319
- def test_r30v2_returning_dormant_users_not_counted (self ):
324
+ def test_r30v2_returning_dormant_users_not_counted (self ) -> None :
320
325
"""
321
326
Tests that dormant users (users inactive for a long time) do not
322
327
contribute to R30v2 when they return for just a single day.
0 commit comments