diff --git a/zerver/lib/bulk_create.py b/zerver/lib/bulk_create.py index 239e079e44..9557c870fb 100644 --- a/zerver/lib/bulk_create.py +++ b/zerver/lib/bulk_create.py @@ -6,8 +6,8 @@ from zerver.models import Realm, Stream, UserProfile, Huddle, \ Subscription, Recipient, Client, RealmAuditLog, get_huddle_hash from zerver.lib.create_user import create_user_profile -def bulk_create_users(realm, users_raw, bot_type=None, tos_version=None, timezone=u""): - # type: (Realm, Set[Tuple[Text, Text, Text, bool]], Optional[int], Optional[Text], Text) -> None +def bulk_create_users(realm, users_raw, bot_type=None, bot_owner=None, tos_version=None, timezone=u""): + # type: (Realm, Set[Tuple[Text, Text, Text, bool]], Optional[int], Optional[UserProfile], Optional[Text], Text) -> None """ Creates and saves a UserProfile with the given email. Has some code based off of UserManage.create_user, but doesn't .save() @@ -20,7 +20,7 @@ def bulk_create_users(realm, users_raw, bot_type=None, tos_version=None, timezon for (email, full_name, short_name, active) in users: profile = create_user_profile(realm, email, initial_password(email), active, bot_type, - full_name, short_name, None, False, tos_version, + full_name, short_name, bot_owner, False, tos_version, timezone, tutorial_status=UserProfile.TUTORIAL_FINISHED, enter_sends=True) profiles_to_create.append(profile) diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index beef974be8..acae1d93bf 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -227,6 +227,7 @@ class ZulipTestCase(TestCase): aaron=u'aaron@zulip.com', ZOE=u'ZOE@zulip.com', webhook_bot=u'webhook-bot@zulip.com', + outgoing_webhook_bot=u'outgoing-webhook@zulip.com' ) mit_user_map = dict( diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py index 2d1f455646..11acfb0751 100644 --- a/zilencer/management/commands/populate_db.py +++ b/zilencer/management/commands/populate_db.py @@ -25,7 +25,7 @@ import os import ujson import itertools from six.moves import range -from typing import Any, Callable, Dict, List, Iterable, Mapping, Sequence, Set, Tuple, Text +from typing import Any, Callable, Dict, List, Iterable, Mapping, Optional, Sequence, Set, Tuple, Text settings.TORNADO_SERVER = None # Disable using memcached caches to avoid 'unsupported pickle @@ -35,14 +35,14 @@ settings.CACHES['default'] = { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache' } -def create_users(realm, name_list, bot_type=None): - # type: (Realm, Iterable[Tuple[Text, Text]], int) -> None +def create_users(realm, name_list, bot_type=None, bot_owner=None): + # type: (Realm, Iterable[Tuple[Text, Text]], Optional[int], Optional[UserProfile]) -> None user_set = set() # type: Set[Tuple[Text, Text, Text, bool]] for full_name, email in name_list: short_name = email_to_username(email) user_set.add((email, full_name, short_name, True)) tos_version = settings.TOS_VERSION if bot_type is None else None - bulk_create_users(realm, user_set, bot_type=bot_type, tos_version=tos_version) + bulk_create_users(realm, user_set, bot_type=bot_type, bot_owner=bot_owner, tos_version=tos_version) class Command(BaseCommand): help = "Populate a test database" @@ -294,8 +294,9 @@ class Command(BaseCommand): zulip_outgoing_bots = [ ("Outgoing Webhook", "outgoing-webhook@zulip.com") ] + aaron = get_user("AARON@zulip.com", zulip_realm) create_users(zulip_realm, zulip_outgoing_bots, - bot_type=UserProfile.OUTGOING_WEBHOOK_BOT) + bot_type=UserProfile.OUTGOING_WEBHOOK_BOT, bot_owner=aaron) # TODO: Clean up this initial bot creation code Service.objects.create( name="test",