mirror of https://github.com/zulip/zulip.git
do_invite_users: Turn some args into kwargs-only.
This commit is contained in:
parent
8c1ea78d7d
commit
3205f680c1
|
@ -1372,7 +1372,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
|
||||||
user,
|
user,
|
||||||
["user1@domain.tld", "user2@domain.tld"],
|
["user1@domain.tld", "user2@domain.tld"],
|
||||||
[stream],
|
[stream],
|
||||||
invite_expires_in_days,
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
)
|
)
|
||||||
assertInviteCountEquals(2)
|
assertInviteCountEquals(2)
|
||||||
|
|
||||||
|
@ -1382,7 +1382,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
|
||||||
user,
|
user,
|
||||||
["user1@domain.tld", "user2@domain.tld"],
|
["user1@domain.tld", "user2@domain.tld"],
|
||||||
[stream],
|
[stream],
|
||||||
invite_expires_in_days,
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
)
|
)
|
||||||
assertInviteCountEquals(4)
|
assertInviteCountEquals(4)
|
||||||
|
|
||||||
|
@ -1392,7 +1392,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
|
||||||
user,
|
user,
|
||||||
["user3@domain.tld", "malformed"],
|
["user3@domain.tld", "malformed"],
|
||||||
[stream],
|
[stream],
|
||||||
invite_expires_in_days,
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
)
|
)
|
||||||
except InvitationError:
|
except InvitationError:
|
||||||
pass
|
pass
|
||||||
|
@ -1404,7 +1404,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
|
||||||
user,
|
user,
|
||||||
["first@domain.tld", "user4@domain.tld"],
|
["first@domain.tld", "user4@domain.tld"],
|
||||||
[stream],
|
[stream],
|
||||||
invite_expires_in_days,
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
)
|
)
|
||||||
except InvitationError:
|
except InvitationError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -6958,6 +6958,7 @@ def do_invite_users(
|
||||||
user_profile: UserProfile,
|
user_profile: UserProfile,
|
||||||
invitee_emails: Collection[str],
|
invitee_emails: Collection[str],
|
||||||
streams: Collection[Stream],
|
streams: Collection[Stream],
|
||||||
|
*,
|
||||||
invite_expires_in_days: int,
|
invite_expires_in_days: int,
|
||||||
invite_as: int = PreregistrationUser.INVITE_AS["MEMBER"],
|
invite_as: int = PreregistrationUser.INVITE_AS["MEMBER"],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
@ -1766,7 +1766,7 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase):
|
||||||
iago,
|
iago,
|
||||||
[email],
|
[email],
|
||||||
[],
|
[],
|
||||||
invite_expires_in_days,
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
invite_as=PreregistrationUser.INVITE_AS["REALM_ADMIN"],
|
invite_as=PreregistrationUser.INVITE_AS["REALM_ADMIN"],
|
||||||
)
|
)
|
||||||
now = timezone_now() + datetime.timedelta(days=invite_expires_in_days + 1)
|
now = timezone_now() + datetime.timedelta(days=invite_expires_in_days + 1)
|
||||||
|
|
|
@ -652,7 +652,10 @@ class NormalActionsTest(BaseAction):
|
||||||
invite_expires_in_days = 2
|
invite_expires_in_days = 2
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
lambda: do_invite_users(
|
lambda: do_invite_users(
|
||||||
self.user_profile, ["foo@zulip.com"], streams, invite_expires_in_days
|
self.user_profile,
|
||||||
|
["foo@zulip.com"],
|
||||||
|
streams,
|
||||||
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
),
|
),
|
||||||
state_change_expected=False,
|
state_change_expected=False,
|
||||||
)
|
)
|
||||||
|
@ -683,7 +686,12 @@ class NormalActionsTest(BaseAction):
|
||||||
streams.append(get_stream(stream_name, self.user_profile.realm))
|
streams.append(get_stream(stream_name, self.user_profile.realm))
|
||||||
|
|
||||||
invite_expires_in_days = 2
|
invite_expires_in_days = 2
|
||||||
do_invite_users(self.user_profile, ["foo@zulip.com"], streams, invite_expires_in_days)
|
do_invite_users(
|
||||||
|
self.user_profile,
|
||||||
|
["foo@zulip.com"],
|
||||||
|
streams,
|
||||||
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
|
)
|
||||||
prereg_users = PreregistrationUser.objects.filter(
|
prereg_users = PreregistrationUser.objects.filter(
|
||||||
referred_by__realm=self.user_profile.realm
|
referred_by__realm=self.user_profile.realm
|
||||||
)
|
)
|
||||||
|
@ -723,7 +731,12 @@ class NormalActionsTest(BaseAction):
|
||||||
streams.append(get_stream(stream_name, self.user_profile.realm))
|
streams.append(get_stream(stream_name, self.user_profile.realm))
|
||||||
|
|
||||||
invite_expires_in_days = 2
|
invite_expires_in_days = 2
|
||||||
do_invite_users(self.user_profile, ["foo@zulip.com"], streams, invite_expires_in_days)
|
do_invite_users(
|
||||||
|
self.user_profile,
|
||||||
|
["foo@zulip.com"],
|
||||||
|
streams,
|
||||||
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
|
)
|
||||||
prereg_user = PreregistrationUser.objects.get(email="foo@zulip.com")
|
prereg_user = PreregistrationUser.objects.get(email="foo@zulip.com")
|
||||||
|
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
|
|
|
@ -2040,15 +2040,32 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
|
||||||
streams.append(get_stream(stream_name, self.user_profile.realm))
|
streams.append(get_stream(stream_name, self.user_profile.realm))
|
||||||
|
|
||||||
invite_expires_in_days = 2
|
invite_expires_in_days = 2
|
||||||
do_invite_users(self.user_profile, ["foo@zulip.com"], streams, invite_expires_in_days)
|
do_invite_users(
|
||||||
|
self.user_profile,
|
||||||
|
["foo@zulip.com"],
|
||||||
|
streams,
|
||||||
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
|
)
|
||||||
prereg_user = PreregistrationUser.objects.get(email="foo@zulip.com")
|
prereg_user = PreregistrationUser.objects.get(email="foo@zulip.com")
|
||||||
do_invite_users(self.user_profile, ["foo@zulip.com"], streams, invite_expires_in_days)
|
do_invite_users(
|
||||||
do_invite_users(self.user_profile, ["foo@zulip.com"], streams, invite_expires_in_days)
|
self.user_profile,
|
||||||
|
["foo@zulip.com"],
|
||||||
|
streams,
|
||||||
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
|
)
|
||||||
|
do_invite_users(
|
||||||
|
self.user_profile,
|
||||||
|
["foo@zulip.com"],
|
||||||
|
streams,
|
||||||
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
|
)
|
||||||
|
|
||||||
# Also send an invite from a different realm.
|
# Also send an invite from a different realm.
|
||||||
lear = get_realm("lear")
|
lear = get_realm("lear")
|
||||||
lear_user = self.lear_user("cordelia")
|
lear_user = self.lear_user("cordelia")
|
||||||
do_invite_users(lear_user, ["foo@zulip.com"], [], invite_expires_in_days)
|
do_invite_users(
|
||||||
|
lear_user, ["foo@zulip.com"], [], invite_expires_in_days=invite_expires_in_days
|
||||||
|
)
|
||||||
|
|
||||||
invites = PreregistrationUser.objects.filter(email__iexact="foo@zulip.com")
|
invites = PreregistrationUser.objects.filter(email__iexact="foo@zulip.com")
|
||||||
self.assert_length(invites, 4)
|
self.assert_length(invites, 4)
|
||||||
|
@ -2185,11 +2202,30 @@ class InvitationsTestCase(InviteUserBase):
|
||||||
streams.append(get_stream(stream_name, user_profile.realm))
|
streams.append(get_stream(stream_name, user_profile.realm))
|
||||||
|
|
||||||
invite_expires_in_days = 2
|
invite_expires_in_days = 2
|
||||||
do_invite_users(user_profile, ["TestOne@zulip.com"], streams, invite_expires_in_days)
|
do_invite_users(
|
||||||
do_invite_users(user_profile, ["TestTwo@zulip.com"], streams, invite_expires_in_days)
|
user_profile,
|
||||||
do_invite_users(hamlet, ["TestThree@zulip.com"], streams, invite_expires_in_days)
|
["TestOne@zulip.com"],
|
||||||
do_invite_users(othello, ["TestFour@zulip.com"], streams, invite_expires_in_days)
|
streams,
|
||||||
do_invite_users(self.mit_user("sipbtest"), ["TestOne@mit.edu"], [], invite_expires_in_days)
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
|
)
|
||||||
|
do_invite_users(
|
||||||
|
user_profile,
|
||||||
|
["TestTwo@zulip.com"],
|
||||||
|
streams,
|
||||||
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
|
)
|
||||||
|
do_invite_users(
|
||||||
|
hamlet, ["TestThree@zulip.com"], streams, invite_expires_in_days=invite_expires_in_days
|
||||||
|
)
|
||||||
|
do_invite_users(
|
||||||
|
othello, ["TestFour@zulip.com"], streams, invite_expires_in_days=invite_expires_in_days
|
||||||
|
)
|
||||||
|
do_invite_users(
|
||||||
|
self.mit_user("sipbtest"),
|
||||||
|
["TestOne@mit.edu"],
|
||||||
|
[],
|
||||||
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
|
)
|
||||||
do_create_multiuse_invite_link(
|
do_create_multiuse_invite_link(
|
||||||
user_profile, PreregistrationUser.INVITE_AS["MEMBER"], invite_expires_in_days
|
user_profile, PreregistrationUser.INVITE_AS["MEMBER"], invite_expires_in_days
|
||||||
)
|
)
|
||||||
|
@ -2216,13 +2252,23 @@ class InvitationsTestCase(InviteUserBase):
|
||||||
streams.append(get_stream(stream_name, user_profile.realm))
|
streams.append(get_stream(stream_name, user_profile.realm))
|
||||||
|
|
||||||
invite_expires_in_days = 2
|
invite_expires_in_days = 2
|
||||||
do_invite_users(user_profile, ["TestOne@zulip.com"], streams, invite_expires_in_days)
|
do_invite_users(
|
||||||
|
user_profile,
|
||||||
|
["TestOne@zulip.com"],
|
||||||
|
streams,
|
||||||
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"confirmation.models.timezone_now",
|
"confirmation.models.timezone_now",
|
||||||
return_value=timezone_now() - datetime.timedelta(days=invite_expires_in_days + 1),
|
return_value=timezone_now() - datetime.timedelta(days=invite_expires_in_days + 1),
|
||||||
):
|
):
|
||||||
do_invite_users(user_profile, ["TestTwo@zulip.com"], streams, invite_expires_in_days)
|
do_invite_users(
|
||||||
|
user_profile,
|
||||||
|
["TestTwo@zulip.com"],
|
||||||
|
streams,
|
||||||
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
|
)
|
||||||
do_create_multiuse_invite_link(
|
do_create_multiuse_invite_link(
|
||||||
othello, PreregistrationUser.INVITE_AS["MEMBER"], invite_expires_in_days
|
othello, PreregistrationUser.INVITE_AS["MEMBER"], invite_expires_in_days
|
||||||
)
|
)
|
||||||
|
|
|
@ -76,7 +76,13 @@ def invite_users_backend(
|
||||||
)
|
)
|
||||||
streams.append(stream)
|
streams.append(stream)
|
||||||
|
|
||||||
do_invite_users(user_profile, invitee_emails, streams, invite_expires_in_days, invite_as)
|
do_invite_users(
|
||||||
|
user_profile,
|
||||||
|
invitee_emails,
|
||||||
|
streams,
|
||||||
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
|
invite_as=invite_as,
|
||||||
|
)
|
||||||
return json_success()
|
return json_success()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue