users: Modify do_create_user and create_user to accept role.

We change do_create_user and create_user to accept
role as a parameter instead of 'is_realm_admin' and 'is_guest'.
These changes are done to minimize data conversions between
role and boolean fields.
This commit is contained in:
Sahil Batra
2020-06-03 04:41:36 +05:30
committed by GitHub
parent cfc87e3925
commit 77d4be56a4
7 changed files with 23 additions and 23 deletions

View File

@@ -59,7 +59,7 @@ class Command(BaseCommand):
with mock.patch("zerver.lib.create_user.timezone_now", return_value=installation_time):
shylock = create_user('shylock@analytics.ds', 'Shylock', realm,
full_name='Shylock', short_name='shylock',
is_realm_admin=True)
role=UserProfile.ROLE_REALM_ADMINISTRATOR)
do_change_user_role(shylock, UserProfile.ROLE_REALM_ADMINISTRATOR)
stream = Stream.objects.create(
name='all', realm=realm, date_created=installation_time)

View File

@@ -67,7 +67,7 @@ class AnalyticsTestCase(TestCase):
return create_user(kwargs['email'], 'password', kwargs['realm'],
active=kwargs['is_active'],
full_name=kwargs['full_name'], short_name=kwargs['short_name'],
is_realm_admin=True, **pass_kwargs)
role=UserProfile.ROLE_REALM_ADMINISTRATOR, **pass_kwargs)
def create_stream_with_recipient(self, **kwargs: Any) -> Tuple[Stream, Recipient]:
self.name_counter += 1