Simplify the way the HomeServer object caches its internal attributes. (#8565)

Changes `@cache_in_self` to use underscore-prefixed attributes.
This commit is contained in:
Jonathan de Jong 2020-11-30 19:28:44 +01:00 committed by GitHub
parent a090b86209
commit ca60822b34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 40 additions and 36 deletions

View file

@ -33,12 +33,15 @@ class PresenceTestCase(unittest.HomeserverTestCase):
def make_homeserver(self, reactor, clock):
hs = self.setup_test_homeserver(
"red", http_client=None, federation_client=Mock()
)
presence_handler = Mock()
presence_handler.set_state.return_value = defer.succeed(None)
hs.presence_handler = Mock()
hs.presence_handler.set_state.return_value = defer.succeed(None)
hs = self.setup_test_homeserver(
"red",
http_client=None,
federation_client=Mock(),
presence_handler=presence_handler,
)
return hs
@ -55,7 +58,7 @@ class PresenceTestCase(unittest.HomeserverTestCase):
)
self.assertEqual(channel.code, 200)
self.assertEqual(self.hs.presence_handler.set_state.call_count, 1)
self.assertEqual(self.hs.get_presence_handler().set_state.call_count, 1)
def test_put_presence_disabled(self):
"""
@ -70,4 +73,4 @@ class PresenceTestCase(unittest.HomeserverTestCase):
)
self.assertEqual(channel.code, 200)
self.assertEqual(self.hs.presence_handler.set_state.call_count, 0)
self.assertEqual(self.hs.get_presence_handler().set_state.call_count, 0)