mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
zerver/tests: Test ensure_medium_avatar_url when the file exists.
This commit is contained in:
committed by
Tim Abbott
parent
398141268f
commit
2dc13d6b50
@@ -625,6 +625,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
|
||||
def tearDown(self) -> None:
|
||||
destroy_uploads()
|
||||
|
||||
|
||||
class AvatarTest(UploadSerializeMixin, ZulipTestCase):
|
||||
|
||||
def test_get_avatar_field(self) -> None:
|
||||
@@ -804,6 +805,11 @@ class AvatarTest(UploadSerializeMixin, ZulipTestCase):
|
||||
medium_avatar_disk_path = avatar_disk_path(user_profile, medium=True)
|
||||
self.assertTrue(os.path.exists(medium_avatar_disk_path))
|
||||
|
||||
# Verify that ensure_medium_avatar_url does not overwrite this file if it exists
|
||||
with mock.patch('zerver.lib.upload.write_local_file') as mock_write_local_file:
|
||||
zerver.lib.upload.upload_backend.ensure_medium_avatar_image(user_profile)
|
||||
self.assertFalse(mock_write_local_file.called)
|
||||
|
||||
# Confirm that ensure_medium_avatar_url works to recreate
|
||||
# medium size avatars from the original if needed
|
||||
os.remove(medium_avatar_disk_path)
|
||||
|
||||
Reference in New Issue
Block a user