upload: Rename BadImageError exception to not mention avatars.

This is preparation for using that function to decode realm icons as
well.
This commit is contained in:
Tim Abbott 2017-02-26 11:17:34 -08:00
parent 9ce218154e
commit c5ed119f89
2 changed files with 2 additions and 2 deletions

View File

@ -90,7 +90,7 @@ def resize_avatar(image_data, size=DEFAULT_AVATAR_SIZE):
im = Image.open(io.BytesIO(image_data)) im = Image.open(io.BytesIO(image_data))
im = ImageOps.fit(im, (size, size), Image.ANTIALIAS) im = ImageOps.fit(im, (size, size), Image.ANTIALIAS)
except IOError: except IOError:
raise BadImageError("Could not decode avatar image; did you upload an image file?") raise BadImageError("Could not decode image; did you upload an image file?")
out = io.BytesIO() out = io.BytesIO()
im.save(out, format='png') im.save(out, format='png')
return out.getvalue() return out.getvalue()

View File

@ -444,7 +444,7 @@ class AvatarTest(UploadSerializeMixin, ZulipTestCase):
with get_test_image_file(fname) as fp: with get_test_image_file(fname) as fp:
result = self.client_put_multipart("/json/users/me/avatar", {'file': fp}) result = self.client_put_multipart("/json/users/me/avatar", {'file': fp})
self.assert_json_error(result, "Could not decode avatar image; did you upload an image file?") self.assert_json_error(result, "Could not decode image; did you upload an image file?")
user_profile = get_user_profile_by_email("hamlet@zulip.com") user_profile = get_user_profile_by_email("hamlet@zulip.com")
self.assertEqual(user_profile.avatar_version, 1) self.assertEqual(user_profile.avatar_version, 1)