Skip to content

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

Changes after code review

Damian Wysocki46cbf27bd402
diff --git a/tests/api/test_account.py b/tests/api/test_account.py
index 69cb1c62a8..ef583db807 100644
--- a/tests/api/test_account.py
+++ b/tests/api/test_account.py
@@ -636,7 +636,7 @@ def test_customer_register(
customer_creation_event = account_events.CustomerEvent.objects.get()
assert customer_creation_event.type == account_events.CustomerEvents.ACCOUNT_CREATED
assert customer_creation_event.user == new_user
- assert match_orders_with_new_user_mock.call_count == 0
+ match_orders_with_new_user_mock.assert_not_called()
@override_settings(ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL=False)
@@ -645,12 +645,15 @@ def test_customer_register(
def test_customer_register_disabled_email_confirmation(
match_orders_with_new_user_mock, send_account_confirmation_email_mock, api_client
):
- variables = {"email": "[email protected]", "password": "Password"}
+ email = "[email protected]"
+ variables = {"email": email, "password": "Password"}
response = api_client.post_graphql(ACCOUNT_REGISTER_MUTATION, variables)
errors = response.json()["data"]["accountRegister"]["errors"]
+ new_user = User.objects.get(email=email)
+
assert errors == []
assert send_account_confirmation_email_mock.delay.call_count == 0
- assert match_orders_with_new_user_mock.call_count == 1
+ match_orders_with_new_user_mock.assert_called_once_with(new_user)
@override_settings(ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL=True)
diff --git a/tests/test_order_utils.py b/tests/test_order_utils.py
index 799a883e4e..e8bad43d99 100644
--- a/tests/test_order_utils.py
+++ b/tests/test_order_utils.py
@@ -47,17 +47,11 @@ def test_change_quantity_generates_proper_event(
def test_match_orders_with_new_user(customer_user):
- def get_order_user_by_customer_email(email):
- return Order.objects.filter(user_email=email).first().user
-
- customer_email = customer_user.email
address = customer_user.default_billing_address.get_copy()
- Order.objects.create(
- billing_address=address, user=None, user_email=customer_email,
+ order = Order.objects.create(
+ billing_address=address, user=None, user_email=customer_user.email,
)
- assert get_order_user_by_customer_email(customer_email) is None
-
match_orders_with_new_user(customer_user)
-
- assert get_order_user_by_customer_email(customer_email) == customer_user
+ order.refresh_from_db()
+ assert order.user == customer_user