Skip to content

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

Cleanup tests

Ania Warzechaa073da1408f9
diff --git a/saleor/graphql/order/tests/mutations/test_order_line_delete.py b/saleor/graphql/order/tests/mutations/test_order_line_delete.py
index 395fefbb75..6e3004dc5b 100644
--- a/saleor/graphql/order/tests/mutations/test_order_line_delete.py
+++ b/saleor/graphql/order/tests/mutations/test_order_line_delete.py
@@ -132,6 +132,7 @@ def test_order_line_remove_no_line_allocations(
permission_group_manage_orders,
staff_api_client,
):
+ # given
query = ORDER_LINE_DELETE_MUTATION
permission_group_manage_orders.user_set.add(staff_api_client.user)
order = order_with_lines
@@ -142,7 +143,10 @@ def test_order_line_remove_no_line_allocations(
line_id = graphene.Node.to_global_id("OrderLine", line.id)
variables = {"id": line_id}
+ # when
response = staff_api_client.post_graphql(query, variables)
+
+ # then
content = get_graphql_content(response)
data = content["data"]["orderLineDelete"]
assert OrderEvent.objects.count() == 1
diff --git a/saleor/graphql/order/tests/mutations/test_order_line_update.py b/saleor/graphql/order/tests/mutations/test_order_line_update.py
index 9cc72ae25d..4367a4c1fc 100644
--- a/saleor/graphql/order/tests/mutations/test_order_line_update.py
+++ b/saleor/graphql/order/tests/mutations/test_order_line_update.py
@@ -255,6 +255,7 @@ def test_order_line_update_no_allocation(
staff_api_client,
staff_user,
):
+ # given
query = ORDER_LINE_UPDATE_MUTATION
order = order_with_lines
order.status = OrderStatus.UNCONFIRMED
@@ -266,22 +267,16 @@ def test_order_line_update_no_allocation(
line_id = graphene.Node.to_global_id("OrderLine", line.id)
variables = {"lineId": line_id, "quantity": new_quantity}
- # Ensure the line has the expected quantity
- assert line.quantity == 3
-
+ # when
# No event should exist yet
assert not OrderEvent.objects.exists()
- # mutation should fail without proper permissions
- response = staff_api_client.post_graphql(query, variables)
- assert_no_permission(response)
- order_updated_webhook_mock.assert_not_called()
- draft_order_updated_webhook_mock.assert_not_called()
-
# assign permissions
permission_group_manage_orders.user_set.add(staff_api_client.user)
response = staff_api_client.post_graphql(query, variables)
content = get_graphql_content(response)
+
+ # then
data = content["data"]["orderLineUpdate"]
assert data["orderLine"]["quantity"] == new_quantity
assert_proper_webhook_called_once(
@@ -299,14 +294,6 @@ def test_order_line_update_no_allocation(
]
}
- # mutation should fail when quantity is lower than 1
- variables = {"lineId": line_id, "quantity": 0}
- response = staff_api_client.post_graphql(query, variables)
- content = get_graphql_content(response)
- data = content["data"]["orderLineUpdate"]
- assert data["errors"]
- assert data["errors"][0]["field"] == "quantity"
-
def test_order_line_update_by_user_no_channel_access(
order_with_lines,