mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
additional magic test
This commit is contained in:
parent
a89a3fad17
commit
d0ed3e3132
2 changed files with 13 additions and 1 deletions
|
|
@ -140,7 +140,7 @@ class Avatar(models.Model):
|
|||
try:
|
||||
orientation = image._getexif()[0x0112]
|
||||
ops = EXIF_ORIENTATION_STEPS[orientation]
|
||||
except TypeError:
|
||||
except (AttributeError, TypeError):
|
||||
ops = []
|
||||
for method in ops:
|
||||
image = image.transpose(getattr(Image, method))
|
||||
|
|
|
|||
|
|
@ -129,6 +129,18 @@ class AvatarTests(TestCase):
|
|||
self.assertEqual(len(response.redirect_chain), 0) # Redirect only if it worked
|
||||
self.assertNotEqual(response.context["upload_avatar_form"].errors, {})
|
||||
|
||||
# We allow the .tiff file extension and the mime type
|
||||
@override_settings(AVATAR_ALLOWED_FILE_EXTS=(".png", ".gif", ".jpg", ".tiff"))
|
||||
@override_settings(
|
||||
AVATAR_ALLOWED_MIMETYPES=("image/png", "image/gif", "image/jpeg", "image/tiff")
|
||||
)
|
||||
def test_supported_image_format_upload(self):
|
||||
"""Check with python-magic that we detect corrupted / unapprovd image files correctly"""
|
||||
response = upload_helper(self, "test.tiff")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(len(response.redirect_chain), 1) # Redirect only if it worked
|
||||
self.assertEqual(response.context["upload_avatar_form"].errors, {})
|
||||
|
||||
@override_settings(AVATAR_ALLOWED_FILE_EXTS=(".jpg", ".png"))
|
||||
def test_image_without_wrong_extension(self):
|
||||
response = upload_helper(self, "imagefilewithoutext")
|
||||
|
|
|
|||
Loading…
Reference in a new issue