realms: Create default system user groups for internal realm.

Since we include internal realms while creating system groups
in "0382_create_role_based_system_groups.py", we should do it
when creating new internal realms as well to be consistent.

Tests are changed accordingly as UserGroup objects are created.
We also change the user group ids used in api docs examples
such that user groups are of correct realm.
This commit is contained in:
Sahil Batra
2022-06-28 22:34:17 +05:30
committed by Tim Abbott
parent 9b8d9d038a
commit 393afc9781
3 changed files with 5 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ from typing import Iterable, Optional, Tuple
from django.conf import settings
from zerver.lib.bulk_create import bulk_create_users
from zerver.lib.user_groups import create_system_user_groups_for_realm
from zerver.models import (
Realm,
RealmAuditLog,
@@ -25,6 +26,7 @@ def create_internal_realm() -> None:
realm=realm, event_type=RealmAuditLog.REALM_CREATED, event_time=realm.date_created
)
RealmUserDefault.objects.create(realm=realm)
create_system_user_groups_for_realm(realm)
# Create some client objects for common requests. Not required;
# just ensures these get low IDs in production, and in development

View File

@@ -14303,7 +14303,7 @@ paths:
type: array
items:
type: integer
example: [1, 2]
example: [8, 9]
required: false
responses:
"200":
@@ -16459,7 +16459,7 @@ components:
The ID of the target user group.
schema:
type: integer
example: 22
example: 29
required: true
QueueId:
name: queue_id

View File

@@ -39,7 +39,7 @@ class UserGroupTestCase(ZulipTestCase):
def test_user_groups_in_realm_serialized(self) -> None:
realm = get_realm("zulip")
user_group = UserGroup.objects.first()
user_group = UserGroup.objects.filter(realm=realm).first()
assert user_group is not None
membership = UserGroupMembership.objects.filter(user_group=user_group).values_list(
"user_profile_id", flat=True