forked from mirrors/bookwyrm
Add save_and_cleanup test
This commit is contained in:
parent
00b09cd07d
commit
ba39dad06c
1 changed files with 14 additions and 0 deletions
|
@ -16,6 +16,7 @@ from bookwyrm.preview_images import (
|
||||||
generate_edition_preview_image_task,
|
generate_edition_preview_image_task,
|
||||||
generate_user_preview_image_task,
|
generate_user_preview_image_task,
|
||||||
generate_preview_image,
|
generate_preview_image,
|
||||||
|
save_and_cleanup,
|
||||||
)
|
)
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
@ -70,6 +71,19 @@ class PreviewImages(TestCase):
|
||||||
result.size, (settings.PREVIEW_IMG_WIDTH, settings.PREVIEW_IMG_HEIGHT)
|
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):
|
def test_site_preview(self, *args, **kwargs):
|
||||||
"""generate site preview"""
|
"""generate site preview"""
|
||||||
generate_site_preview_image_task()
|
generate_site_preview_image_task()
|
||||||
|
|
Loading…
Reference in a new issue