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

Commit

Permalink
Fix tests; update them to check new call arguments
Browse files Browse the repository at this point in the history
The List type args were changed to Iterables as we now pass Sets to this
method instead. Iterable is more correct as well, as the method only
iterates over it (and passes the state to send_presence, which also
wants an Iterable).
  • Loading branch information
anoadragon453 committed Feb 18, 2021
1 parent 5eb004b commit 0028b37
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion synapse/federation/sender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ async def send_presence(self, states: List[UserPresenceState]):
self._processing_pending_presence = False

def send_presence_to_destinations(
self, states: List[UserPresenceState], destinations: List[str]
self, states: Iterable[UserPresenceState], destinations: Iterable[str]
) -> None:
"""Send the given presence states to the given destinations.
destinations (list[str])
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ async def _handle_state_delta(self, deltas):
# Send out user presence updates for each destination
for destination, user_state_set in presence_destinations.items():
self.federation.send_presence_to_destinations(
states=user_state_set, destinations=[destination]
destinations=[destination], states=user_state_set
)

async def _on_user_joined_room(
Expand Down
14 changes: 10 additions & 4 deletions tests/handlers/test_presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def test_remote_joins(self):
)
self.assertEqual(expected_state.state, PresenceState.ONLINE)
self.federation_sender.send_presence_to_destinations.assert_called_once_with(
destinations=["server2"], states=[expected_state]
destinations=["server2"], states={expected_state}
)

#
Expand All @@ -533,7 +533,7 @@ def test_remote_joins(self):

self.federation_sender.send_presence.assert_not_called()
self.federation_sender.send_presence_to_destinations.assert_called_once_with(
destinations=["server3"], states=[expected_state]
destinations=["server3"], states={expected_state}
)

def test_remote_gets_presence_when_local_user_joins(self):
Expand Down Expand Up @@ -584,8 +584,14 @@ def test_remote_gets_presence_when_local_user_joins(self):
self.presence_handler.current_state_for_user("@test2:server")
)
self.assertEqual(expected_state.state, PresenceState.ONLINE)
self.federation_sender.send_presence_to_destinations.assert_called_once_with(
destinations={"server2", "server3"}, states=[expected_state]
self.assertEqual(
self.federation_sender.send_presence_to_destinations.call_count, 2
)
self.federation_sender.send_presence_to_destinations.assert_any_call(
destinations=["server3"], states={expected_state}
)
self.federation_sender.send_presence_to_destinations.assert_any_call(
destinations=["server2"], states={expected_state}
)

def _add_new_user(self, room_id, user_id):
Expand Down

0 comments on commit 0028b37

Please sign in to comment.