add test for nondefault image names, fixes #38

This commit is contained in:
Johannes Wilm 2022-08-16 13:40:25 +02:00
parent 39f8681e29
commit c089561f48
3 changed files with 8 additions and 2 deletions

View file

@ -8,14 +8,14 @@ from django.core.files.base import ContentFile
from django.core.files.storage import get_storage_class
from django.db import models
from django.db.models import signals
from django.utils.encoding import force_str
from django.utils.encoding import force_bytes, force_str
from django.utils.module_loading import import_string
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from PIL import Image, ImageOps
from avatar.conf import settings
from avatar.utils import force_bytes, get_username, invalidate_cache
from avatar.utils import get_username, invalidate_cache
avatar_storage = get_storage_class(settings.AVATAR_STORAGE)()

BIN
tests/data/django #3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -312,6 +312,12 @@ class AvatarTests(TestCase):
self.assertLess(root_mean_square_difference(image_with_exif, image_no_exif), 1)
def test_automatic_thumbnail_creation_nondefault_filename(self):
upload_helper(self, "django #3.png")
self.assertMediaFileExists(
f"/avatars/{self.user.id}/resized/80/80/django_3.png"
)
def test_has_avatar_False_if_no_avatar(self):
self.assertFalse(avatar_tags.has_avatar(self.user))