mirror of https://github.com/zulip/zulip.git
Use self.example_user() in more places.
This fixes most cases where we were assigning a user to the var email and then calling get_user_profile_by_email with that var. (This was fixed mostly with a script.)
This commit is contained in:
parent
942db9b6c5
commit
6bc8424c71
|
@ -50,11 +50,8 @@ class AlertWordTests(ZulipTestCase):
|
|||
"""
|
||||
Users start out with no alert words.
|
||||
"""
|
||||
email = "cordelia@zulip.com"
|
||||
user = get_user_profile_by_email(email)
|
||||
|
||||
user = self.example_user('cordelia')
|
||||
words = user_alert_words(user)
|
||||
|
||||
self.assertEqual(words, [])
|
||||
|
||||
def test_add_word(self):
|
||||
|
@ -62,8 +59,7 @@ class AlertWordTests(ZulipTestCase):
|
|||
"""
|
||||
add_user_alert_words can add multiple alert words at once.
|
||||
"""
|
||||
email = "cordelia@zulip.com"
|
||||
user = get_user_profile_by_email(email)
|
||||
user = self.example_user('cordelia')
|
||||
|
||||
# Add several words, including multi-word and non-ascii words.
|
||||
add_user_alert_words(user, self.interesting_alert_word_list)
|
||||
|
@ -77,8 +73,7 @@ class AlertWordTests(ZulipTestCase):
|
|||
Removing alert words works via remove_user_alert_words, even
|
||||
for multi-word and non-ascii words.
|
||||
"""
|
||||
email = "cordelia@zulip.com"
|
||||
user = get_user_profile_by_email(email)
|
||||
user = self.example_user('cordelia')
|
||||
|
||||
add_user_alert_words(user, self.interesting_alert_word_list)
|
||||
|
||||
|
|
|
@ -226,11 +226,11 @@ class AuthBackendTest(ZulipTestCase):
|
|||
@override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.GoogleMobileOauth2Backend',))
|
||||
def test_google_backend(self):
|
||||
# type: () -> None
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
backend = GoogleMobileOauth2Backend()
|
||||
payload = dict(email_verified=True,
|
||||
email=email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
self.setup_subdomain(user_profile)
|
||||
|
||||
with mock.patch('apiclient.sample_tools.client.verify_id_token', return_value=payload):
|
||||
|
@ -273,9 +273,9 @@ class AuthBackendTest(ZulipTestCase):
|
|||
@override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipLDAPAuthBackend',))
|
||||
def test_ldap_backend(self):
|
||||
# type: () -> None
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
password = "test_password"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
self.setup_subdomain(user_profile)
|
||||
|
||||
username = self.get_username()
|
||||
|
@ -1364,8 +1364,8 @@ class FetchAuthBackends(ZulipTestCase):
|
|||
class TestDevAuthBackend(ZulipTestCase):
|
||||
def test_login_success(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
data = {'direct_email': email}
|
||||
result = self.client_post('/accounts/login/local/', data)
|
||||
self.assertEqual(result.status_code, 302)
|
||||
|
@ -1373,8 +1373,8 @@ class TestDevAuthBackend(ZulipTestCase):
|
|||
|
||||
def test_login_with_subdomain(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
data = {'direct_email': email}
|
||||
with self.settings(REALMS_HAVE_SUBDOMAINS=True):
|
||||
result = self.client_post('/accounts/login/local/', data)
|
||||
|
@ -1401,8 +1401,8 @@ class TestDevAuthBackend(ZulipTestCase):
|
|||
class TestZulipRemoteUserBackend(ZulipTestCase):
|
||||
def test_login_success(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipRemoteUserBackend',)):
|
||||
result = self.client_post('/accounts/login/sso/', REMOTE_USER=email)
|
||||
self.assertEqual(result.status_code, 302)
|
||||
|
@ -1416,8 +1416,7 @@ class TestZulipRemoteUserBackend(ZulipTestCase):
|
|||
def test_login_success_with_sso_append_domain(self):
|
||||
# type: () -> None
|
||||
username = 'hamlet'
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
with self.settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipRemoteUserBackend',),
|
||||
SSO_APPEND_DOMAIN='zulip.com'):
|
||||
result = self.client_post('/accounts/login/sso/', REMOTE_USER=username)
|
||||
|
@ -1478,8 +1477,8 @@ class TestZulipRemoteUserBackend(ZulipTestCase):
|
|||
|
||||
def test_login_success_under_subdomains(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
with mock.patch('zerver.views.auth.get_subdomain', return_value='zulip'):
|
||||
with self.settings(
|
||||
REALMS_HAVE_SUBDOMAINS=True,
|
||||
|
@ -1612,8 +1611,7 @@ class TestJWTLogin(ZulipTestCase):
|
|||
class TestLDAP(ZulipTestCase):
|
||||
def setUp(self):
|
||||
# type: () -> None
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
self.setup_subdomain(user_profile)
|
||||
|
||||
ldap_patcher = mock.patch('django_auth_ldap.config.ldap.initialize')
|
||||
|
|
|
@ -588,9 +588,9 @@ class DeactivatedRealmTest(ZulipTestCase):
|
|||
|
||||
"""
|
||||
realm = get_realm("zulip")
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
test_password = "abcd1234"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile.set_password(test_password)
|
||||
|
||||
self.login(email)
|
||||
|
@ -630,8 +630,8 @@ class LoginRequiredTest(ZulipTestCase):
|
|||
"""
|
||||
Verifies the zulip_login_required decorator blocks deactivated users.
|
||||
"""
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
|
||||
# Verify fails if logged-out
|
||||
result = self.client_get('/accounts/accept_terms/')
|
||||
|
@ -684,8 +684,8 @@ class InactiveUserTest(ZulipTestCase):
|
|||
rest_dispatch rejects requests from deactivated users, both /json and api
|
||||
|
||||
"""
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
do_deactivate_user(user_profile)
|
||||
|
||||
|
@ -720,8 +720,8 @@ class InactiveUserTest(ZulipTestCase):
|
|||
authenticated_json_view views fail with a deactivated user
|
||||
|
||||
"""
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
test_password = "abcd1234"
|
||||
user_profile.set_password(test_password)
|
||||
user_profile.save()
|
||||
|
@ -738,8 +738,7 @@ class InactiveUserTest(ZulipTestCase):
|
|||
logging in fails with an inactive user
|
||||
|
||||
"""
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
do_deactivate_user(user_profile)
|
||||
|
||||
result = self.login_with_return("hamlet@zulip.com")
|
||||
|
@ -751,8 +750,8 @@ class InactiveUserTest(ZulipTestCase):
|
|||
Deactivated users can't use webhooks
|
||||
|
||||
"""
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
do_deactivate_user(user_profile)
|
||||
|
||||
api_key = self.get_api_key(email)
|
||||
|
|
|
@ -133,9 +133,9 @@ class EmailChangeTestCase(ZulipTestCase):
|
|||
def test_unauthorized_email_change(self):
|
||||
# type: () -> None
|
||||
data = {'email': 'hamlet-new@zulip.com'}
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
do_set_realm_property(user_profile.realm, 'email_changes_disabled', True)
|
||||
url = '/json/settings/change'
|
||||
result = self.client_post(url, data)
|
||||
|
@ -147,7 +147,8 @@ class EmailChangeTestCase(ZulipTestCase):
|
|||
def test_unauthorized_email_change_from_email_confirmation_link(self):
|
||||
# type: () -> None
|
||||
data = {'email': 'hamlet-new@zulip.com'}
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
url = '/json/settings/change'
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
|
@ -162,7 +163,6 @@ class EmailChangeTestCase(ZulipTestCase):
|
|||
body = email_message.body
|
||||
self.assertIn('We received a request to change the email', body)
|
||||
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
do_set_realm_property(user_profile.realm, 'email_changes_disabled', True)
|
||||
|
||||
activation_url = [s for s in body.split('\n') if s][4]
|
||||
|
|
|
@ -218,9 +218,9 @@ class GetEventsTest(ZulipTestCase):
|
|||
|
||||
def test_get_events(self):
|
||||
# type: () -> None
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
recipient_email = "othello@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
recipient_user_profile = get_user_profile_by_email(recipient_email)
|
||||
self.login(email)
|
||||
|
||||
|
@ -308,8 +308,8 @@ class GetEventsTest(ZulipTestCase):
|
|||
|
||||
def test_get_events_narrow(self):
|
||||
# type: () -> None
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
|
||||
result = self.tornado_call(get_events_backend, user_profile,
|
||||
|
@ -1608,8 +1608,7 @@ class FetchInitialStateDataTest(ZulipTestCase):
|
|||
# Non-admin users don't have access to all bots
|
||||
def test_realm_bots_non_admin(self):
|
||||
# type: () -> None
|
||||
email = 'cordelia@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('cordelia')
|
||||
self.assertFalse(user_profile.is_realm_admin)
|
||||
result = fetch_initial_state_data(user_profile, None, "")
|
||||
self.assert_length(result['realm_bots'], 0)
|
||||
|
@ -1621,8 +1620,7 @@ class FetchInitialStateDataTest(ZulipTestCase):
|
|||
# Admin users have access to all bots in the realm_bots field
|
||||
def test_realm_bots_admin(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
do_change_is_admin(user_profile, True)
|
||||
self.assertTrue(user_profile.is_realm_admin)
|
||||
result = fetch_initial_state_data(user_profile, None, "")
|
||||
|
|
|
@ -78,8 +78,8 @@ class RateLimitTests(ZulipTestCase):
|
|||
|
||||
def test_headers(self):
|
||||
# type: () -> None
|
||||
email = "hamlet@zulip.com"
|
||||
user = get_user_profile_by_email(email)
|
||||
user = self.example_user('hamlet')
|
||||
email = user.email
|
||||
clear_user_history(user)
|
||||
|
||||
result = self.send_api_message(email, "some stuff")
|
||||
|
@ -89,8 +89,8 @@ class RateLimitTests(ZulipTestCase):
|
|||
|
||||
def test_ratelimit_decrease(self):
|
||||
# type: () -> None
|
||||
email = "hamlet@zulip.com"
|
||||
user = get_user_profile_by_email(email)
|
||||
user = self.example_user('hamlet')
|
||||
email = user.email
|
||||
clear_user_history(user)
|
||||
result = self.send_api_message(email, "some stuff")
|
||||
limit = int(result['X-RateLimit-Remaining'])
|
||||
|
@ -101,8 +101,8 @@ class RateLimitTests(ZulipTestCase):
|
|||
|
||||
def test_hit_ratelimits(self):
|
||||
# type: () -> None
|
||||
email = "cordelia@zulip.com"
|
||||
user = get_user_profile_by_email(email)
|
||||
user = self.example_user('cordelia')
|
||||
email = user.email
|
||||
clear_user_history(user)
|
||||
|
||||
start_time = time.time()
|
||||
|
|
|
@ -221,11 +221,11 @@ class HomeTest(ZulipTestCase):
|
|||
|
||||
def test_terms_of_service(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user = self.example_user('hamlet')
|
||||
email = user.email
|
||||
self.login(email)
|
||||
|
||||
for user_tos_version in [None, '1.1', '2.0.3.4']:
|
||||
user = get_user_profile_by_email(email)
|
||||
user.tos_version = user_tos_version
|
||||
user.save()
|
||||
|
||||
|
@ -240,10 +240,10 @@ class HomeTest(ZulipTestCase):
|
|||
|
||||
def test_terms_of_service_first_time_template(self):
|
||||
# type: () -> None
|
||||
email = "hamlet@zulip.com"
|
||||
user = self.example_user('hamlet')
|
||||
email = user.email
|
||||
self.login(email)
|
||||
|
||||
user = get_user_profile_by_email(email)
|
||||
user.tos_version = None
|
||||
user.save()
|
||||
|
||||
|
@ -279,8 +279,8 @@ class HomeTest(ZulipTestCase):
|
|||
|
||||
def test_bad_pointer(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
user_profile.pointer = 999999
|
||||
user_profile.save()
|
||||
|
||||
|
@ -359,8 +359,8 @@ class HomeTest(ZulipTestCase):
|
|||
|
||||
def test_invites_by_admins_only(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
|
||||
realm = user_profile.realm
|
||||
realm.invite_by_admins_only = True
|
||||
|
|
|
@ -60,11 +60,11 @@ class TopicHistoryTest(ZulipTestCase):
|
|||
def test_topics_history(self):
|
||||
# type: () -> None
|
||||
# verified: int(UserMessage.flags.read) == 1
|
||||
email = 'iago@zulip.com'
|
||||
user_profile = self.example_user('iago')
|
||||
email = user_profile.email
|
||||
stream_name = 'Verona'
|
||||
self.login(email)
|
||||
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
stream = get_stream(stream_name, user_profile.realm)
|
||||
recipient = get_recipient(Recipient.STREAM, stream.id)
|
||||
|
||||
|
@ -504,8 +504,8 @@ class StreamMessagesTest(ZulipTestCase):
|
|||
def test_stream_message_mirroring(self):
|
||||
# type: () -> None
|
||||
from zerver.lib.actions import do_change_is_admin
|
||||
email = "iago@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('iago')
|
||||
email = user_profile.email
|
||||
|
||||
do_change_is_admin(user_profile, True, 'api_super_user')
|
||||
result = self.client_post("/api/v1/messages", {"type": "stream",
|
||||
|
@ -772,8 +772,8 @@ class MessagePOSTTest(ZulipTestCase):
|
|||
Sending messages without a to field should be sent to the default
|
||||
stream for the user_profile.
|
||||
"""
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
user_profile.default_sending_stream = get_stream('Verona', user_profile.realm)
|
||||
user_profile.save()
|
||||
result = self.client_post("/api/v1/messages", {"type": "stream",
|
||||
|
|
|
@ -65,8 +65,8 @@ class UserPresenceModelTests(ZulipTestCase):
|
|||
# type: () -> None
|
||||
UserPresence.objects.all().delete()
|
||||
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
presence_dct = UserPresence.get_status_dict_by_realm(user_profile.realm_id)
|
||||
self.assertEqual(len(presence_dct), 0)
|
||||
|
||||
|
|
|
@ -149,8 +149,8 @@ class PushBouncerNotificationTest(ZulipTestCase):
|
|||
push notification bouncer flow
|
||||
"""
|
||||
mock.side_effect = self.bounce_request
|
||||
email = "cordelia@zulip.com"
|
||||
user = get_user_profile_by_email(email)
|
||||
user = self.example_user('cordelia')
|
||||
email = user.email
|
||||
self.login(email)
|
||||
server = RemoteZulipServer.objects.get(uuid=self.server_uuid)
|
||||
|
||||
|
@ -295,8 +295,8 @@ class ResponseListenerTest(PushNotificationTest):
|
|||
class TestPushApi(ZulipTestCase):
|
||||
def test_push_api(self):
|
||||
# type: () -> None
|
||||
email = "cordelia@zulip.com"
|
||||
user = get_user_profile_by_email(email)
|
||||
user = self.example_user('cordelia')
|
||||
email = user.email
|
||||
self.login(email)
|
||||
|
||||
endpoints = [
|
||||
|
|
|
@ -106,9 +106,9 @@ class RealmTest(ZulipTestCase):
|
|||
# type: () -> None
|
||||
new_name = 'Mice will play while the cat is away'
|
||||
|
||||
email = 'othello@zulip.com'
|
||||
user_profile = self.example_user('othello')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
do_change_is_admin(user_profile, False)
|
||||
|
||||
req = dict(name=ujson.dumps(new_name))
|
||||
|
@ -118,9 +118,9 @@ class RealmTest(ZulipTestCase):
|
|||
def test_unauthorized_name_change(self):
|
||||
# type: () -> None
|
||||
data = {'full_name': 'Sir Hamlet'}
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
do_set_realm_property(user_profile.realm, 'name_changes_disabled', True)
|
||||
url = '/json/settings/change'
|
||||
result = self.client_post(url, data)
|
||||
|
@ -171,9 +171,9 @@ class RealmAPITest(ZulipTestCase):
|
|||
|
||||
def setUp(self):
|
||||
# type: () -> None
|
||||
email = 'cordelia@zulip.com'
|
||||
user_profile = self.example_user('cordelia')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
do_change_is_admin(user_profile, True)
|
||||
|
||||
def set_up_db(self, attr, value):
|
||||
|
|
|
@ -143,9 +143,9 @@ class RecipientTest(ZulipTestCase):
|
|||
class StreamAdminTest(ZulipTestCase):
|
||||
def test_make_stream_public(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
self.make_stream('private_stream', invite_only=True)
|
||||
|
||||
do_change_is_admin(user_profile, True)
|
||||
|
@ -173,9 +173,9 @@ class StreamAdminTest(ZulipTestCase):
|
|||
|
||||
def test_make_stream_private(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
realm = user_profile.realm
|
||||
self.make_stream('public_stream', realm=realm)
|
||||
|
||||
|
@ -192,9 +192,9 @@ class StreamAdminTest(ZulipTestCase):
|
|||
|
||||
def test_deactivate_stream_backend(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
stream = self.make_stream('new_stream')
|
||||
self.subscribe_to_stream(user_profile.email, stream.name)
|
||||
do_change_is_admin(user_profile, True)
|
||||
|
@ -219,9 +219,9 @@ class StreamAdminTest(ZulipTestCase):
|
|||
|
||||
def test_deactivate_stream_backend_requires_existing_stream(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
self.make_stream('new_stream')
|
||||
do_change_is_admin(user_profile, True)
|
||||
|
||||
|
@ -230,8 +230,8 @@ class StreamAdminTest(ZulipTestCase):
|
|||
|
||||
def test_deactivate_stream_backend_requires_realm_admin(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
self.subscribe_to_stream(email, 'new_stream')
|
||||
|
||||
|
@ -241,10 +241,10 @@ class StreamAdminTest(ZulipTestCase):
|
|||
|
||||
def test_private_stream_live_updates(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
do_change_is_admin(user_profile, True)
|
||||
|
||||
self.make_stream('private_stream', invite_only=True)
|
||||
|
@ -284,9 +284,9 @@ class StreamAdminTest(ZulipTestCase):
|
|||
|
||||
def test_rename_stream(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
realm = user_profile.realm
|
||||
stream = self.subscribe_to_stream(email, 'stream_name1')
|
||||
do_change_is_admin(user_profile, True)
|
||||
|
@ -380,8 +380,8 @@ class StreamAdminTest(ZulipTestCase):
|
|||
|
||||
def test_rename_stream_requires_realm_admin(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
self.make_stream('stream_name1')
|
||||
|
||||
|
@ -392,9 +392,9 @@ class StreamAdminTest(ZulipTestCase):
|
|||
|
||||
def test_change_stream_description(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
realm = user_profile.realm
|
||||
self.subscribe_to_stream(email, 'stream_name1')
|
||||
do_change_is_admin(user_profile, True)
|
||||
|
@ -428,9 +428,9 @@ class StreamAdminTest(ZulipTestCase):
|
|||
|
||||
def test_change_stream_description_requires_realm_admin(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
|
||||
self.subscribe_to_stream(email, 'stream_name1')
|
||||
do_change_is_admin(user_profile, False)
|
||||
|
@ -446,9 +446,9 @@ class StreamAdminTest(ZulipTestCase):
|
|||
"""
|
||||
Create a stream for deletion by an administrator.
|
||||
"""
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
stream = self.make_stream(stream_name, invite_only=invite_only)
|
||||
|
||||
# For testing deleting streams you aren't on.
|
||||
|
@ -548,9 +548,9 @@ class StreamAdminTest(ZulipTestCase):
|
|||
# type: (bool, bool, bool, bool) -> HttpResponse
|
||||
|
||||
# Set up the main user, who is in most cases an admin.
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
if is_admin:
|
||||
do_change_is_admin(user_profile, True)
|
||||
|
||||
|
@ -635,8 +635,8 @@ class StreamAdminTest(ZulipTestCase):
|
|||
the number of days since the user had joined is less than waiting period
|
||||
threshold, non admin users shouldn't be able to create new streams.
|
||||
"""
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
do_set_realm_property(user_profile.realm, 'create_stream_by_admins_only', True)
|
||||
|
||||
|
@ -653,8 +653,8 @@ class StreamAdminTest(ZulipTestCase):
|
|||
Non admin users with account age greater or equal to waiting period
|
||||
threshold should be able to create new streams.
|
||||
"""
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
do_change_is_admin(user_profile, False)
|
||||
|
||||
|
@ -1651,8 +1651,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
|||
bulk_add_subscriptions([stream], [existing_user_profile])
|
||||
|
||||
# Now subscribe Cordelia to the stream, capturing events
|
||||
email = 'cordelia@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('cordelia')
|
||||
|
||||
events = [] # type: List[Dict[str, Any]]
|
||||
with tornado_redirected_to_list(events):
|
||||
|
@ -2229,7 +2228,8 @@ class InviteOnlyStreamTest(ZulipTestCase):
|
|||
def test_inviteonly(self):
|
||||
# type: () -> None
|
||||
# Creating an invite-only stream is allowed
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
stream_name = "Saxony"
|
||||
|
||||
result = self.common_subscribe_to_streams(email, [stream_name], invite_only=True)
|
||||
|
@ -2240,13 +2240,15 @@ class InviteOnlyStreamTest(ZulipTestCase):
|
|||
self.assertEqual(json["already_subscribed"], {})
|
||||
|
||||
# Subscribing oneself to an invite-only stream is not allowed
|
||||
email = "othello@zulip.com"
|
||||
user_profile = self.example_user('othello')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
result = self.common_subscribe_to_streams(email, [stream_name])
|
||||
self.assert_json_error(result, 'Unable to access stream (Saxony).')
|
||||
|
||||
# authorization_errors_fatal=False works
|
||||
email = "othello@zulip.com"
|
||||
user_profile = self.example_user('othello')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
result = self.common_subscribe_to_streams(email, [stream_name],
|
||||
extra_post_data={'authorization_errors_fatal': ujson.dumps(False)})
|
||||
|
@ -2257,8 +2259,8 @@ class InviteOnlyStreamTest(ZulipTestCase):
|
|||
self.assertEqual(json["already_subscribed"], {})
|
||||
|
||||
# Inviting another user to an invite-only stream is allowed
|
||||
email = 'hamlet@zulip.com'
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
self.login(email)
|
||||
result = self.common_subscribe_to_streams(
|
||||
email, [stream_name],
|
||||
|
|
|
@ -164,8 +164,8 @@ class TemplateTestCase(ZulipTestCase):
|
|||
context.
|
||||
|
||||
"""
|
||||
email = "hamlet@zulip.com"
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
|
||||
context = dict(
|
||||
article="zerver/help/index.md",
|
||||
|
|
|
@ -28,8 +28,8 @@ def fix_params(raw_params):
|
|||
class TutorialTests(ZulipTestCase):
|
||||
def test_send_message(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
user = get_user_profile_by_email(email)
|
||||
user = self.example_user('hamlet')
|
||||
email = user.email
|
||||
self.login(email)
|
||||
|
||||
welcome_bot = get_user_profile_by_email("welcome-bot@zulip.com")
|
||||
|
|
Loading…
Reference in New Issue