Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve testing processing group to fit other FSM tests
Anna Siwik0ec9abda4df8
diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.pyindex b78e9ca645..0f72d6c046 100644--- a/tests/dashboard/test_order.py+++ b/tests/dashboard/test_order.py@@ -3,9 +3,11 @@ from decimal import Decimalfrom django.urls import reverseimport pytestfrom django_fsm import TransitionNotAllowed+from prices import Pricefrom tests.utils import get_redirect_location, get_url_path+from saleor.cart.models import Cartfrom saleor.dashboard.order.forms import ChangeQuantityFormfrom saleor.order import GroupStatus, OrderStatusfrom saleor.order.models import (@@ -602,3 +604,60 @@ def test_cant_cancel_cancelled_delivery_group(delivery_group):with pytest.raises(TransitionNotAllowed):delivery_group.cancel()+++def test_process_new_delivery_group(billing_address, product_in_stock):+ variant = product_in_stock.variants.get()+ cart = Cart()+ cart.save()+ cart.add(variant, quantity=2)+ order = Order.objects.create(billing_address=billing_address)+ group = DeliveryGroup.objects.create(order=order)++ group.process(cart.lines.all())+ group.save()++ assert group.status == GroupStatus.NEW+ order_line = group.lines.get()+ stock = order_line.stock+ assert stock.quantity_allocated == 2+++def test_process_new_delivery_group_with_discount(+ sale, order, request_cart_with_item):+ cart = request_cart_with_item+ group = DeliveryGroup.objects.create(order=order)++ group.process(cart.lines.all(), cart.discounts)+ group.save()++ line = group.lines.first()+ assert line.get_price_per_item() == Price(currency="USD", net=5)+++def test_cant_process_cancelled_delivery_group(+ delivery_group, product_in_stock):+ delivery_group.cancel()+ delivery_group.save()++ variant = product_in_stock.variants.get()+ cart = Cart()+ cart.save()+ cart.add(variant, quantity=2)++ with pytest.raises(TransitionNotAllowed):+ delivery_group.process(cart.lines.all())+++def test_cant_process_shipped_delivery_group(+ delivery_group, product_in_stock):+ delivery_group.ship()+ delivery_group.save()++ variant = product_in_stock.variants.get()+ cart = Cart()+ cart.save()+ cart.add(variant, quantity=2)++ with pytest.raises(TransitionNotAllowed):+ delivery_group.process(cart.lines.all())diff --git a/tests/test_order.py b/tests/test_order.pyindex 038d8737db..5dde4c6968 100644--- a/tests/test_order.py+++ b/tests/test_order.py@@ -1,8 +1,6 @@from prices import Price-from saleor.cart.models import Cartfrom saleor.order import models, OrderStatus-from saleor.order.transitions import process_delivery_groupfrom saleor.order.utils import add_variant_to_delivery_group@@ -26,28 +24,6 @@ def test_total_setter():assert order.total_tax.net == 10-def test_stock_allocation(billing_address, product_in_stock):- variant = product_in_stock.variants.get()- cart = Cart()- cart.save()- cart.add(variant, quantity=2)- order = models.Order.objects.create(billing_address=billing_address)- delivery_group = models.DeliveryGroup.objects.create(order=order)- process_delivery_group(delivery_group, cart.lines.all())- order_line = delivery_group.lines.get()- stock = order_line.stock- assert stock.quantity_allocated == 2---def test_order_discount(sale, order, request_cart_with_item):- cart = request_cart_with_item- group = models.DeliveryGroup.objects.create(order=order)- process_delivery_group(- group, cart.lines.all(), discounts=cart.discounts)- line = group.lines.first()- assert line.get_price_per_item() == Price(currency="USD", net=5)--def test_add_variant_to_delivery_group_adds_line_for_new_variant(order_with_lines, product_in_stock):group = order_with_lines.groups.get()