Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move get_graphql_content to tests/api/utils
Pacu2cdba5cf675ed
diff --git a/tests/api/utils.py b/tests/api/utils.pyindex b060089225..3009f6431e 100644--- a/tests/api/utils.py+++ b/tests/api/utils.py@@ -1,10 +1,19 @@import json-from tests.utils import get_graphql_content-from saleor.graphql.core.utils import snake_to_camel_case-from saleor.graphql.core.utils import snake_to_camel_case++def get_graphql_content(response, check_for_errors=True):+ """Get's GraphQL content from the response, and optionally checks if it+ contains any operating-related errors, eg. schema errors or lack of+ permissions.+ """+ content = json.loads(response.content.decode('utf8'))+ # We should be always checking for errors, unless one want to test lack+ # of permissions+ if check_for_errors:+ assert 'errors' not in content, content['errors']+ return contentdef assert_no_permission(response):diff --git a/tests/utils.py b/tests/utils.pyindex 349d440f2b..c6161a61fd 100644--- a/tests/utils.py+++ b/tests/utils.py@@ -26,12 +26,6 @@ def filter_products_by_attribute(queryset, attribute_id, value):return queryset.filter(in_product | in_variant)-def get_graphql_content(response):- content = json.loads(response.content.decode('utf8'))- assert 'errors' not in content, content['errors']- return content--def get_form_errors(response, form_name='form'):errors = response.context.get(form_name).errorsreturn errors.get('__all__') if errors else []