populate_db: Add users to initial private stream in mit and lear realm.

We do not allow keeping vacant private streams as we deactivate them
when all users are unsubscribed, so it is better to add at least one
user in the initial private stream created while creating realm.
This commit is contained in:
Sahil Batra 2022-05-14 16:37:14 +05:30 committed by Tim Abbott
parent aa46d8d2a8
commit 6e8523015c
1 changed files with 16 additions and 0 deletions

View File

@ -26,6 +26,7 @@ from zerver.actions.custom_profile_fields import (
) )
from zerver.actions.message_send import build_message_send_dict, do_send_messages from zerver.actions.message_send import build_message_send_dict, do_send_messages
from zerver.actions.realm_emoji import check_add_realm_emoji from zerver.actions.realm_emoji import check_add_realm_emoji
from zerver.actions.streams import bulk_add_subscriptions
from zerver.actions.users import do_change_user_role from zerver.actions.users import do_change_user_role
from zerver.lib.bulk_create import bulk_create_streams from zerver.lib.bulk_create import bulk_create_streams
from zerver.lib.generate_test_data import create_test_data, generate_topics from zerver.lib.generate_test_data import create_test_data, generate_topics
@ -825,6 +826,7 @@ class Command(BaseCommand):
if options["test_suite"]: if options["test_suite"]:
# Create test users; the MIT ones are needed to test # Create test users; the MIT ones are needed to test
# the Zephyr mirroring codepaths. # the Zephyr mirroring codepaths.
event_time = timezone_now()
testsuite_mit_users = [ testsuite_mit_users = [
("Fred Sipb (MIT)", "sipbtest@mit.edu"), ("Fred Sipb (MIT)", "sipbtest@mit.edu"),
("Athena Consulting Exchange User (MIT)", "starnine@mit.edu"), ("Athena Consulting Exchange User (MIT)", "starnine@mit.edu"),
@ -834,6 +836,12 @@ class Command(BaseCommand):
mit_realm, testsuite_mit_users, tos_version=settings.TERMS_OF_SERVICE_VERSION mit_realm, testsuite_mit_users, tos_version=settings.TERMS_OF_SERVICE_VERSION
) )
mit_user = get_user_by_delivery_email("sipbtest@mit.edu", mit_realm)
mit_signup_stream = Stream.objects.get(
name=Realm.INITIAL_PRIVATE_STREAM_NAME, realm=mit_realm
)
bulk_add_subscriptions(mit_realm, [mit_signup_stream], [mit_user], acting_user=None)
testsuite_lear_users = [ testsuite_lear_users = [
("King Lear", "king@lear.org"), ("King Lear", "king@lear.org"),
("Cordelia, Lear's daughter", "cordelia@zulip.com"), ("Cordelia, Lear's daughter", "cordelia@zulip.com"),
@ -842,6 +850,14 @@ class Command(BaseCommand):
lear_realm, testsuite_lear_users, tos_version=settings.TERMS_OF_SERVICE_VERSION lear_realm, testsuite_lear_users, tos_version=settings.TERMS_OF_SERVICE_VERSION
) )
lear_user = get_user_by_delivery_email("king@lear.org", lear_realm)
lear_signup_stream = Stream.objects.get(
name=Realm.INITIAL_PRIVATE_STREAM_NAME, realm=lear_realm
)
bulk_add_subscriptions(
lear_realm, [lear_signup_stream], [lear_user], acting_user=None
)
if not options["test_suite"]: if not options["test_suite"]:
# To keep the messages.json fixtures file for the test # To keep the messages.json fixtures file for the test
# suite fast, don't add these users and subscriptions # suite fast, don't add these users and subscriptions