mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Merge pull request #2192 from bookwyrm-social/tests
Tests for image generator file
This commit is contained in:
commit
8e18c21460
2 changed files with 31 additions and 1 deletions
1
.github/workflows/django-tests.yml
vendored
1
.github/workflows/django-tests.yml
vendored
|
@ -55,5 +55,6 @@ jobs:
|
||||||
EMAIL_HOST_PASSWORD: ""
|
EMAIL_HOST_PASSWORD: ""
|
||||||
EMAIL_USE_TLS: true
|
EMAIL_USE_TLS: true
|
||||||
ENABLE_PREVIEW_IMAGES: false
|
ENABLE_PREVIEW_IMAGES: false
|
||||||
|
ENABLE_THUMBNAIL_GENERATION: true
|
||||||
run: |
|
run: |
|
||||||
pytest -n 3
|
pytest -n 3
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
""" testing models """
|
""" 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.test import TestCase
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
@ -96,3 +100,28 @@ class Book(TestCase):
|
||||||
self.first_edition.description = "hi"
|
self.first_edition.description = "hi"
|
||||||
self.first_edition.save()
|
self.first_edition.save()
|
||||||
self.assertEqual(self.first_edition.edition_rank, 1)
|
self.assertEqual(self.first_edition.edition_rank, 1)
|
||||||
|
|
||||||
|
def test_thumbnail_fields(self):
|
||||||
|
"""Just hit them"""
|
||||||
|
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