|
@@ -1,10 +1,12 @@
|
|
|
from django.db import transaction
|
|
|
-from django.test import TransactionTestCase, override_settings
|
|
|
+from django.test import TestCase, TransactionTestCase, override_settings
|
|
|
|
|
|
from wagtail.images import get_image_model, signal_handlers
|
|
|
from wagtail.images.tests.utils import get_test_image_file
|
|
|
from wagtail.models import Collection
|
|
|
|
|
|
+from .utils import Image
|
|
|
+
|
|
|
|
|
|
class TestFilesDeletedForDefaultModels(TransactionTestCase):
|
|
|
"""
|
|
@@ -80,3 +82,16 @@ class TestFilesDeletedForCustomModels(TestFilesDeletedForDefaultModels):
|
|
|
self.assertEqual(
|
|
|
"%s.%s" % (cls._meta.app_label, cls.__name__), "tests.CustomImage"
|
|
|
)
|
|
|
+
|
|
|
+
|
|
|
+@override_settings(WAGTAILIMAGES_FEATURE_DETECTION_ENABLED=True)
|
|
|
+class TestRawForPreSaveImageFeatureDetection(TestCase):
|
|
|
+ fixtures = ["test.json"]
|
|
|
+
|
|
|
+ # just to test the file is from a fixture doesn't actually exists.
|
|
|
+ # raw check in pre_save_image_feature_detection skips on the provided condition of this test
|
|
|
+ # hence avoiding an error
|
|
|
+
|
|
|
+ def test_image_does_not_exist(self):
|
|
|
+ bad_image = Image.objects.get(pk=1)
|
|
|
+ self.assertFalse(bad_image.file.storage.exists(bad_image.file.name))
|