Remove active parameter from do_create_user().

Almost all callers to do_create_user were trying to
create active users, except for one test.  The
active=False codepath was kind of broken (things
like sending welcome messages had sort of undefined
behavior there), so instead of trying to maintain it,
we just update the one test (`test_people`) to flip the
`is_active` flag manually.

Fixes #7197
This commit is contained in:
Steve Howell
2017-10-28 10:22:02 -07:00
committed by Tim Abbott
parent d6c47573b2
commit d132c30c24
5 changed files with 10 additions and 9 deletions

View File

@@ -428,16 +428,16 @@ def notify_created_bot(user_profile):
send_event(event, bot_owner_user_ids(user_profile)) send_event(event, bot_owner_user_ids(user_profile))
def do_create_user(email, password, realm, full_name, short_name, def do_create_user(email, password, realm, full_name, short_name,
active=True, is_realm_admin=False, bot_type=None, bot_owner=None, tos_version=None, is_realm_admin=False, bot_type=None, bot_owner=None, tos_version=None,
timezone=u"", avatar_source=UserProfile.AVATAR_FROM_GRAVATAR, timezone=u"", avatar_source=UserProfile.AVATAR_FROM_GRAVATAR,
default_sending_stream=None, default_events_register_stream=None, default_sending_stream=None, default_events_register_stream=None,
default_all_public_streams=None, prereg_user=None, default_all_public_streams=None, prereg_user=None,
newsletter_data=None, default_stream_groups=[]): newsletter_data=None, default_stream_groups=[]):
# type: (Text, Optional[Text], Realm, Text, Text, bool, bool, Optional[int], Optional[UserProfile], Optional[Text], Text, Text, Optional[Stream], Optional[Stream], bool, Optional[PreregistrationUser], Optional[Dict[str, str]], List[DefaultStreamGroup]) -> UserProfile # type: (Text, Optional[Text], Realm, Text, Text, bool, Optional[int], Optional[UserProfile], Optional[Text], Text, Text, Optional[Stream], Optional[Stream], bool, Optional[PreregistrationUser], Optional[Dict[str, str]], List[DefaultStreamGroup]) -> UserProfile
user_profile = create_user(email=email, password=password, realm=realm, user_profile = create_user(email=email, password=password, realm=realm,
full_name=full_name, short_name=short_name, full_name=full_name, short_name=short_name,
active=active, is_realm_admin=is_realm_admin, is_realm_admin=is_realm_admin,
bot_type=bot_type, bot_owner=bot_owner, bot_type=bot_type, bot_owner=bot_owner,
tos_version=tos_version, timezone=timezone, avatar_source=avatar_source, tos_version=tos_version, timezone=timezone, avatar_source=avatar_source,
default_sending_stream=default_sending_stream, default_sending_stream=default_sending_stream,

View File

@@ -388,8 +388,13 @@ class HomeTest(ZulipTestCase):
realm=realm, realm=realm,
full_name=name, full_name=name,
short_name=name, short_name=name,
active=False
) )
# Doing a full-stack deactivation would be expensive here,
# and we really only need to flip the flag to get a valid
# test.
user.is_active = False
user.save()
return user return user
@slow('creating users and loading home page') @slow('creating users and loading home page')

View File

@@ -649,7 +649,6 @@ class StreamMessagesTest(ZulipTestCase):
realm=realm, realm=realm,
full_name='Normal Bot', full_name='Normal Bot',
short_name='', short_name='',
active=True,
bot_type=UserProfile.DEFAULT_BOT, bot_type=UserProfile.DEFAULT_BOT,
bot_owner=cordelia, bot_owner=cordelia,
) )
@@ -2313,7 +2312,6 @@ class CheckMessageTest(ZulipTestCase):
realm=parent.realm, realm=parent.realm,
full_name='', full_name='',
short_name='', short_name='',
active=True,
bot_type=UserProfile.DEFAULT_BOT, bot_type=UserProfile.DEFAULT_BOT,
bot_owner=parent bot_owner=parent
) )

View File

@@ -438,7 +438,6 @@ class RecipientInfoTest(ZulipTestCase):
realm=realm, realm=realm,
full_name='', full_name='',
short_name='', short_name='',
active=True,
bot_type=UserProfile.EMBEDDED_BOT, bot_type=UserProfile.EMBEDDED_BOT,
) )
@@ -459,7 +458,6 @@ class RecipientInfoTest(ZulipTestCase):
realm=realm, realm=realm,
full_name='', full_name='',
short_name='', short_name='',
active=True,
bot_type=UserProfile.DEFAULT_BOT, bot_type=UserProfile.DEFAULT_BOT,
) )

View File

@@ -297,7 +297,7 @@ def add_bot_backend(request, user_profile, full_name_raw=REQ("full_name"), short
bot_profile = do_create_user(email=email, password='', bot_profile = do_create_user(email=email, password='',
realm=user_profile.realm, full_name=full_name, realm=user_profile.realm, full_name=full_name,
short_name=short_name, active=True, short_name=short_name,
bot_type=bot_type, bot_type=bot_type,
bot_owner=user_profile, bot_owner=user_profile,
avatar_source=avatar_source, avatar_source=avatar_source,