Fix user directory test for deactivated support user. (#16157)
Support users should not be added to the user directory after being deactivated.pull/16140/head
parent
bc72d803d5
commit
b657e89005
|
@ -0,0 +1 @@
|
||||||
|
Fix assertion in user directory unit tests.
|
|
@ -446,6 +446,7 @@ class UserDirectoryTestCase(unittest.HomeserverTestCase):
|
||||||
self.assertIsNone(profile)
|
self.assertIsNone(profile)
|
||||||
|
|
||||||
def test_handle_user_deactivated_support_user(self) -> None:
|
def test_handle_user_deactivated_support_user(self) -> None:
|
||||||
|
"""Ensure a support user doesn't get added to the user directory after deactivation."""
|
||||||
s_user_id = "@support:test"
|
s_user_id = "@support:test"
|
||||||
self.get_success(
|
self.get_success(
|
||||||
self.store.register_user(
|
self.store.register_user(
|
||||||
|
@ -453,14 +454,16 @@ class UserDirectoryTestCase(unittest.HomeserverTestCase):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
mock_remove_from_user_dir = Mock(return_value=make_awaitable(None))
|
# The profile should not be in the directory.
|
||||||
with patch.object(
|
profile = self.get_success(self.store._get_user_in_directory(s_user_id))
|
||||||
self.store, "remove_from_user_dir", mock_remove_from_user_dir
|
self.assertIsNone(profile)
|
||||||
):
|
|
||||||
self.get_success(self.handler.handle_local_user_deactivated(s_user_id))
|
# Remove the user from the directory.
|
||||||
# BUG: the correct spelling is assert_not_called, but that makes the test fail
|
self.get_success(self.handler.handle_local_user_deactivated(s_user_id))
|
||||||
# and it's not clear that this is actually the behaviour we want.
|
|
||||||
mock_remove_from_user_dir.not_called()
|
# The profile should still not be in the user directory.
|
||||||
|
profile = self.get_success(self.store._get_user_in_directory(s_user_id))
|
||||||
|
self.assertIsNone(profile)
|
||||||
|
|
||||||
def test_handle_user_deactivated_regular_user(self) -> None:
|
def test_handle_user_deactivated_regular_user(self) -> None:
|
||||||
r_user_id = "@regular:test"
|
r_user_id = "@regular:test"
|
||||||
|
|
Loading…
Reference in New Issue