Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Tests refactor
Tomasz Szymanski7712bfc2d3d5
diff --git a/tests/api/test_order.py b/tests/api/test_order.pyindex 9e3a09eaad..0cc92e675b 100644--- a/tests/api/test_order.py+++ b/tests/api/test_order.py@@ -31,7 +31,7 @@ from saleor.payment.models import Paymentfrom saleor.shipping.models import ShippingMethodfrom saleor.warehouse.models import Stock-from .utils import assert_field_has_error, assert_no_permission, get_graphql_content+from .utils import assert_no_permission, get_graphql_content@pytest.fixture@@ -2823,7 +2823,6 @@ REQUEST_INVOICE_MUTATION = """) {invoiceErrors {field- messagecode}}@@ -2846,7 +2845,6 @@ CREATE_INVOICE_MUTATION = """}invoiceErrors {field- messagecode}}@@ -2861,7 +2859,6 @@ DELETE_INVOICE_MUTATION = """) {invoiceErrors {field- messagecode}}@@ -2884,7 +2881,6 @@ UPDATE_INVOICE_MUTATION = """}invoiceErrors {field- messagecode}}@@ -3104,8 +3100,14 @@ def test_create_invoice_empty_params()content = get_graphql_content(response)errors = content["data"]["createInvoice"]["invoiceErrors"]- for field in ("number", "url"):- assert_field_has_error(field, InvoiceErrorCode.REQUIRED.name, errors)+ assert errors[0] == {+ "field": "url",+ "code": InvoiceErrorCode.REQUIRED.name,+ }+ assert errors[1] == {+ "field": "number",+ "code": InvoiceErrorCode.REQUIRED.name,+ }assert not Invoice.objects.filter(order_id=order.pk, status=InvoiceStatus.READYdiff --git a/tests/api/utils.py b/tests/api/utils.pyindex c9bd794789..129dbe32e8 100644--- a/tests/api/utils.py+++ b/tests/api/utils.py@@ -21,13 +21,6 @@ def get_graphql_content(response, *, ignore_errors: bool = False):return content-def assert_field_has_error(field: str, code: str, errors: list):- """Assert if there is an error with provided field and code in error list"""- assert list(- filter(lambda error: error["field"] == field and error["code"] == code, errors,)- )--def assert_no_permission(response):content = _get_graphql_content_from_response(response)assert "errors" in content, content