Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Test is_shipping_required DeliveryGroup method
Anna Siwikf382e837708e
diff --git a/tests/conftest.py b/tests/conftest.pyindex a58257063c..ed63eac9a4 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -272,6 +272,18 @@ def product_in_stock(product_type, default_category):return product+def product_without_shipping(default_category):+ product_type = ProductType.objects.create(+ name='Type with no shipping', has_variants=False,+ is_shipping_required=False)+ product = Product.objects.create(+ name='Test product', price=Decimal('10.00'),+ product_type=product_type, category=default_category)+ variant = ProductVariant.objects.create(product=product, sku='SKU_B')+ return product++@pytest.fixturedef product_list(product_type, default_category):product_attr = product_type.product_attributes.first()@@ -486,7 +498,7 @@ def delivery_group(order, product_type, default_category):name='Test product', price=Decimal('10.00'),product_type=product_type, category=default_category)variant = ProductVariant.objects.create(product=product, sku='SKU_A')- warehouse = StockLocation.objects.create(name='Warehouse 1')+ warehouse = StockLocation.objects.create(name='Warehouse 2')stock = Stock.objects.create(variant=variant, cost_price=1, quantity=5, quantity_allocated=3,location=warehouse)diff --git a/tests/test_order.py b/tests/test_order.pyindex 8f0117991e..750660afbf 100644--- a/tests/test_order.py+++ b/tests/test_order.py@@ -1,3 +1,4 @@+from decimal import Decimalfrom django.test.client import RequestFactoryfrom django.urls import reversefrom prices import Price@@ -150,3 +151,29 @@ def test_create_order_history(order_with_lines):history_entry = models.OrderHistoryEntry.objects.get(order=order)assert history_entry == order.history.first()assert history_entry.content == 'test_entry'+++def test_delivery_group_is_shipping_required(delivery_group):+ assert delivery_group.is_shipping_required()+++def test_delivery_group_is_shipping_required_no_shipping(delivery_group):+ line = delivery_group.lines.first()+ product_type = line.product.product_type+ product_type.is_shipping_required = False+ product_type.save()+ assert not delivery_group.is_shipping_required()+++def test_delivery_group_is_shipping_required_partially_required(+ delivery_group, product_without_shipping):+ variant = product_without_shipping.variants.get()+ delivery_group.lines.create(+ delivery_group=delivery_group,+ product=product_without_shipping,+ product_name=product_without_shipping.name,+ product_sku=variant.sku,+ quantity=3,+ unit_price_net=Decimal('30.00'),+ unit_price_gross=Decimal('30.00'))+ assert delivery_group.is_shipping_required()