Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Set type of conutry to enum in addres input
fowczarek6ab218144403
diff --git a/saleor/graphql/account/types.py b/saleor/graphql/account/types.pyindex 3422fdd731..6b5bd55ed4 100644--- a/saleor/graphql/account/types.py+++ b/saleor/graphql/account/types.py@@ -17,7 +17,7 @@ from ..core.types import CountryDisplay, Image, MetadataObjectType, PermissionDifrom ..core.utils import get_node_optimizedfrom ..decorators import one_of_permissions_requiredfrom ..utils import format_permissions_for_display-from .enums import CustomerEventsEnum+from .enums import CountryCodeEnum, CustomerEventsEnumclass AddressInput(graphene.InputObjectType):@@ -29,7 +29,7 @@ class AddressInput(graphene.InputObjectType):city = graphene.String(description="City.")city_area = graphene.String(description="District.")postal_code = graphene.String(description="Postal code.")- country = graphene.String(description="Country.")+ country = CountryCodeEnum(description="Country.")country_area = graphene.String(description="State or province.")phone = graphene.String(description="Phone number.")diff --git a/tests/api/test_account.py b/tests/api/test_account.pyindex 0d0dea254b..faa693205f 100644--- a/tests/api/test_account.py+++ b/tests/api/test_account.py@@ -1895,7 +1895,7 @@ def test_create_address_mutation(staff_api_client, customer_user, permission_manage_users):query = """- mutation CreateUserAddress($user: ID!, $city: String!, $country: String!) {+ mutation CreateUserAddress($user: ID!, $city: String!, $country: CountryCode!) {addressCreate(userId: $user, input: {city: $city, country: $country}) {errors {fielddiff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.pyindex b744c7a001..2a84d23b60 100644--- a/tests/api/test_checkout.py+++ b/tests/api/test_checkout.py@@ -978,28 +978,6 @@ def test_checkout_shipping_address_update_without_phone_country_prefix(assert not data["errors"]-def test_checkout_shipping_address_update_invalid_country_code(- user_api_client, checkout_with_item, graphql_address_data-):- checkout = checkout_with_item- assert checkout.shipping_address is None- checkout_id = graphene.Node.to_global_id("Checkout", checkout.pk)-- shipping_address = graphql_address_data- shipping_address["country"] = "CODE"- variables = {"checkoutId": checkout_id, "shippingAddress": shipping_address}-- response = user_api_client.post_graphql(- MUTATION_CHECKOUT_SHIPPING_ADDRESS_UPDATE, variables- )- content = get_graphql_content(response)- data = content["data"]["checkoutShippingAddressUpdate"]- assert data["errors"][0]["message"] == "Invalid country code."- assert data["errors"][0]["field"] == "country"-- assert data["checkoutErrors"][0]["code"] == CheckoutErrorCode.INVALID.name--def test_checkout_billing_address_update(user_api_client, checkout_with_item, graphql_address_data):