Replace iago@zulip.com with example_email('iago').

This commit is contained in:
Vishnu Ks 2017-05-24 16:44:04 -07:00 committed by Tim Abbott
parent 5230eaef1c
commit 961b35d52e
11 changed files with 62 additions and 62 deletions

View File

@ -2063,7 +2063,7 @@ class TestAdminSetBackends(ZulipTestCase):
def test_change_enabled_backends(self):
# type: () -> None
# Log in as admin
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
result = self.client_patch("/json/realm", {
'authentication_methods': ujson.dumps({u'Email': False, u'Dev': True})})
self.assert_json_success(result)
@ -2074,7 +2074,7 @@ class TestAdminSetBackends(ZulipTestCase):
def test_disable_all_backends(self):
# type: () -> None
# Log in as admin
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
result = self.client_patch("/json/realm", {
'authentication_methods': ujson.dumps({u'Email': False, u'Dev': False})})
self.assert_json_error(result, 'At least one authentication method must be enabled.', status_code=403)
@ -2085,7 +2085,7 @@ class TestAdminSetBackends(ZulipTestCase):
def test_supported_backends_only_updated(self):
# type: () -> None
# Log in as admin
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
# Set some supported and unsupported backends
result = self.client_patch("/json/realm", {
'authentication_methods': ujson.dumps({u'Email': False, u'Dev': True, u'GitHub': False})})

View File

