Skip to content

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

Fix tests and issues caught by tests

Marcin Gębalaa081eb33890e
diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.py
index 36f1c676a2..8031853abb 100644
--- a/saleor/graphql/checkout/mutations.py
+++ b/saleor/graphql/checkout/mutations.py
@@ -461,14 +461,16 @@ class CheckoutComplete(BaseMutation):
errors = []
checkout = cls.get_node_or_error(
info, checkout_id, errors, 'checkout_id', only_type=Checkout)
- if checkout is not None:
- taxes = get_taxes_for_cart(checkout, info.context.taxes)
- ready, checkout_error = ready_to_place_order(
- checkout, taxes, info.context.discounts)
- if not ready:
- cls.add_error(
- field=None, message=checkout_error, errors=errors)
- return CheckoutComplete(errors=errors)
+ if checkout is None:
+ return CheckoutComplete(errors=errors)
+
+ taxes = get_taxes_for_cart(checkout, info.context.taxes)
+ ready, checkout_error = ready_to_place_order(
+ checkout, taxes, info.context.discounts)
+ if not ready:
+ cls.add_error(
+ field=None, message=checkout_error, errors=errors)
+ return CheckoutComplete(errors=errors)
try:
order = create_order(
diff --git a/saleor/payment/utils.py b/saleor/payment/utils.py
index 31fdeb69ad..25fb98f8bd 100644
--- a/saleor/payment/utils.py
+++ b/saleor/payment/utils.py
@@ -231,7 +231,7 @@ def clean_mark_order_as_paid(order: Order):
raise PaymentError(
pgettext_lazy(
'Mark order as paid validation error',
- 'Orders with payments can not be manually marked as paid'))
+ 'Orders with payments can not be manually marked as paid.'))
def call_gateway(operation_type, payment, payment_token, **extra_params):
diff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.py
index 3581df1c6a..df148a0459 100644
--- a/tests/api/test_checkout.py
+++ b/tests/api/test_checkout.py
@@ -1097,7 +1097,7 @@ def test_is_fully_paid(cart_with_item, payment_dummy):
payment.currency = total.gross.currency
payment.checkout = checkout
payment.save()
- is_paid = is_fully_paid(checkout)
+ is_paid = is_fully_paid(checkout, None, None)
assert is_paid
@@ -1119,7 +1119,7 @@ def test_is_fully_paid_many_payments(cart_with_item, payment_dummy):
payment2.currency = total.gross.currency
payment2.checkout = checkout
payment2.save()
- is_paid = is_fully_paid(checkout)
+ is_paid = is_fully_paid(checkout, None, None)
assert is_paid
@@ -1133,11 +1133,11 @@ def test_is_fully_paid_partially_paid(cart_with_item, payment_dummy):
payment.currency = total.gross.currency
payment.checkout = checkout
payment.save()
- is_paid = is_fully_paid(checkout)
+ is_paid = is_fully_paid(checkout, None, None)
assert not is_paid
def test_is_fully_paid_no_payment(cart_with_item):
checkout = cart_with_item
- is_paid = is_fully_paid(checkout)
+ is_paid = is_fully_paid(checkout, None, None)
assert not is_paid
diff --git a/tests/api/test_payment.py b/tests/api/test_payment.py
index afc9311eb0..943fc13767 100644
--- a/tests/api/test_payment.py
+++ b/tests/api/test_payment.py
@@ -1,6 +1,7 @@
from unittest.mock import patch
import graphene
+import pytest
from saleor.core.utils import get_country_name_by_code
from saleor.graphql.payment.enums import (
@@ -263,6 +264,7 @@ CHARGE_QUERY = """
"""
def test_payment_charge_success(
staff_api_client, permission_manage_orders, payment_dummy):
payment = payment_dummy
diff --git a/tests/test_checkout.py b/tests/test_checkout.py
index ebd6336fe5..e901e01f76 100644
--- a/tests/test_checkout.py
+++ b/tests/test_checkout.py
@@ -521,7 +521,7 @@ def test_create_order_insufficient_stock(
add_variant_to_cart(request_cart, variant, 10, check_quantity=False)
request_cart.user = customer_user
request_cart.billing_address = customer_user.default_billing_address
- cart.shipping_address = customer_user.default_billing_address
+ request_cart.shipping_address = customer_user.default_billing_address
request_cart.save()
with pytest.raises(InsufficientStock):