user_groups: Use check_add_user_group instead in test cases.

"check_add_user_group" is a safer helper function than
"create_user_group" to use when creating user_groups. It does
error handling and notify the client with the appropriate event.

Note that the populate_db command still uses "create_user_group"
because we do not need to enqueue events at that point.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li
2022-12-14 00:45:55 -05:00
committed by Tim Abbott
parent 0f5d6432a4
commit e331c356e4
9 changed files with 60 additions and 56 deletions

View File

@@ -8,7 +8,7 @@ from django.http import HttpRequest, HttpResponse
from zerver.actions.message_send import internal_send_private_message
from zerver.actions.muted_users import do_mute_user
from zerver.actions.streams import do_change_subscription_property
from zerver.actions.user_groups import create_user_group
from zerver.actions.user_groups import check_add_user_group
from zerver.actions.user_settings import do_change_user_setting
from zerver.actions.user_topics import do_set_user_topic_visibility_policy
from zerver.lib.cache import cache_delete, get_muting_users_cache_key
@@ -449,10 +449,10 @@ class MissedMessageHookTest(ZulipTestCase):
)
def test_user_group_mention(self) -> None:
hamlet_and_cordelia = create_user_group(
hamlet_and_cordelia = check_add_user_group(
self.cordelia.realm,
"hamlet_and_cordelia",
[self.user_profile, self.cordelia],
self.cordelia.realm,
acting_user=None,
)
msg_id = self.send_stream_message(