Skip to content

Commit

Permalink
tests: Adjust to new changes in populate_db.
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszmandera authored and timabbott committed Jul 31, 2019
1 parent 9b2b24c commit d3d62f9
Show file tree
Hide file tree
Showing 36 changed files with 79 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"livemode": false,
"metadata": {
"realm_id": "1",
"realm_id": "2",
"realm_str": "zulip"
},
"object": "customer",
Expand Down
2 changes: 1 addition & 1 deletion frontend_tests/casper_tests/10-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ casper.then(function () {
}, false);
casper.click("#realm_icon_upload_button");
casper.waitWhileVisible("#upload_icon_spinner .loading_indicator_spinner", function () {
casper.test.assertExists('img#realm-settings-icon[src^="/user_avatars/1/realm/icon.png?version=2"]');
casper.test.assertExists('img#realm-settings-icon[src^="/user_avatars/2/realm/icon.png?version=2"]');
casper.test.assertEqual(casper.visible('#realm_icon_delete_button'), true);
});
});
Expand Down
14 changes: 12 additions & 2 deletions zerver/tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from io import StringIO

from zerver.models import (
get_client, get_stream_recipient, get_stream,
get_client, get_stream_recipient, get_stream, get_realm, get_system_bot,
Message, RealmDomain, Recipient, UserMessage, UserPresence, UserProfile,
Realm, Subscription, Stream, flush_per_request_caches, UserGroup, Service,
Attachment, PreregistrationUser, get_user_by_delivery_email, MultiuseInvite
Expand Down Expand Up @@ -108,6 +108,7 @@
from zerver.lib.events import (
apply_events,
fetch_initial_state_data,
get_raw_user_data,
post_process_state,
)
from zerver.lib.message import (
Expand Down Expand Up @@ -2800,7 +2801,7 @@ def test_realm_bots_admin(self) -> None:
do_change_is_admin(user_profile, True)
self.assertTrue(user_profile.is_realm_admin)
result = fetch_initial_state_data(user_profile, None, "", client_gravatar=False)
self.assertTrue(len(result['realm_bots']) > 5)
self.assertTrue(len(result['realm_bots']) > 2)

def test_max_message_id_with_no_history(self) -> None:
user_profile = self.example_user('aaron')
Expand Down Expand Up @@ -3614,3 +3615,12 @@ def test_use_narrow_if_default_is_none(self) -> None:
self.user_profile.save()
result = _default_narrow(self.user_profile, [])
self.assertEqual(result, [])

class TestGetRawUserDataSystemBotRealm(ZulipTestCase):
def test_get_raw_user_data_on_system_bot_realm(self) -> None:
result = get_raw_user_data(get_realm("zulipinternal"), True)

for bot_email in settings.CROSS_REALM_BOT_EMAILS:
bot_profile = get_system_bot(bot_email)
self.assertTrue(bot_profile.id in result)
self.assertTrue(result[bot_profile.id]['is_cross_realm_bot'])
15 changes: 6 additions & 9 deletions zerver/tests/test_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ def test_export_files_from_local(self) -> None:
self.assertEqual('1.png', os.listdir(fn)[0])
records = full_data['emoji_dir_records']
self.assertEqual(records[0]['file_name'], '1.png')
self.assertEqual(records[0]['path'], '1/emoji/images/1.png')
self.assertEqual(records[0]['s3_path'], '1/emoji/images/1.png')
self.assertEqual(records[0]['path'], '2/emoji/images/1.png')
self.assertEqual(records[0]['s3_path'], '2/emoji/images/1.png')

# Test avatars
fn = os.path.join(full_data['avatar_dir'], original_avatar_path_id)
Expand Down Expand Up @@ -386,8 +386,8 @@ def check_variable_type(user_profile_id: int, realm_id: int) -> None:
records = full_data['emoji_dir_records']
self.assertEqual(records[0]['file_name'], '1.png')
self.assertTrue('last_modified' in records[0])
self.assertEqual(records[0]['path'], '1/emoji/images/1.png')
self.assertEqual(records[0]['s3_path'], '1/emoji/images/1.png')
self.assertEqual(records[0]['path'], '2/emoji/images/1.png')
self.assertEqual(records[0]['s3_path'], '2/emoji/images/1.png')
check_variable_type(records[0]['user_profile_id'], records[0]['realm_id'])

# Test avatars
Expand Down Expand Up @@ -415,13 +415,12 @@ def test_zulip_realm(self) -> None:
realm_emoji.save()

data = full_data['realm']
self.assertEqual(len(data['zerver_userprofile_crossrealm']), 0)
self.assertEqual(len(data['zerver_userprofile_crossrealm']), 3)
self.assertEqual(len(data['zerver_userprofile_mirrordummy']), 0)

exported_user_emails = self.get_set(data['zerver_userprofile'], 'email')
self.assertIn(self.example_email('cordelia'), exported_user_emails)
self.assertIn('[email protected]', exported_user_emails)
self.assertIn('[email protected]', exported_user_emails)

exported_streams = self.get_set(data['zerver_stream'], 'name')
self.assertEqual(
Expand Down Expand Up @@ -472,7 +471,6 @@ def test_export_realm_with_exportable_user_ids(self) -> None:
self.assertIn(self.example_email('cordelia'), dummy_user_emails)
self.assertIn(self.example_email('othello'), dummy_user_emails)
self.assertIn('[email protected]', dummy_user_emails)
self.assertIn('[email protected]', dummy_user_emails)
self.assertNotIn(self.example_email('iago'), dummy_user_emails)
self.assertNotIn(self.example_email('hamlet'), dummy_user_emails)

Expand Down Expand Up @@ -541,7 +539,7 @@ def test_export_realm_with_member_consent(self) -> None:

data = full_data['realm']

self.assertEqual(len(data['zerver_userprofile_crossrealm']), 0)
self.assertEqual(len(data['zerver_userprofile_crossrealm']), 3)
self.assertEqual(len(data['zerver_userprofile_mirrordummy']), 0)

exported_user_emails = self.get_set(data['zerver_userprofile'], 'email')
Expand All @@ -550,7 +548,6 @@ def test_export_realm_with_member_consent(self) -> None:
self.assertIn(self.example_email('iago'), exported_user_emails)
self.assertIn(self.example_email('othello'), exported_user_emails)
self.assertIn('[email protected]', exported_user_emails)
self.assertIn('[email protected]', exported_user_emails)

exported_streams = self.get_set(data['zerver_stream'], 'name')
self.assertEqual(
Expand Down
Loading

0 comments on commit d3d62f9

Please sign in to comment.