mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 03:21:05 +00:00
Tests for image generator file
This isn't what I need to be working on right now but it bugs me immensely that the test coverage is at 89% and not 90% and this was the lowest hanging fruit to get more coverage. Truly a me problem.
This commit is contained in:
parent
0b7c8e8dc0
commit
634ed50044
1 changed files with 29 additions and 1 deletions
|
@ -1,6 +1,10 @@
|
|||
""" testing models """
|
||||
from dateutil.parser import parse
|
||||
from io import BytesIO
|
||||
import pathlib
|
||||
|
||||
from dateutil.parser import parse
|
||||
from PIL import Image
|
||||
from django.core.files.base import ContentFile
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone
|
||||
|
||||
|
@ -96,3 +100,27 @@ class Book(TestCase):
|
|||
self.first_edition.description = "hi"
|
||||
self.first_edition.save()
|
||||
self.assertEqual(self.first_edition.edition_rank, 1)
|
||||
|
||||
def test_thumbnail_fields(self):
|
||||
"""Just hit them"""
|
||||
settings.ENABLE_THUMBNAIL_GENERATION = True
|
||||
image_file = pathlib.Path(__file__).parent.joinpath(
|
||||
"../../static/images/default_avi.jpg"
|
||||
)
|
||||
image = Image.open(image_file)
|
||||
output = BytesIO()
|
||||
image.save(output, format=image.format)
|
||||
book = models.Edition.objects.create(title="hello")
|
||||
book.cover.save("test.jpg", ContentFile(output.getvalue()))
|
||||
self.assertIsNotNone(book.cover_bw_book_xsmall_webp.url)
|
||||
self.assertIsNotNone(book.cover_bw_book_xsmall_jpg.url)
|
||||
self.assertIsNotNone(book.cover_bw_book_small_webp.url)
|
||||
self.assertIsNotNone(book.cover_bw_book_small_jpg.url)
|
||||
self.assertIsNotNone(book.cover_bw_book_medium_webp.url)
|
||||
self.assertIsNotNone(book.cover_bw_book_medium_jpg.url)
|
||||
self.assertIsNotNone(book.cover_bw_book_large_webp.url)
|
||||
self.assertIsNotNone(book.cover_bw_book_large_jpg.url)
|
||||
self.assertIsNotNone(book.cover_bw_book_xlarge_webp.url)
|
||||
self.assertIsNotNone(book.cover_bw_book_xlarge_jpg.url)
|
||||
self.assertIsNotNone(book.cover_bw_book_xxlarge_webp.url)
|
||||
self.assertIsNotNone(book.cover_bw_book_xxlarge_jpg.url)
|
||||
|
|
Loading…
Reference in a new issue