mirror of https://github.com/zulip/zulip.git
export tests: Clean up emoji checks.
This commit is contained in:
parent
fd94ba1579
commit
d3ea369057
|
@ -158,7 +158,7 @@ class RealmImportExportTest(ZulipTestCase):
|
||||||
consent_message_id=consent_message_id,
|
consent_message_id=consent_message_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _setup_export_files(self, user_profile: UserProfile) -> Tuple[str, str]:
|
def _setup_export_files(self, user_profile: UserProfile) -> str:
|
||||||
realm = user_profile.realm
|
realm = user_profile.realm
|
||||||
message = most_recent_message(user_profile)
|
message = most_recent_message(user_profile)
|
||||||
url = upload_message_file(
|
url = upload_message_file(
|
||||||
|
@ -172,11 +172,6 @@ class RealmImportExportTest(ZulipTestCase):
|
||||||
is_message_realm_public=True,
|
is_message_realm_public=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
emoji_path = RealmEmoji.PATH_ID_TEMPLATE.format(
|
|
||||||
realm_id=realm.id,
|
|
||||||
emoji_file_name="1.png",
|
|
||||||
)
|
|
||||||
|
|
||||||
with get_test_image_file("img.png") as img_file:
|
with get_test_image_file("img.png") as img_file:
|
||||||
upload_emoji_image(img_file, "1.png", user_profile)
|
upload_emoji_image(img_file, "1.png", user_profile)
|
||||||
with get_test_image_file("img.png") as img_file:
|
with get_test_image_file("img.png") as img_file:
|
||||||
|
@ -198,7 +193,7 @@ class RealmImportExportTest(ZulipTestCase):
|
||||||
|
|
||||||
realm.refresh_from_db()
|
realm.refresh_from_db()
|
||||||
|
|
||||||
return attachment_path_id, emoji_path
|
return attachment_path_id
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Tests for export
|
Tests for export
|
||||||
|
@ -207,7 +202,7 @@ class RealmImportExportTest(ZulipTestCase):
|
||||||
def test_export_files_from_local(self) -> None:
|
def test_export_files_from_local(self) -> None:
|
||||||
user = self.example_user("hamlet")
|
user = self.example_user("hamlet")
|
||||||
realm = user.realm
|
realm = user.realm
|
||||||
path_id, emoji_path = self._setup_export_files(user)
|
path_id = self._setup_export_files(user)
|
||||||
self._export_realm(realm)
|
self._export_realm(realm)
|
||||||
|
|
||||||
data = read_json("attachment.json")
|
data = read_json("attachment.json")
|
||||||
|
@ -232,13 +227,14 @@ class RealmImportExportTest(ZulipTestCase):
|
||||||
self.assertEqual(file_name, "dummy.txt")
|
self.assertEqual(file_name, "dummy.txt")
|
||||||
|
|
||||||
# Test emojis
|
# Test emojis
|
||||||
fn = export_fn(f"emoji/{emoji_path}")
|
emoji_path = f"{realm.id}/emoji/images/1.png"
|
||||||
fn = fn.replace("1.png", "")
|
emoji_dir = export_fn(f"emoji/{realm.id}/emoji/images")
|
||||||
self.assertEqual("1.png", os.listdir(fn)[0])
|
self.assertEqual(os.listdir(emoji_dir), ["1.png"])
|
||||||
records = read_json("emoji/records.json")
|
|
||||||
self.assertEqual(records[0]["file_name"], "1.png")
|
(record,) = read_json("emoji/records.json")
|
||||||
self.assertEqual(records[0]["path"], "2/emoji/images/1.png")
|
self.assertEqual(record["file_name"], "1.png")
|
||||||
self.assertEqual(records[0]["s3_path"], "2/emoji/images/1.png")
|
self.assertEqual(record["path"], emoji_path)
|
||||||
|
self.assertEqual(record["s3_path"], emoji_path)
|
||||||
|
|
||||||
# Test realm logo and icon
|
# Test realm logo and icon
|
||||||
records = read_json("realm_icons/records.json")
|
records = read_json("realm_icons/records.json")
|
||||||
|
@ -284,10 +280,7 @@ class RealmImportExportTest(ZulipTestCase):
|
||||||
user = self.example_user("hamlet")
|
user = self.example_user("hamlet")
|
||||||
realm = user.realm
|
realm = user.realm
|
||||||
|
|
||||||
(
|
attachment_path_id = self._setup_export_files(user)
|
||||||
attachment_path_id,
|
|
||||||
emoji_path,
|
|
||||||
) = self._setup_export_files(user)
|
|
||||||
self._export_realm(realm)
|
self._export_realm(realm)
|
||||||
|
|
||||||
data = read_json("attachment.json")
|
data = read_json("attachment.json")
|
||||||
|
@ -313,15 +306,16 @@ class RealmImportExportTest(ZulipTestCase):
|
||||||
check_types(records[0]["user_profile_id"], records[0]["realm_id"])
|
check_types(records[0]["user_profile_id"], records[0]["realm_id"])
|
||||||
|
|
||||||
# Test emojis
|
# Test emojis
|
||||||
fn = export_fn(f"emoji/{emoji_path}")
|
emoji_path = f"{realm.id}/emoji/images/1.png"
|
||||||
fn = fn.replace("1.png", "")
|
emoji_dir = export_fn(f"emoji/{realm.id}/emoji/images")
|
||||||
self.assertIn("1.png", os.listdir(fn))
|
self.assertEqual(os.listdir(emoji_dir), ["1.png"])
|
||||||
records = read_json("emoji/records.json")
|
|
||||||
self.assertEqual(records[0]["file_name"], "1.png")
|
(record,) = read_json("emoji/records.json")
|
||||||
|
self.assertEqual(record["file_name"], "1.png")
|
||||||
self.assertTrue("last_modified" in records[0])
|
self.assertTrue("last_modified" in records[0])
|
||||||
self.assertEqual(records[0]["path"], "2/emoji/images/1.png")
|
self.assertEqual(record["path"], emoji_path)
|
||||||
self.assertEqual(records[0]["s3_path"], "2/emoji/images/1.png")
|
self.assertEqual(record["s3_path"], emoji_path)
|
||||||
check_types(records[0]["user_profile_id"], records[0]["realm_id"])
|
check_types(record["user_profile_id"], record["realm_id"])
|
||||||
|
|
||||||
# Test realm logo and icon
|
# Test realm logo and icon
|
||||||
records = read_json("realm_icons/records.json")
|
records = read_json("realm_icons/records.json")
|
||||||
|
|
Loading…
Reference in New Issue