Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve test coverage and remove unused arguments
Unknown9fc2b2e7dd4e
diff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.pyindex 78bf744efe..e155ad6d5f 100644--- a/tests/api/test_checkout.py+++ b/tests/api/test_checkout.py@@ -78,7 +78,8 @@ def test_checkout_create_reuse_cart(cart, user_api_client, variant):variables = {'checkoutInput': {'lines': [{'quantity': 1, 'variantId': variant_id}], }}- response = user_api_client.post_graphql(MUTATION_CHECKOUT_CREATE, variables)+ response = user_api_client.post_graphql(+ MUTATION_CHECKOUT_CREATE, variables)content = get_graphql_content(response)# assert that existing cart was reused and returned by mutation@@ -275,7 +276,7 @@ def test_checkout_available_shipping_methods(def test_checkout_no_available_shipping_methods_without_address(- api_client, cart_with_item, shipping_zone):+ api_client, cart_with_item):query = """query getCheckout($token: UUID!) {checkout(token: $token) {@@ -294,7 +295,7 @@ def test_checkout_no_available_shipping_methods_without_address(def test_checkout_no_available_shipping_methods_without_lines(- api_client, cart, shipping_zone):+ api_client, cart):query = """query getCheckout($token: UUID!) {checkout(token: $token) {@@ -609,7 +610,7 @@ def test_checkout_customer_detach(def test_checkout_customer_detach_without_customer(- user_api_client, cart_with_item, customer_user):+ user_api_client, cart_with_item):cart = cart_with_itemcheckout_id = graphene.Node.to_global_id('Checkout', cart.pk)@@ -993,8 +994,8 @@ def test_checkout_prices(user_api_client, cart_with_item):@patch('saleor.graphql.checkout.mutations.clean_shipping_method')def test_checkout_shipping_method_update(- mock_clean_shipping, staff_api_client, shipping_method, cart_with_item,- sale, vatlayer):+ mock_clean_shipping, staff_api_client,+ shipping_method, cart_with_item):query = """mutation checkoutShippingMethodUpdate($checkoutId:ID!, $shippingMethodId:ID!){@@ -1142,6 +1143,17 @@ def test_ready_to_place_order_invalid_shipping_method(assert error == 'Shipping method is not valid for your shipping address'+def test_ready_to_place_order_no_billing_address(+ cart_with_item, address, shipping_method):+ checkout = cart_with_item+ checkout.shipping_address = address+ checkout.shipping_method = shipping_method+ checkout.save()+ ready, error = ready_to_place_order(checkout, None, None)+ assert not ready+ assert error == 'Billing address is not set'++def test_ready_to_place_order_no_payment(cart_with_item, shipping_method, address):checkout = cart_with_item@@ -1316,7 +1328,8 @@ def test_checkout_shipping_address_update_with_not_applicable_voucher(cart_with_item.shipping_address = address_other_countrycart_with_item.shipping_method = shipping_methodcart_with_item.save(update_fields=['shipping_address', 'shipping_method'])- assert cart_with_item.shipping_address.country == address_other_country.country+ assert cart_with_item.shipping_address.country == \+ address_other_country.countryvoucher = voucher_shipping_typeassert voucher.countries[0].code == address_other_country.countrydiff --git a/tests/api/test_payment.py b/tests/api/test_payment.pyindex b85d80c9d1..20e759956a 100644--- a/tests/api/test_payment.py+++ b/tests/api/test_payment.py@@ -183,6 +183,25 @@ def test_payment_capture_success(assert txn.kind == TransactionKind.CAPTURE+def test_payment_capture_with_invalid_argument(+ staff_api_client, permission_manage_orders, payment_txn_preauth):+ payment = payment_txn_preauth+ assert payment.charge_status == ChargeStatus.NOT_CHARGED+ payment_id = graphene.Node.to_global_id(+ 'Payment', payment_txn_preauth.pk)++ variables = {+ 'paymentId': payment_id,+ 'amount': 0}+ response = staff_api_client.post_graphql(+ CAPTURE_QUERY, variables, permissions=[permission_manage_orders])+ content = get_graphql_content(response)+ data = content['data']['paymentCapture']+ assert len(data['errors']) == 1+ assert data['errors'][0]['message'] == \+ 'Amount should be a positive number.'++def test_payment_capture_gateway_error(staff_api_client, permission_manage_orders, payment_txn_preauth,monkeypatch):@@ -251,6 +270,27 @@ def test_payment_refund_success(assert txn.kind == TransactionKind.REFUND+def test_payment_refund_with_invalid_argument(+ staff_api_client, permission_manage_orders, payment_txn_captured):+ payment = payment_txn_captured+ payment.charge_status = ChargeStatus.CHARGED+ payment.captured_amount = payment.total+ payment.save()+ payment_id = graphene.Node.to_global_id(+ 'Payment', payment.pk)++ variables = {+ 'paymentId': payment_id,+ 'amount': 0}+ response = staff_api_client.post_graphql(+ REFUND_QUERY, variables, permissions=[permission_manage_orders])+ content = get_graphql_content(response)+ data = content['data']['paymentRefund']+ assert len(data['errors']) == 1+ assert data['errors'][0]['message'] == \+ 'Amount should be a positive number.'++def test_payment_refund_error(staff_api_client, permission_manage_orders, payment_txn_captured,monkeypatch):