1
0
Fork 1
mirror of https://github.com/bookwyrm-social/bookwyrm.git synced 2024-12-28 11:00:36 +00:00

Add save_and_cleanup test

This commit is contained in:
Joachim 2021-05-29 15:32:04 +02:00
parent 00b09cd07d
commit ba39dad06c

View file

@ -16,6 +16,7 @@ from bookwyrm.preview_images import (
generate_edition_preview_image_task,
generate_user_preview_image_task,
generate_preview_image,
save_and_cleanup,
)
import logging
@ -70,6 +71,19 @@ class PreviewImages(TestCase):
result.size, (settings.PREVIEW_IMG_WIDTH, settings.PREVIEW_IMG_HEIGHT)
)
def test_store_preview_image(self, *args, **kwargs):
image = Image.new("RGB", (200, 200), color="#F00")
result = save_and_cleanup(image, instance=self.local_user)
self.assertTrue(result)
self.local_user.refresh_from_db()
self.assertIsInstance(self.local_user.preview_image, ImageFieldFile)
self.assertIsNotNone(self.local_user.preview_image)
self.assertEqual(self.local_user.preview_image.width, 200)
self.assertEqual(self.local_user.preview_image.height, 200)
def test_site_preview(self, *args, **kwargs):
"""generate site preview"""
generate_site_preview_image_task()