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

@@ -1,4 +1,4 @@
from zerver.actions.user_groups import create_user_group
from zerver.actions.user_groups import check_add_user_group
from zerver.lib.mention import MentionBackend, MentionData
from zerver.lib.notification_data import UserMessageNotificationsData, get_user_group_mentions_data
from zerver.lib.test_classes import ZulipTestCase
@@ -275,9 +275,9 @@ class TestNotificationData(ZulipTestCase):
cordelia = self.example_user("cordelia")
realm = hamlet.realm
hamlet_only = create_user_group("hamlet_only", [hamlet], realm, acting_user=None)
hamlet_and_cordelia = create_user_group(
"hamlet_and_cordelia", [hamlet, cordelia], realm, acting_user=None
hamlet_only = check_add_user_group(realm, "hamlet_only", [hamlet], acting_user=None)
hamlet_and_cordelia = check_add_user_group(
realm, "hamlet_and_cordelia", [hamlet, cordelia], acting_user=None
)
mention_backend = MentionBackend(realm.id)