Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
fix get_product_image_thumbnail when data is None (#16591)
Artur663bf6d9bbc1
diff --git a/saleor/plugins/email_common.py b/saleor/plugins/email_common.pyindex 65e59466a2..819c9bc264 100644--- a/saleor/plugins/email_common.py+++ b/saleor/plugins/email_common.py@@ -144,8 +144,10 @@ def format_datetime(this, date, date_format=None):def get_product_image_thumbnail(this, size: int, image_data):"""Use provided size to get a correct image."""+ if image_data is None:+ returnexpected_size = get_thumbnail_size(size)- return image_data["original"][str(expected_size)]+ return image_data.get("original", {}).get(str(expected_size))def compare(this, val1, compare_operator, val2):diff --git a/saleor/plugins/tests/test_email_common.py b/saleor/plugins/tests/test_email_common.pyindex bc7dde41d4..6bdf971731 100644--- a/saleor/plugins/tests/test_email_common.py+++ b/saleor/plugins/tests/test_email_common.py@@ -114,3 +114,14 @@ def test_get_product_image_thumbnail_simulate_json_dump_and_load(product_with_im# thenassert thumbnail == image_data["original"]["128"]+++def test_get_product_image_thumbnail_image_missing(product_with_image):+ # given+ image_data = None++ # when+ thumbnail = get_product_image_thumbnail(None, 100, image_data)++ # then+ assert thumbnail is None