Skip to content

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

Add tests

michal6bb4436474c9
diff --git a/saleor/order/models.py b/saleor/order/models.py
index b0c5eaa8c3..953e499ff4 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -323,7 +323,7 @@ class OrderedItemManager(models.Manager):
order.create_history_entry(
status=OrderStatus.CANCELLED, comment=pgettext_lazy(
'Order status history entry',
- 'Shipment canceled. No items in shipment'))
+ 'Order cancelled. No items in order'))
@python_2_unicode_compatible
diff --git a/tests/test_order.py b/tests/test_order.py
index 178fe9e71a..fa35e7558f 100644
--- a/tests/test_order.py
+++ b/tests/test_order.py
@@ -45,3 +45,26 @@ def test_order_discount(sale, order, request_cart_with_item):
group, cart.lines.all(), discounts=cart.discounts)
item = group.items.first()
assert item.get_price_per_item() == Price(currency="USD", net=5)
+
+
+def test_ordered_item_change_quantity(transactional_db, order_with_items):
+ assert list(order_with_items.history.all()) == []
+ items = order_with_items.groups.all()[0].items.all()
+ items[0].change_quantity(0)
+ items[1].change_quantity(0)
+ items[2].change_quantity(0)
+ history = list(order_with_items.history.all())
+ assert len(history) == 1
+ assert history[0].status == 'cancelled'
+ assert history[0].comment == 'Order cancelled. No items in order'
+
+
+def test_ordered_item_remove_empty_groupwith_force(
+ transactional_db, order_with_items):
+ group = order_with_items.groups.all()[0]
+ items = group.items.all()
+ models.OrderedItem.objects.remove_empty_groups(items[0], force=True)
+ history = list(order_with_items.history.all())
+ assert len(history) == 1
+ assert history[0].status == 'cancelled'
+ assert history[0].comment == 'Order cancelled. No items in order'