Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Drop unused manager argument in clean_tax_code (#16482)
Marcin Gębala5781b10f0256
diff --git a/saleor/graphql/product/mutations/product/product_create.py b/saleor/graphql/product/mutations/product/product_create.pyindex af05cdc961..069f4d8c5a 100644--- a/saleor/graphql/product/mutations/product/product_create.py+++ b/saleor/graphql/product/mutations/product/product_create.py@@ -195,8 +195,7 @@ class ProductCreate(ModelMutation):except ValidationError as exc:raise ValidationError({"attributes": exc})- manager = get_plugin_manager_promise(info.context).get()- clean_tax_code(cleaned_input, manager)+ clean_tax_code(cleaned_input)clean_seo_fields(cleaned_input)return cleaned_inputdiff --git a/saleor/graphql/product/mutations/product_type/product_type_create.py b/saleor/graphql/product/mutations/product_type/product_type_create.pyindex be33fc7c1c..ddd0dc1d80 100644--- a/saleor/graphql/product/mutations/product_type/product_type_create.py+++ b/saleor/graphql/product/mutations/product_type/product_type_create.py@@ -12,7 +12,6 @@ from ....core.mutations import ModelMutationfrom ....core.scalars import WeightScalarfrom ....core.types import BaseInputObjectType, NonNullList, ProductErrorfrom ....core.validators import validate_slug_and_generate_if_needed-from ....plugins.dataloaders import get_plugin_manager_promisefrom ...enums import ProductTypeKindEnumfrom ...types import ProductTypefrom ..utils import clean_tax_code@@ -117,8 +116,7 @@ class ProductTypeCreate(ModelMutation):error.code = ProductErrorCode.REQUIRED.valueraise ValidationError({"slug": error})- manager = get_plugin_manager_promise(info.context).get()- clean_tax_code(cleaned_input, manager)+ clean_tax_code(cleaned_input)cls.validate_attributes(cleaned_input)return cleaned_inputdiff --git a/saleor/graphql/product/mutations/utils.py b/saleor/graphql/product/mutations/utils.pyindex 9f1f15a443..45d61a02d8 100644--- a/saleor/graphql/product/mutations/utils.py+++ b/saleor/graphql/product/mutations/utils.py@@ -1,10 +1,9 @@from django.db.models import Q-from ....plugins.manager import PluginsManagerfrom ....tax.models import TaxClass-def clean_tax_code(cleaned_input: dict, manager: PluginsManager):+def clean_tax_code(cleaned_input: dict):"""Clean deprecated `taxCode` field.This function provides backwards compatibility for the `taxCode` input field. If thediff --git a/saleor/graphql/product/tests/deprecated/test_utils.py b/saleor/graphql/product/tests/deprecated/test_utils.pyindex 158f70681a..cda668cb4b 100644--- a/saleor/graphql/product/tests/deprecated/test_utils.py+++ b/saleor/graphql/product/tests/deprecated/test_utils.py@@ -1,15 +1,13 @@-from .....plugins.manager import get_plugins_managerfrom .....tax.models import TaxClassfrom ...mutations.utils import clean_tax_codedef test_clean_tax_code_does_nothing_when_empty_data():# given- manager = get_plugins_manager(allow_replica=False)data = {}# when- clean_tax_code(data, manager)+ clean_tax_code(data)# thenassert data == {}@@ -17,11 +15,10 @@ def test_clean_tax_code_does_nothing_when_empty_data():def test_clean_tax_code_does_nothing_when_tax_class_provided():# given- manager = get_plugins_manager(allow_replica=False)data = {"tax_code": "P0000000", "tax_class": "VGF4Q2xhc3M6MQ=="}# when- clean_tax_code(data, manager)+ clean_tax_code(data)# thenassert data == {"tax_code": "P0000000", "tax_class": "VGF4Q2xhc3M6MQ=="}@@ -29,13 +26,12 @@ def test_clean_tax_code_does_nothing_when_tax_class_provided():def test_clean_tax_code_when_tax_class_exists_by_name():# given- manager = get_plugins_manager(allow_replica=False)tax_code = "P0000000"tax_class = TaxClass.objects.create(name=tax_code)data = {"tax_code": tax_code}# when- clean_tax_code(data, manager)+ clean_tax_code(data)# thenassert data["tax_class"] == tax_class@@ -43,13 +39,12 @@ def test_clean_tax_code_when_tax_class_exists_by_name():def test_clean_tax_code_when_tax_class_exists_by_avatax():# given- manager = get_plugins_manager(allow_replica=False)tax_code = "P0000000"tax_class = TaxClass.objects.create(name="Test", metadata={"avatax.code": tax_code})data = {"tax_code": tax_code}# when- clean_tax_code(data, manager)+ clean_tax_code(data)# thenassert data["tax_class"] == tax_class@@ -57,7 +52,6 @@ def test_clean_tax_code_when_tax_class_exists_by_avatax():def test_clean_tax_code_when_tax_class_exists_by_vatlayer():# given- manager = get_plugins_manager(allow_replica=False)tax_code = "P0000000"tax_class = TaxClass.objects.create(name="Test", metadata={"vatlayer.code": tax_code}@@ -65,7 +59,7 @@ def test_clean_tax_code_when_tax_class_exists_by_vatlayer():data = {"tax_code": tax_code}# when- clean_tax_code(data, manager)+ clean_tax_code(data)# thenassert data["tax_class"] == tax_class@@ -73,13 +67,12 @@ def test_clean_tax_code_when_tax_class_exists_by_vatlayer():def test_clean_tax_code_when_tax_class_does_not_exists():# given- manager = get_plugins_manager(allow_replica=False)tax_code = "P0000000"TaxClass.objects.all().delete()data = {"tax_code": tax_code}# when- clean_tax_code(data, manager)+ clean_tax_code(data)# thenassert data["tax_class"] is None