summary refs log tree commit diff
path: root/tests/test_phone_home.py
diff options
context:
space:
mode:
authorDirk Klimpel <5740567+dklimpel@users.noreply.github.com>2022-04-05 14:54:41 +0200
committerGitHub <noreply@github.com>2022-04-05 13:54:41 +0100
commitd666fc02fab7421efb39a33800a83791f88bf9b2 (patch)
tree4313e8c64e6daa20ac471881b117d081fb0c9bbb /tests/test_phone_home.py
parentFix a spec compliance issue where requests to the `/publicRooms` federation A... (diff)
downloadsynapse-d666fc02fab7421efb39a33800a83791f88bf9b2.tar.xz
Add type hints to some tests files (#12371)
Diffstat (limited to 'tests/test_phone_home.py')
-rw-r--r--tests/test_phone_home.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/test_phone_home.py b/tests/test_phone_home.py
index 09707a74d7..b01cae6e5d 100644
--- a/tests/test_phone_home.py
+++ b/tests/test_phone_home.py
@@ -16,23 +16,24 @@ import resource
 from unittest import mock
 
 from synapse.app.phone_stats_home import phone_stats_home
+from synapse.types import JsonDict
 
 from tests.unittest import HomeserverTestCase
 
 
 class PhoneHomeStatsTestCase(HomeserverTestCase):
-    def test_performance_frozen_clock(self):
+    def test_performance_frozen_clock(self) -> None:
         """
         If time doesn't move, don't error out.
         """
         past_stats = [
             (self.hs.get_clock().time(), resource.getrusage(resource.RUSAGE_SELF))
         ]
-        stats = {}
+        stats: JsonDict = {}
         self.get_success(phone_stats_home(self.hs, stats, past_stats))
         self.assertEqual(stats["cpu_average"], 0)
 
-    def test_performance_100(self):
+    def test_performance_100(self) -> None:
         """
         1 second of usage over 1 second is 100% CPU usage.
         """
@@ -43,7 +44,8 @@ class PhoneHomeStatsTestCase(HomeserverTestCase):
         old_resource.ru_maxrss = real_res.ru_maxrss
 
         past_stats = [(self.hs.get_clock().time(), old_resource)]
-        stats = {}
+        stats: JsonDict = {}
         self.reactor.advance(1)
-        self.get_success(phone_stats_home(self.hs, stats, past_stats))
+        # `old_resource` has type `Mock` instead of `struct_rusage`
+        self.get_success(phone_stats_home(self.hs, stats, past_stats))  # type: ignore[arg-type]
         self.assertApproximates(stats["cpu_average"], 100, tolerance=2.5)