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

Commit 0e9d64a

Browse files
committed
Update tests to catch this case.
The tests were modifying the callback object directly instead of using the method that modules would use, thus bypassing the missing code.
1 parent a13a6df commit 0e9d64a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/rest/client/test_third_party_rules.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -941,18 +941,16 @@ def test_on_add_and_remove_user_third_party_identifier(self) -> None:
941941
just before associating and removing a 3PID to/from an account.
942942
"""
943943
# Pretend to be a Synapse module and register both callbacks as mocks.
944-
third_party_rules = self.hs.get_third_party_event_rules()
945944
on_add_user_third_party_identifier_callback_mock = Mock(
946945
return_value=make_awaitable(None)
947946
)
948947
on_remove_user_third_party_identifier_callback_mock = Mock(
949948
return_value=make_awaitable(None)
950949
)
951-
third_party_rules._on_threepid_bind_callbacks.append(
952-
on_add_user_third_party_identifier_callback_mock
953-
)
954-
third_party_rules._on_threepid_bind_callbacks.append(
955-
on_remove_user_third_party_identifier_callback_mock
950+
third_party_rules = self.hs.get_third_party_event_rules()
951+
third_party_rules.register_third_party_rules_callbacks(
952+
on_add_user_third_party_identifier=on_add_user_third_party_identifier_callback_mock,
953+
on_remove_user_third_party_identifier=on_remove_user_third_party_identifier_callback_mock,
956954
)
957955

958956
# Register an admin user.
@@ -1008,12 +1006,12 @@ def test_on_remove_user_third_party_identifier_is_called_on_deactivate(
10081006
when a user is deactivated and their third-party ID associations are deleted.
10091007
"""
10101008
# Pretend to be a Synapse module and register both callbacks as mocks.
1011-
third_party_rules = self.hs.get_third_party_event_rules()
10121009
on_remove_user_third_party_identifier_callback_mock = Mock(
10131010
return_value=make_awaitable(None)
10141011
)
1015-
third_party_rules._on_threepid_bind_callbacks.append(
1016-
on_remove_user_third_party_identifier_callback_mock
1012+
third_party_rules = self.hs.get_third_party_event_rules()
1013+
third_party_rules.register_third_party_rules_callbacks(
1014+
on_threepid_bind=on_remove_user_third_party_identifier_callback_mock,
10171015
)
10181016

10191017
# Register an admin user.
@@ -1039,6 +1037,9 @@ def test_on_remove_user_third_party_identifier_is_called_on_deactivate(
10391037
)
10401038
self.assertEqual(channel.code, 200, channel.json_body)
10411039

1040+
# Check that the mock was not called on the act of adding a third-party ID.
1041+
on_remove_user_third_party_identifier_callback_mock.assert_not_called()
1042+
10421043
# Now deactivate the user.
10431044
channel = self.make_request(
10441045
"PUT",

0 commit comments

Comments
 (0)