Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Refactor PresenceRouter tests
Browse files Browse the repository at this point in the history
The current default_config method didn't quite work for the test we just moved in,
(it negated any use of @override_config). So convert it to an @override_config
call instead.
  • Loading branch information
anoadragon453 committed Apr 1, 2021
1 parent ac4b0ff commit 6e42612
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions tests/events/test_presence_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,34 @@ class PresenceRouterTestCase(FederatingHomeserverTestCase):
presence.register_servlets,
]

def default_config(self):
config = super().default_config()
config["presence"] = {
"presence_router": {
"module": __name__ + ".PresenceRouterTestModule",
"config": {
"users_who_should_receive_all_presence": ["@presence_gobbler:test"]
},
}
}
return config

def make_homeserver(self, reactor, clock):
return self.setup_test_homeserver(
federation_transport_client=Mock(spec=["send_transaction"]),
)

def prepare(self, reactor, clock, homeserver):
self.sync_handler = self.hs.get_sync_handler()
self.module_api = homeserver.get_module_api()

@override_config(
{
"presence": {
"presence_router": {
"module": __name__ + ".PresenceRouterTestModule",
"config": {
"users_who_should_receive_all_presence": [
"@presence_gobbler:test",
]
},
}
},
"send_federation": True,
}
)
def test_receiving_all_presence(self):
"""Test that a user that does not share a room with another other can receive
presence for them, due to presence routing.
"""
# Create a user who should receive all presence of others
self.presence_receiving_user_id = self.register_user(
"presence_gobbler", "monkey"
Expand All @@ -119,26 +127,17 @@ def prepare(self, reactor, clock, homeserver):
self.other_user_two_tok = self.login("other_user_two", "monkey")

# Put the other two users in a room with each other
self.room_id = self.helper.create_room_as(
room_id = self.helper.create_room_as(
self.other_user_one_id, tok=self.other_user_one_tok
)

self.helper.invite(
self.room_id,
room_id,
self.other_user_one_id,
self.other_user_two_id,
tok=self.other_user_one_tok,
)
self.helper.join(
self.room_id, self.other_user_two_id, tok=self.other_user_two_tok
)

self.module_api = homeserver.get_module_api()

def test_receiving_all_presence(self):
"""Test that a user that does not share a room with another other can receive
presence for them, due to presence routing.
"""
self.helper.join(room_id, self.other_user_two_id, tok=self.other_user_two_tok)
# User one sends some presence
send_presence_update(
self,
Expand Down

0 comments on commit 6e42612

Please sign in to comment.