Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Merge 'invalid' error codes
Aleksander Spyra5f63941a4056
diff --git a/saleor/account/validators.py b/saleor/account/validators.pyindex 70045e6b2a..c5998b7a5c 100644--- a/saleor/account/validators.py+++ b/saleor/account/validators.py@@ -14,7 +14,6 @@ def validate_possible_number(phone, country=None):or not phone_number.is_valid()):raise ValidationError(- _("The phone number entered is not valid."),- code=AccountErrorCode.INVALID_PHONE_NUMBER,+ _("The phone number entered is not valid."), code=AccountErrorCode.INVALID)return phone_numberdiff --git a/saleor/core/utils/url.py b/saleor/core/utils/url.pyindex 70f6dd1007..2d1e64b3ec 100644--- a/saleor/core/utils/url.py+++ b/saleor/core/utils/url.py@@ -18,7 +18,7 @@ def validate_storefront_url(url):domain, _ = split_domain_port(parsed_url.netloc)except ValueError as error:raise ValidationError(- {"redirectUrl": str(error)}, code=AccountErrorCode.INVALID_STOREFRONT_URL+ {"redirectUrl": str(error)}, code=AccountErrorCode.INVALID)if not validate_host(domain, settings.ALLOWED_CLIENT_HOSTS):error_message = (@@ -26,5 +26,5 @@ def validate_storefront_url(url):"`ALLOWED_CLIENT_HOSTS` configuration.")raise ValidationError(- {"redirectUrl": error_message}, code=AccountErrorCode.INVALID_STOREFRONT_URL+ {"redirectUrl": error_message}, code=AccountErrorCode.INVALID)diff --git a/saleor/graphql/account/i18n.py b/saleor/graphql/account/i18n.pyindex 3b38389994..48b6c27425 100644--- a/saleor/graphql/account/i18n.py+++ b/saleor/graphql/account/i18n.py@@ -35,7 +35,7 @@ class I18nMixin:raise ValidationError({"country": ValidationError(- "Invalid country code.", code=AccountErrorCode.INVALID_COUNTRY+ "Invalid country code.", code=AccountErrorCode.INVALID)})diff --git a/saleor/graphql/account/mutations/account.py b/saleor/graphql/account/mutations/account.pyindex 6b527e58ae..bca514ea4d 100644--- a/saleor/graphql/account/mutations/account.py+++ b/saleor/graphql/account/mutations/account.py@@ -140,11 +140,7 @@ class AccountDelete(AccountErrorMixin, ModelDeleteMutation):token = data.pop("token")if not default_token_generator.check_token(user, token):raise ValidationError(- {- "token": ValidationError(- INVALID_TOKEN, code=AccountErrorCode.INVALID_TOKEN- )- }+ {"token": ValidationError(INVALID_TOKEN, code=AccountErrorCode.INVALID)})db_id = user.iddiff --git a/saleor/graphql/account/mutations/base.py b/saleor/graphql/account/mutations/base.pyindex 940e1d7e2d..fe08825ebb 100644--- a/saleor/graphql/account/mutations/base.py+++ b/saleor/graphql/account/mutations/base.py@@ -105,11 +105,7 @@ class SetPassword(AccountErrorMixin, CreateToken):)if not default_token_generator.check_token(user, token):raise ValidationError(- {- "token": ValidationError(- INVALID_TOKEN, code=AccountErrorCode.INVALID_TOKEN- )- }+ {"token": ValidationError(INVALID_TOKEN, code=AccountErrorCode.INVALID)})try:password_validation.validate_password(password, user)diff --git a/saleor/graphql/core/utils/error_codes.py b/saleor/graphql/core/utils/error_codes.pyindex 31d5e7f5b0..e3a77f7964 100644--- a/saleor/graphql/core/utils/error_codes.py+++ b/saleor/graphql/core/utils/error_codes.py@@ -39,11 +39,7 @@ class AccountErrorCode(Enum):DELETE_SUPERUSER_ACCOUNT = "delete_superuser_account"GRAPHQL_ERROR = "graphql_error"INVALID = "invalid"- INVALID_COUNTRY = "invalid_country"INVALID_PASSWORD = "invalid_password"- INVALID_PHONE_NUMBER = "invalid_phone_number"- INVALID_STOREFRONT_URL = "invalid_storefront_url"- INVALID_TOKEN = "invalid_token"OBJECT_DOES_NOT_EXIST = "object_does_not_exist"PASSWORD_ENTIRELY_NUMERIC = "password_entirely_numeric"PASSWORD_TOO_COMMON = "password_too_common"@@ -59,8 +55,6 @@ class CheckoutErrorCode(Enum):GRAPHQL_ERROR = "graphql_error"INSUFFICIENT_STOCK = "insufficient_stock"INVALID = "invalid"- INVALID_COUNTRY = "invalid_country"- INVALID_PHONE_NUMBER = "invalid_phone_number"INVALID_SHIPPING_METHOD = "invalid_shipping_method"OBJECT_ALREADY_EXISTS = "object_already_exists"OBJECT_DOES_NOT_EXIST = "object_does_not_exist"diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 1d9128364c..ccce35f5a5 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -47,11 +47,7 @@ enum AccountErrorCode {DELETE_SUPERUSER_ACCOUNTGRAPHQL_ERRORINVALID- INVALID_COUNTRYINVALID_PASSWORD- INVALID_PHONE_NUMBER- INVALID_STOREFRONT_URL- INVALID_TOKENOBJECT_DOES_NOT_EXISTPASSWORD_ENTIRELY_NUMERICPASSWORD_TOO_COMMON@@ -693,8 +689,6 @@ enum CheckoutErrorCode {GRAPHQL_ERRORINSUFFICIENT_STOCKINVALID- INVALID_COUNTRY- INVALID_PHONE_NUMBERINVALID_SHIPPING_METHODOBJECT_ALREADY_EXISTSOBJECT_DOES_NOT_EXISTdiff --git a/tests/api/test_account.py b/tests/api/test_account.pyindex 79711c5086..df2e60346d 100644--- a/tests/api/test_account.py+++ b/tests/api/test_account.py@@ -1654,7 +1654,7 @@ def test_set_password_invalid_token(user_api_client, customer_user):account_errors = content["data"]["setPassword"]["accountErrors"]assert account_errors[0]["message"] == INVALID_TOKEN- assert account_errors[0]["code"] == AccountErrorCode.INVALID_TOKEN.name+ assert account_errors[0]["code"] == AccountErrorCode.INVALID.namedef test_set_password_invalid_email(user_api_client):diff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.pyindex b209c6bfb5..5ff340f66d 100644--- a/tests/api/test_checkout.py+++ b/tests/api/test_checkout.py@@ -865,7 +865,7 @@ def test_checkout_shipping_address_with_invalid_phone_number_returns_error({"field": "phone","message": "'+33600000' is not a valid phone number.",- "code": CheckoutErrorCode.INVALID_PHONE_NUMBER.name,+ "code": CheckoutErrorCode.INVALID.name,}]@@ -930,7 +930,7 @@ def test_checkout_shipping_address_update_invalid_country_code(assert data["errors"][0]["message"] == "Invalid country code."assert data["errors"][0]["field"] == "country"- assert data["checkoutErrors"][0]["code"] == CheckoutErrorCode.INVALID_COUNTRY.name+ assert data["checkoutErrors"][0]["code"] == CheckoutErrorCode.INVALID.namedef test_checkout_billing_address_update(