Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix review remarks
fowczarek2c99a795a27c
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex db02ff9af0..6525b67a44 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -147,7 +147,8 @@ class ProductTypeForm(forms.ModelForm):return dataself.check_if_variants_changed(has_variants)- update_variants_names.delay(self.instance, saved_attributes=variant_attr)+ update_variants_names.delay(+ self.instance, saved_attributes=variant_attr)return datadef check_if_variants_changed(self, has_variants):diff --git a/saleor/product/tasks.py b/saleor/product/tasks.pyindex 8acbaaeb24..993600901e 100644--- a/saleor/product/tasks.py+++ b/saleor/product/tasks.py@@ -5,6 +5,7 @@ from .utils.attributes import get_name_from_attributesdef _update_variants_names(instance, saved_attributes):+ """update saved variants name for products type."""initial_attributes = set(instance.variant_attributes.all())attributes_changed = initial_attributes.intersection(saved_attributes)if not attributes_changed:diff --git a/tests/api/test_product.py b/tests/api/test_product.pyindex 2bf82e77d0..9b573fd71d 100644--- a/tests/api/test_product.py+++ b/tests/api/test_product.py@@ -12,6 +12,7 @@ from saleor.graphql.core.types import ReportingPeriodfrom saleor.graphql.product.types import StockAvailabilityfrom saleor.product.models import (Category, Collection, Product, ProductImage, ProductType, ProductVariant)+from saleor.product.tasks import update_variants_namesfrom .utils import assert_no_permission, get_multipart_request_body@@ -1239,6 +1240,7 @@ def test_unassign_not_assigned_variant_image(assert content['data']['variantImageUnassign']['errors'][0]['field'] == ('imageId')+@patch('saleor.product.tasks.update_variants_names.delay')def test_product_type_update_changes_variant_name(mock_update_variants_names, staff_api_client, product_type,@@ -1287,6 +1289,14 @@ def test_product_type_update_changes_variant_name(product_type, variant_attributes)+@patch('saleor.product.tasks._update_variants_names')+def test_product_update_variants_names(mock__update_variants_names,+ product_type):+ variant_attributes = [product_type.variant_attributes.first()]+ update_variants_names(product_type, variant_attributes)+ mock__update_variants_names.assert_called_once_with(+ product_type, variant_attributes)+def test_product_variants_by_ids(user_api_client, variant):query = """diff --git a/tests/test_product_attributes.py b/tests/test_product_attributes.pyindex 1d2ad85661..1dc1de7290 100644--- a/tests/test_product_attributes.py+++ b/tests/test_product_attributes.py@@ -73,11 +73,13 @@ def test_generate_name_from_values_empty():def test_product_type_update_changes_variant_name(product_type):- variant = product_type.variant_attributes.first()- variant.name = "test_name"- variant.save()- _update_variants_names(product_type, set([variant]))- assert product_type.variant_attributes.first().name == "test_name"+ new_name = 'test_name'+ variant_attr = product_type.variant_attributes.first()+ assert not variant_attr.name == new_name+ variant_attr.name = new_name+ variant_attr.save()+ _update_variants_names(product_type, [variant_attr])+ assert product_type.variant_attributes.first().name == new_namedef test_update_variants_changed_does_nothing_with_no_attributes():