Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add tests for address validator with updated fields

Unknownf7b63a71dab7
diff --git a/tests/api/test_account.py b/tests/api/test_account.py
index 713b48af19..c438eddf63 100644
--- a/tests/api/test_account.py
+++ b/tests/api/test_account.py
@@ -1135,6 +1135,48 @@ def test_address_validator_uses_geip_when_country_code_missing(
assert data['countryName'] == 'UNITED STATES'
+def test_address_validator_with_country_area(user_api_client):
+ query = """
+ query getValidator($input: AddressValidationInput!) {
+ addressValidator(input: $input) {
+ countryCode
+ countryName
+ countryAreaType
+ countryAreaChoices {
+ verbose
+ raw
+ }
+ cityType
+ cityChoices {
+ raw
+ verbose
+ }
+ cityAreaType
+ cityAreaChoices {
+ raw
+ verbose
+ }
+ }
+ }
+ """
+ variables = {
+ 'input': {
+ 'countryCode': 'CN',
+ 'countryArea': 'Fujian Sheng',
+ 'cityArea': None}}
+ response = user_api_client.post_graphql(query, variables)
+ content = get_graphql_content(response)
+ data = content['data']['addressValidator']
+ assert data['countryCode'] == 'CN'
+ assert data['countryName'] == 'CHINA'
+ assert data['countryAreaType'] == 'province'
+ assert data['countryAreaChoices']
+ assert data['cityType'] == 'city'
+ assert data['cityChoices']
+ assert data['cityAreaType'] == 'city'
+ assert not data['cityAreaChoices']
+
+
@patch('saleor.account.emails.send_password_reset_email.delay')
def test_customer_reset_password(
send_password_reset_mock, user_api_client, customer_user):