Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix thumbnail generation (#12347)
Przemysław Ładab7952addef53
diff --git a/saleor/thumbnail/tests/test_utils.py b/saleor/thumbnail/tests/test_utils.pyindex 82a8869940..698afbb06a 100644--- a/saleor/thumbnail/tests/test_utils.py+++ b/saleor/thumbnail/tests/test_utils.py@@ -4,8 +4,10 @@ import grapheneimport pytestfrom django.core.files import File+from .. import ThumbnailFormatfrom ..models import Thumbnailfrom ..utils import (+ ProcessedImage,get_image_or_proxy_url,get_thumbnail_size,prepare_image_proxy_url,@@ -93,3 +95,20 @@ def test_get_image_or_proxy_url_thumbnail_url_returned(collection, media_root):# thenassert url == thumbnail.image.url++[email protected]("thumb_format", [ThumbnailFormat.WEBP, ThumbnailFormat.AVIF])+def test_processed_image_preprocess_method_called(category_with_image, thumb_format):+ # given+ image_path = category_with_image.background_image.name+ processed_image = ProcessedImage(image_path, 128, thumb_format)+ preprocess_method_name = f"preprocess_{thumb_format.upper()}"+ preprocess_mock = MagicMock()+ preprocess_mock.side_effect = getattr(processed_image, preprocess_method_name)+ setattr(processed_image, preprocess_method_name, preprocess_mock)++ # when+ processed_image.create_thumbnail()++ # then+ preprocess_mock.assert_called_once()diff --git a/saleor/thumbnail/utils.py b/saleor/thumbnail/utils.pyindex e0a42a90f5..4a3604b843 100644--- a/saleor/thumbnail/utils.py+++ b/saleor/thumbnail/utils.py@@ -101,7 +101,7 @@ class ProcessedImage:):self.image_path = image_pathself.size = size- self.format = format+ self.format = format.upper() if format else Noneself.storage = storagedef create_thumbnail(self):