Skip to content

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

Update tests after review comments

Maciej Korycinskib7822473c15c
diff --git a/tests/api/test_fulfillment.py b/tests/api/test_fulfillment.py
index 29c9f266b8..b06dfed0eb 100644
--- a/tests/api/test_fulfillment.py
+++ b/tests/api/test_fulfillment.py
@@ -35,7 +35,7 @@ CREATE_FULFILLMENT_QUERY = """
"""
-@patch("saleor.order.actions.send_fulfillment_confirmation_to_customer")
+@patch("saleor.order.actions.send_fulfillment_confirmation_to_customer", autospec=True)
def test_create_fulfillment(
mock_email_fulfillment,
staff_api_client,
@@ -68,7 +68,7 @@ def test_create_fulfillment(
assert mock_email_fulfillment.call_count == 1
-@patch("saleor.order.actions.send_fulfillment_confirmation_to_customer")
+@patch("saleor.order.actions.send_fulfillment_confirmation_to_customer", autospec=True)
def test_create_fulfillment_with_empty_quantity(
mock_send_fulfillment_confirmation,
staff_api_client,
@@ -245,7 +245,7 @@ def test_cancel_fulfillment(
assert event_cancel_fulfillment.user == staff_user
-@patch("saleor.order.actions.send_fulfillment_confirmation_to_customer")
+@patch("saleor.order.actions.send_fulfillment_confirmation_to_customer", autospec=True)
def test_create_digital_fulfillment(
mock_email_fulfillment,
digital_content,
diff --git a/tests/test_order_actions.py b/tests/test_order_actions.py
index 2ad06b07e1..fbce78b30f 100644
--- a/tests/test_order_actions.py
+++ b/tests/test_order_actions.py
@@ -15,16 +15,8 @@ from saleor.order.actions import (
from saleor.payment import ChargeStatus, PaymentError
-@patch("saleor.order.emails.send_fulfillment_confirmation.delay")
-@patch("saleor.order.emails.send_payment_confirmation.delay")
-def test_handle_fully_paid_order_digital_lines(
- mock_send_payment_confirmation,
- mock_send_fulfillment_confirmation,
- order,
- digital_content,
- variant,
- site_settings,
-):
+def order_with_digital_line(order, digital_content, variant, site_settings):
site_settings.automatic_fulfillment_digital_products = True
site_settings.save()
@@ -48,7 +40,18 @@ def test_handle_fully_paid_order_digital_lines(
unit_price=TaxedMoney(net=net, gross=gross),
tax_rate=23,
)
+ return order
+
+
+@patch("saleor.order.emails.send_fulfillment_confirmation.delay")
+@patch("saleor.order.emails.send_payment_confirmation.delay")
+def test_handle_fully_paid_order_digital_lines(
+ mock_send_payment_confirmation,
+ mock_send_fulfillment_confirmation,
+ order_with_digital_line,
+):
+ order = order_with_digital_line
handle_fully_paid_order(order)
fulfillment = order.fulfillments.first()