From d4b41aaf438b6cc1b39af2335e9437e1bbea1fdb Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 22 May 2024 15:01:06 -0500 Subject: [PATCH] Fix lints --- tests/rest/client/test_sendtodevice.py | 12 +++++++----- tests/rest/client/test_sync.py | 25 +++++++++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/tests/rest/client/test_sendtodevice.py b/tests/rest/client/test_sendtodevice.py index ce8ba0f209..a5eefaf958 100644 --- a/tests/rest/client/test_sendtodevice.py +++ b/tests/rest/client/test_sendtodevice.py @@ -43,12 +43,9 @@ from tests.unittest import HomeserverTestCase, override_config ), ], ) -class SendToDeviceTestCaseBase(HomeserverTestCase): +class SendToDeviceTestCase(HomeserverTestCase): """ Test `/sendToDevice` will deliver messages across to people receiving them over `/sync`. - - In order to run the tests, inherit from this base-class with `HomeserverTestCase`, e.g. - `class SendToDeviceTestCase(SendToDeviceTestCase, HomeserverTestCase)` """ servlets = [ @@ -60,9 +57,14 @@ class SendToDeviceTestCaseBase(HomeserverTestCase): def default_config(self) -> JsonDict: config = super().default_config() - config["experimental_features"] = self.experimental_features + config["experimental_features"] = self.experimental_features # type: ignore[attr-defined] return config + def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: + # This pointless re-assignment avoids `# type: ignore[attr-defined]` problems + # throughout the test cases + self.sync_endpoint: str = self.sync_endpoint + def test_user_to_user(self) -> None: """A to-device message from one user to another should get delivered""" diff --git a/tests/rest/client/test_sync.py b/tests/rest/client/test_sync.py index 8397d89f0d..ab9b16a0f8 100644 --- a/tests/rest/client/test_sync.py +++ b/tests/rest/client/test_sync.py @@ -699,7 +699,7 @@ class SyncCacheTestCase(unittest.HomeserverTestCase): ), ], ) -class DeviceListSyncTestCaseBase(unittest.HomeserverTestCase): +class DeviceListSyncTestCase(unittest.HomeserverTestCase): """Tests regarding device list (`device_lists`) changes.""" servlets = [ @@ -712,9 +712,14 @@ class DeviceListSyncTestCaseBase(unittest.HomeserverTestCase): def default_config(self) -> JsonDict: config = super().default_config() - config["experimental_features"] = self.experimental_features + config["experimental_features"] = self.experimental_features # type: ignore[attr-defined] return config + def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: + # This pointless re-assignment avoids `# type: ignore[attr-defined]` problems + # throughout the test cases + self.sync_endpoint: str = self.sync_endpoint + def test_receiving_local_device_list_changes(self) -> None: """Tests that a local users that share a room receive each other's device list changes. @@ -901,7 +906,7 @@ class DeviceListSyncTestCaseBase(unittest.HomeserverTestCase): ), ], ) -class DeviceOneTimeKeysSyncTestCaseBase(unittest.HomeserverTestCase): +class DeviceOneTimeKeysSyncTestCase(unittest.HomeserverTestCase): """Tests regarding device one time keys (`device_one_time_keys_count`) changes.""" servlets = [ @@ -913,10 +918,14 @@ class DeviceOneTimeKeysSyncTestCaseBase(unittest.HomeserverTestCase): def default_config(self) -> JsonDict: config = super().default_config() - config["experimental_features"] = self.experimental_features + config["experimental_features"] = self.experimental_features # type: ignore[attr-defined] return config def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: + # This pointless re-assignment avoids `# type: ignore[attr-defined]` problems + # throughout the test cases + self.sync_endpoint: str = self.sync_endpoint + self.e2e_keys_handler = hs.get_e2e_keys_handler() def test_no_device_one_time_keys(self) -> None: @@ -1003,7 +1012,7 @@ class DeviceOneTimeKeysSyncTestCaseBase(unittest.HomeserverTestCase): ), ], ) -class DeviceUnusedFallbackKeySyncTestCaseBase(unittest.HomeserverTestCase): +class DeviceUnusedFallbackKeySyncTestCase(unittest.HomeserverTestCase): """Tests regarding device one time keys (`device_unused_fallback_key_types`) changes.""" servlets = [ @@ -1015,10 +1024,14 @@ class DeviceUnusedFallbackKeySyncTestCaseBase(unittest.HomeserverTestCase): def default_config(self) -> JsonDict: config = super().default_config() - config["experimental_features"] = self.experimental_features + config["experimental_features"] = self.experimental_features # type: ignore[attr-defined] return config def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: + # This pointless re-assignment avoids `# type: ignore[attr-defined]` problems + # throughout the test cases + self.sync_endpoint: str = self.sync_endpoint + self.store = self.hs.get_datastores().main self.e2e_keys_handler = hs.get_e2e_keys_handler()