@ -118,7 +118,7 @@ class TopicHistoryTest(ZulipTestCase):
def test_bad_stream_id(self):
# type: () -> None
email = 'iago@zulip.com'
email = self.example_email("iago")
self.login(email)
# non-sensible stream id
@ -445,7 +445,7 @@ class StreamMessagesTest(ZulipTestCase):
def test_not_too_many_queries(self):
# type: () -> None
recipient_list = [self.example_email("hamlet"), 'iago@zulip.com', 'cordelia@zulip.com', 'othello@zulip.com']
recipient_list = [self.example_email("hamlet"), self.example_email("iago"), 'cordelia@zulip.com', 'othello@zulip.com']
for email in recipient_list:
self.subscribe_to_stream(email, "Denmark")
@ -1172,7 +1172,7 @@ class EditMessageTest(ZulipTestCase):
def test_edit_message_no_permission(self):
# type: () -> None
self.login(self.example_email("hamlet"))
msg_id = self.send_message("iago@zulip.com", "Scotland", Recipient.STREAM,
msg_id = self.send_message(self.example_email("iago"), "Scotland", Recipient.STREAM,
subject="editing", content="before edit")
result = self.client_patch("/json/messages/" + str(msg_id), {
'message_id': msg_id,
@ -1295,7 +1295,7 @@ class EditMessageTest(ZulipTestCase):
self.assertEqual(history[0]['prev_content'], 'content 3')
self.assertEqual(history[0]['user_id'], hamlet.id)
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
result = self.client_patch("/json/messages/" + str(msg_id), {
'message_id': msg_id,
'subject': 'subject 4',
@ -1394,9 +1394,9 @@ class EditMessageTest(ZulipTestCase):
self.assert_json_error(result, error)
self.check_message(id_, subject=old_subject, content=old_content)
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
# send a message in the past
id_ = self.send_message("iago@zulip.com", "Scotland", Recipient.STREAM,
id_ = self.send_message(self.example_email("iago"), "Scotland", Recipient.STREAM,
content="content", subject="subject")
message = Message.objects.get(id=id_)
message.pub_date = message.pub_date - datetime.timedelta(seconds=180)
@ -1429,13 +1429,13 @@ class EditMessageTest(ZulipTestCase):
self.login(self.example_email("hamlet"))
id1 = self.send_message(self.example_email("hamlet"), "Scotland", Recipient.STREAM,
subject="topic1")
id2 = self.send_message("iago@zulip.com", "Scotland", Recipient.STREAM,
id2 = self.send_message(self.example_email("iago"), "Scotland", Recipient.STREAM,
subject="topic1")
id3 = self.send_message("iago@zulip.com", "Rome", Recipient.STREAM,
id3 = self.send_message(self.example_email("iago"), "Rome", Recipient.STREAM,
subject="topic1")
id4 = self.send_message(self.example_email("hamlet"), "Scotland", Recipient.STREAM,
subject="topic2")
id5 = self.send_message("iago@zulip.com", "Scotland", Recipient.STREAM,
id5 = self.send_message(self.example_email("iago"), "Scotland", Recipient.STREAM,
subject="topic1")
result = self.client_patch("/json/messages/" + str(id1), {
@ -1458,13 +1458,13 @@ class EditMessageTest(ZulipTestCase):
subject="topic1")
id2 = self.send_message(self.example_email("hamlet"), "Scotland", Recipient.STREAM,
subject="topic1")
id3 = self.send_message("iago@zulip.com", "Rome", Recipient.STREAM,
id3 = self.send_message(self.example_email("iago"), "Rome", Recipient.STREAM,
subject="topic1")
id4 = self.send_message(self.example_email("hamlet"), "Scotland", Recipient.STREAM,
subject="topic2")
id5 = self.send_message("iago@zulip.com", "Scotland", Recipient.STREAM,
id5 = self.send_message(self.example_email("iago"), "Scotland", Recipient.STREAM,
subject="topic1")
id6 = self.send_message("iago@zulip.com", "Scotland", Recipient.STREAM,
id6 = self.send_message(self.example_email("iago"), "Scotland", Recipient.STREAM,
subject="topic3")
result = self.client_patch("/json/messages/" + str(id2), {

View File

@ -488,9 +488,9 @@ class GetOldMessagesTest(ZulipTestCase):
assert isinstance(dr, list)
return ','.join(sorted(set([r['email'] for r in dr] + [me])))
self.send_message(me, 'iago@zulip.com', Recipient.PERSONAL)
self.send_message(me, self.example_email("iago"), Recipient.PERSONAL)
self.send_message(me,
['iago@zulip.com', 'cordelia@zulip.com'],
[self.example_email("iago"), 'cordelia@zulip.com'],
Recipient.HUDDLE)
personals = [m for m in get_user_messages(self.example_user('hamlet'))
if m.recipient.type == Recipient.PERSONAL or
@ -514,13 +514,13 @@ class GetOldMessagesTest(ZulipTestCase):
me = self.example_email("hamlet")
matching_message_ids = []
matching_message_ids.append(self.send_message(me, ['iago@zulip.com', 'cordelia@zulip.com', 'othello@zulip.com'], Recipient.HUDDLE))
matching_message_ids.append(self.send_message(me, [self.example_email("iago"), 'cordelia@zulip.com', 'othello@zulip.com'], Recipient.HUDDLE))
matching_message_ids.append(self.send_message(me, ['cordelia@zulip.com', 'othello@zulip.com'], Recipient.HUDDLE))
non_matching_message_ids = []
non_matching_message_ids.append(self.send_message(me, 'cordelia@zulip.com', Recipient.PERSONAL))
non_matching_message_ids.append(self.send_message(me, ['iago@zulip.com', 'othello@zulip.com'], Recipient.HUDDLE))
non_matching_message_ids.append(self.send_message('cordelia@zulip.com', ['iago@zulip.com', 'othello@zulip.com'], Recipient.HUDDLE))
non_matching_message_ids.append(self.send_message(me, [self.example_email("iago"), 'othello@zulip.com'], Recipient.HUDDLE))
non_matching_message_ids.append(self.send_message('cordelia@zulip.com', [self.example_email("iago"), 'othello@zulip.com'], Recipient.HUDDLE))
self.login(me)
narrow = [dict(operator='group-pm-with', operand='cordelia@zulip.com')]
@ -676,7 +676,7 @@ class GetOldMessagesTest(ZulipTestCase):
self.send_message(self.example_email("hamlet"), "Scotland", Recipient.STREAM)
self.send_message("othello@zulip.com", "Scotland", Recipient.STREAM)
self.send_message("othello@zulip.com", self.example_email("hamlet"), Recipient.PERSONAL)
self.send_message("iago@zulip.com", "Scotland", Recipient.STREAM)
self.send_message(self.example_email("iago"), "Scotland", Recipient.STREAM)
narrow = [dict(operator='sender', operand='othello@zulip.com')]
result = self.get_and_check_messages(dict(narrow=ujson.dumps(narrow)))
@ -1090,7 +1090,7 @@ class GetOldMessagesTest(ZulipTestCase):
# Add a few messages that help us test that our query doesn't
# look at messages that are irrelevant to Hamlet.
self.send_message("othello@zulip.com", "cordelia@zulip.com", Recipient.PERSONAL)
self.send_message("othello@zulip.com", "iago@zulip.com", Recipient.PERSONAL)
self.send_message("othello@zulip.com", self.example_email("iago"), Recipient.PERSONAL)
query_params = dict(
use_first_unread_anchor='true',

View File

@ -142,7 +142,7 @@ class ReactionMessageIDTest(ZulipTestCase):
"""
pm_sender = self.example_email("hamlet")
pm_recipient = 'othello@zulip.com'
reaction_sender = 'iago@zulip.com'
reaction_sender = self.example_email("iago")
result = self.client_post("/api/v1/messages", {"type": "private",
"content": "Test message",

View File

@ -67,7 +67,7 @@ class RealmTest(ZulipTestCase):
def test_update_realm_description(self):
# type: () -> None
email = 'iago@zulip.com'
email = self.example_email("iago")
self.login(email)
realm = get_realm('zulip')
new_description = u'zulip dev group'
@ -93,7 +93,7 @@ class RealmTest(ZulipTestCase):
data = dict(description=ujson.dumps(new_description))
# create an admin user
email = 'iago@zulip.com'
email = self.example_email("iago")
self.login(email)
result = self.client_patch('/json/realm', data)
@ -158,7 +158,7 @@ class RealmTest(ZulipTestCase):
realm = get_realm('zulip')
self.assertNotEqual(realm.default_language, new_lang)
# we need an admin user.
email = 'iago@zulip.com'
email = self.example_email("iago")
self.login(email)
req = dict(default_language=ujson.dumps(new_lang))

View File

@ -20,7 +20,7 @@ import ujson
class RealmDomainTest(ZulipTestCase):
def test_list_realm_domains(self):
# type: () -> None
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
realm = get_realm('zulip')
RealmDomain.objects.create(realm=realm, domain='acme.com', allow_subdomains=True)
result = self.client_get("/json/realm/domains")
@ -43,7 +43,7 @@ class RealmDomainTest(ZulipTestCase):
def test_create_realm_domain(self):
# type: () -> None
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
data = {'domain': ujson.dumps(''),
'allow_subdomains': ujson.dumps(True)}
result = self.client_post("/json/realm/domains", info=data)
@ -72,7 +72,7 @@ class RealmDomainTest(ZulipTestCase):
def test_patch_realm_domain(self):
# type: () -> None
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
realm = get_realm('zulip')
RealmDomain.objects.create(realm=realm, domain='acme.com',
allow_subdomains=False)
@ -92,7 +92,7 @@ class RealmDomainTest(ZulipTestCase):
def test_delete_realm_domain(self):
# type: () -> None
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
realm = get_realm('zulip')
RealmDomain.objects.create(realm=realm, domain='acme.com')
result = self.client_delete("/json/realm/domains/non-existent.com")
@ -106,7 +106,7 @@ class RealmDomainTest(ZulipTestCase):
def test_delete_all_realm_domains(self):
# type: () -> None
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
realm = get_realm('zulip')
query = RealmDomain.objects.filter(realm=realm)

View File

@ -1629,7 +1629,7 @@ class DeactivateUserTest(ZulipTestCase):
def test_do_not_deactivate_final_admin(self):
# type: () -> None
email = 'iago@zulip.com'
email = self.example_email("iago")
self.login(email)
user = self.example_user('iago')
self.assertTrue(user.is_active)
@ -1705,7 +1705,7 @@ class TestFindMyTeam(ZulipTestCase):
result = self.client_get(url)
content = result.content.decode('utf8')
self.assertIn("Emails sent! You will only receive emails", content)
self.assertIn("iago@zulip.com", content)
self.assertIn(self.example_email("iago"), content)
self.assertIn("cordelia@zulip.com", content)
def test_find_team_ignore_invalid_email(self):
@ -1714,7 +1714,7 @@ class TestFindMyTeam(ZulipTestCase):
result = self.client_get(url)
content = result.content.decode('utf8')
self.assertIn("Emails sent! You will only receive emails", content)
self.assertIn("iago@zulip.com", content)
self.assertIn(self.example_email("iago"), content)
self.assertNotIn("invalid_email", content)
def test_find_team_zero_emails(self):

View File

@ -1303,8 +1303,8 @@ class SubscriptionAPITest(ZulipTestCase):
{"msg": "",
"result": "success",
"already_subscribed": {"iago@zulip.com": ["Venice", "Verona"]},
"subscribed": {"iago@zulip.com": ["Venice8"]}}
"already_subscribed": {self.example_email("iago"): ["Venice", "Verona"]},
"subscribed": {self.example_email("iago"): ["Venice8"]}}
"""
result = self.common_subscribe_to_streams(self.test_email, subscriptions,
other_params, invite_only=invite_only)
@ -1366,7 +1366,7 @@ class SubscriptionAPITest(ZulipTestCase):
"""
Calling POST /json/users/me/subscriptions should notify when a new stream is created.
"""
invitee = "iago@zulip.com"
invitee = self.example_email("iago")
current_stream = self.get_streams(invitee)[0]
invite_streams = self.make_random_stream_names([current_stream])[:1]
@ -1385,7 +1385,7 @@ class SubscriptionAPITest(ZulipTestCase):
"""
Calling POST /json/users/me/subscriptions should notify when a new stream is created.
"""
invitee = "iago@zulip.com"
invitee = self.example_email("iago")
invitee_full_name = 'Iago'
current_stream = self.get_streams(invitee)[0]
@ -1459,7 +1459,7 @@ class SubscriptionAPITest(ZulipTestCase):
"""
Calling POST /json/users/me/subscriptions should notify when a new stream is created.
"""
invitee = "iago@zulip.com"
invitee = self.example_email("iago")
invitee_full_name = 'Iago'
current_stream = self.get_streams(invitee)[0]
@ -1572,7 +1572,7 @@ class SubscriptionAPITest(ZulipTestCase):
def test_multi_user_subscription(self):
# type: () -> None
email1 = 'cordelia@zulip.com'
email2 = 'iago@zulip.com'
email2 = self.example_email("iago")
realm = get_realm("zulip")
streams_to_sub = ['multi_user_stream']
events = [] # type: List[Dict[str, Any]]
@ -1711,7 +1711,7 @@ class SubscriptionAPITest(ZulipTestCase):
streams_to_sub,
dict(principals=ujson.dumps(users_to_subscribe)))
new_users_to_subscribe = ["iago@zulip.com", "cordelia@zulip.com"]
new_users_to_subscribe = [self.example_email("iago"), "cordelia@zulip.com"]
events = [] # type: List[Dict[str, Any]]
with tornado_redirected_to_list(events):
self.common_subscribe_to_streams(
@ -1743,7 +1743,7 @@ class SubscriptionAPITest(ZulipTestCase):
email1 = 'othello@zulip.com'
email2 = 'cordelia@zulip.com'
email3 = 'hamlet@zulip.com'
email4 = 'iago@zulip.com'
email4 = self.example_email("iago")
realm = get_realm('zulip')
stream1 = self.make_stream('stream1')

View File

@ -164,9 +164,9 @@ class UnreadCountTests(ZulipTestCase):
# type: () -> None
self.unread_msg_ids = [
self.send_message(
"iago@zulip.com", self.example_email("hamlet"), Recipient.PERSONAL, "hello"),
self.example_email("iago"), self.example_email("hamlet"), Recipient.PERSONAL, "hello"),
self.send_message(
"iago@zulip.com", self.example_email("hamlet"), Recipient.PERSONAL, "hello2")]
self.example_email("iago"), self.example_email("hamlet"), Recipient.PERSONAL, "hello2")]
# Sending a new message results in unread UserMessages being created
def test_new_message(self):
@ -215,7 +215,7 @@ class UnreadCountTests(ZulipTestCase):
# type: () -> None
self.login(self.example_email("hamlet"))
message_ids = [self.send_message(self.example_email("hamlet"), "iago@zulip.com",
message_ids = [self.send_message(self.example_email("hamlet"), self.example_email("iago"),
Recipient.PERSONAL, "test"),
self.send_message(self.example_email("hamlet"), "cordelia@zulip.com",
Recipient.PERSONAL, "test2")]

View File

@ -516,7 +516,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
def test_file_download_authorization_invite_only(self):
# type: () -> None
subscribed_users = [self.example_email("hamlet"), "iago@zulip.com"]
subscribed_users = [self.example_email("hamlet"), self.example_email("iago")]
unsubscribed_users = ["othello@zulip.com", "prospero@zulip.com"]
for user in subscribed_users:
self.subscribe_to_stream(user, "test-subscribe")
@ -556,7 +556,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
def test_file_download_authorization_public(self):
# type: () -> None
subscribed_users = [self.example_email("hamlet"), "iago@zulip.com"]
subscribed_users = [self.example_email("hamlet"), self.example_email("iago")]
unsubscribed_users = ["othello@zulip.com", "prospero@zulip.com"]
for user in subscribed_users:
self.subscribe_to_stream(user, "test-subscribe")
@ -798,7 +798,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
Attempting to upload two files should fail.
"""
# Log in as admin
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
with get_test_image_file('img.png') as fp1, \
get_test_image_file('img.png') as fp2:
result = self.client_put_multipart("/json/realm/icon", {'f1': fp1, 'f2': fp2})
@ -809,7 +809,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
"""
Calling this endpoint with no files should fail.
"""
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
result = self.client_put_multipart("/json/realm/icon")
self.assert_json_error(result, "You must upload exactly one icon.")
@ -865,7 +865,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
for fname, rfname in self.correct_files:
# TODO: use self.subTest once we're exclusively on python 3 by uncommenting the line below.
# with self.subTest(fname=fname):
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
with get_test_image_file(fname) as fp:
result = self.client_put_multipart("/json/realm/icon", {'file': fp})
realm = get_realm('zulip')
@ -888,7 +888,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
"""
for fname in self.corrupt_files:
# with self.subTest(fname=fname):
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
with get_test_image_file(fname) as fp:
result = self.client_put_multipart("/json/realm/icon", {'file': fp})
@ -899,7 +899,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
"""
A DELETE request to /json/realm/icon should delete the realm icon and return gravatar URL
"""
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
realm = get_realm('zulip')
realm.icon_source = Realm.ICON_UPLOADED
realm.save()
@ -915,7 +915,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
def test_realm_icon_version(self):
# type: () -> None
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
realm = get_realm('zulip')
icon_version = realm.icon_version
self.assertEqual(icon_version, 1)
@ -926,7 +926,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
def test_realm_icon_upload_file_size_error(self):
# type: () -> None
self.login("iago@zulip.com")
self.login(self.example_email("iago"))
with get_test_image_file(self.correct_files[0][0]) as fp:
with self.settings(MAX_ICON_FILE_SIZE=0):
result = self.client_put_multipart("/json/realm/icon", {'file': fp})

View File

@ -111,7 +111,7 @@ class PermissionTest(ZulipTestCase):
self.assertEqual(person['is_admin'], False)
# Cannot take away from last admin
self.login('iago@zulip.com')
self.login(self.example_email("iago"))
req = dict(is_admin=ujson.dumps(False))
events = []
with tornado_redirected_to_list(events):
@ -134,7 +134,7 @@ class PermissionTest(ZulipTestCase):
def test_admin_user_can_change_full_name(self):
# type: () -> None
new_name = 'new name'
self.login('iago@zulip.com')
self.login(self.example_email("iago"))
req = dict(full_name=ujson.dumps(new_name))
result = self.client_patch('/json/users/hamlet@zulip.com', req)
self.assertTrue(result.status_code == 200)
@ -151,7 +151,7 @@ class PermissionTest(ZulipTestCase):
def test_admin_cannot_set_long_full_name(self):
# type: () -> None
new_name = 'a' * (UserProfile.MAX_NAME_LENGTH + 1)
self.login('iago@zulip.com')
self.login(self.example_email("iago"))
req = dict(full_name=ujson.dumps(new_name))
result = self.client_patch('/json/users/hamlet@zulip.com', req)
self.assert_json_error(result, 'Name too long!')
@ -159,7 +159,7 @@ class PermissionTest(ZulipTestCase):
def test_admin_cannot_set_short_full_name(self):
# type: () -> None
new_name = 'a'
self.login('iago@zulip.com')
self.login(self.example_email("iago"))
req = dict(full_name=ujson.dumps(new_name))
result = self.client_patch('/json/users/hamlet@zulip.com', req)
self.assert_json_error(result, 'Name too short!')
@ -167,7 +167,7 @@ class PermissionTest(ZulipTestCase):
def test_admin_cannot_set_full_name_with_invalid_characters(self):
# type: () -> None
new_name = 'Opheli*'
self.login('iago@zulip.com')
self.login(self.example_email("iago"))
req = dict(full_name=ujson.dumps(new_name))
result = self.client_patch('/json/users/hamlet@zulip.com', req)
self.assert_json_error(result, 'Invalid characters in name!')
@ -289,7 +289,7 @@ class ActivateTest(ZulipTestCase):
"""This test helps ensure that our URL patterns for /users/me URLs
handle email addresses starting with "me" correctly."""
self.register(self.nonreg_email('me'), "testpassword")
self.login('iago@zulip.com')
self.login(self.example_email("iago"))
result = self.client_delete('/json/users/me@zulip.com')
self.assert_json_success(result)
@ -396,10 +396,10 @@ class GetProfileTest(ZulipTestCase):
self.assertIn("user_id", result)
self.assertFalse(result['is_bot'])
self.assertFalse(result['is_admin'])
self.login('iago@zulip.com')
self.login(self.example_email("iago"))
result = ujson.loads(self.client_get('/json/users/me').content)
self.assertEqual(result['short_name'], 'iago')
self.assertEqual(result['email'], 'iago@zulip.com')
self.assertEqual(result['email'], self.example_email("iago"))
self.assertEqual(result['full_name'], 'Iago')
self.assertFalse(result['is_bot'])
self.assertTrue(result['is_admin'])