fixup! thumbnail: Fix MAX_EMOJI_GIF_FILE_SIZE_BYTES check to be post-resize.

This commit is contained in:
Alex Vandiver 2024-07-12 17:35:32 +00:00 committed by Tim Abbott
parent f6b99171ce
commit 2b3da0e70f
1 changed files with 11 additions and 0 deletions

View File

@ -1779,6 +1779,17 @@ class EmojiTest(UploadSerializeMixin, ZulipTestCase):
self.assert_json_error(result, "Invalid image format")
resize_mock.assert_not_called()
def test_upload_too_big_after_resize(self) -> None:
"""Non-animated image is too big after resizing"""
self.login("iago")
with get_test_image_file("img.png") as f:
with patch(
"zerver.lib.upload.resize_emoji", return_value=(b"a" * (200 * 1024), None)
) as resize_mock:
result = self.client_post("/json/realm/emoji/new", {"f1": f})
self.assert_json_error(result, "Image size exceeds limit")
resize_mock.assert_called_once()
def test_upload_big_after_animated_resize(self) -> None:
"""A big animated image is fine as long as the still is small"""
self.login("iago")