Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add tests for shop fetch tax rates mutation
fowczarek1507cac6adc8
diff --git a/saleor/graphql/shop/mutations.py b/saleor/graphql/shop/mutations.pyindex a65022b862..5960ae144f 100644--- a/saleor/graphql/shop/mutations.py+++ b/saleor/graphql/shop/mutations.py@@ -105,7 +105,7 @@ class ShopFetchTaxRates(BaseMutation):logger.exception(exc)cls.add_error(errors, None, 'Could not fetch tax rates. '- 'Make sure you have supplied a valid API Access Key.'+ 'Make sure you have supplied a valid API Access Key. ''Check the server logs for more information about this error.')return ShopFetchTaxRates(shop=Shop(), errors=errors)diff --git a/tests/api/test_shop.py b/tests/api/test_shop.pyindex 86af3abca0..4d9fe78c3f 100644--- a/tests/api/test_shop.py+++ b/tests/api/test_shop.py@@ -1,12 +1,14 @@+from unittest.mock import patch+import graphenefrom django_countries import countriesfrom django_prices_vatlayer.models import VAT+from tests.api.utils import get_graphql_contentfrom saleor.core.permissions import MODELS_PERMISSIONSfrom saleor.graphql.core.utils import str_to_enumfrom saleor.site import AuthenticationBackendsfrom saleor.site.models import Site-from tests.api.utils import get_graphql_contentdef test_query_authorization_keys(@@ -474,3 +476,37 @@ def test_mutation_authorization_key_delete(query, variables, permissions=[permission_manage_settings])content = get_graphql_content(response)assert content['data']['authorizationKeyDelete']['authorizationKey']+++MUTATION_SHOP_FETCH_TAX_RATES = """+ mutation FetchTaxRates {+ shopFetchTaxRates {+ errors {+ field+ message+ }+ }+ }"""+++def test_shop_fetch_tax_rates_no_api_access_key(+ staff_api_client, permission_manage_settings):+ staff_api_client.user.user_permissions.add(permission_manage_settings)+ response = staff_api_client.post_graphql(+ MUTATION_SHOP_FETCH_TAX_RATES)+ content = get_graphql_content(response)+ data = content['data']['shopFetchTaxRates']+ error_message =('Could not fetch tax rates. '+ 'Make sure you have supplied a valid API Access Key. '+ 'Check the server logs for more information about this error.')+ assert data['errors'][0]['message'] == error_message+++@patch('saleor.graphql.shop.mutations.call_command')+def test_shop_fetch_tax_rates(+ mock_call_command, staff_api_client, permission_manage_settings):+ staff_api_client.user.user_permissions.add(permission_manage_settings)+ response = staff_api_client.post_graphql(+ MUTATION_SHOP_FETCH_TAX_RATES)+ get_graphql_content(response)+ mock_call_command.assert_called_once_with('get_vat_rates')