def cart_draft(client): product_1 = client.products.create( types.ProductDraft( key=f"product-1", product_type=types.ProductTypeResourceIdentifier(key="dummy"), name=types.LocalizedString(en=f"my-product-1"), slug=types.LocalizedString(en=f"my-product-1"), publish=True, )) product_2 = client.products.create( types.ProductDraft( key=f"product-2", product_type=types.ProductTypeResourceIdentifier(key="dummy"), name=types.LocalizedString(en=f"my-product-2"), slug=types.LocalizedString(en=f"my-product-2"), publish=True, )) return types.CartDraft( customer_id=str(uuid.uuid4()), customer_email="*****@*****.**", currency="GBP", anonymous_id=str(uuid.uuid4()), country="GB", inventory_mode=types.InventoryMode.NONE, tax_mode=types.TaxMode.PLATFORM, tax_rounding_mode=types.RoundingMode.HALF_EVEN, tax_calculation_mode=types.TaxCalculationMode.LINE_ITEM_LEVEL, line_items=[ types.LineItemDraft(product_id=product_1.id, quantity=1), types.LineItemDraft(product_id=product_2.id, quantity=2), ], locale="en", origin=types.CartOrigin.CUSTOMER, )
def test_orders_get_by_id(client): cart = client.carts.create(types.CartDraft(currency="EUR")) order = client.orders.create( types.OrderFromCartDraft(id=cart.id, version=1, order_number="test-order") ) assert order.id assert order.order_number == "test-order"
def test_orders_query(client): results = client.orders.query() assert results.total == 0 cart = client.carts.create(types.CartDraft(currency="EUR")) order = client.orders.create( types.OrderFromCartDraft(id=cart.id, version=1, order_number="test-order") ) results = client.orders.query() assert results.total == 1
def test_unknown_expand_terms(client: commercetools.Client): cart = client.carts.create(types.CartDraft(currency="EUR")) order = client.orders.create( types.OrderFromCartDraft(id=cart.id, version=1, order_number="test-order"), expand="nonExisting", ) assert order.id
def cart_draft(): return types.CartDraft( customer_id=str(uuid.uuid4()), customer_email="*****@*****.**", currency="GBP", anonymous_id=str(uuid.uuid4()), country="GB", inventory_mode=types.InventoryMode.NONE, tax_mode=types.TaxMode.PLATFORM, tax_rounding_mode=types.RoundingMode.HALF_EVEN, tax_calculation_mode=types.TaxCalculationMode.LINE_ITEM_LEVEL, line_items=[ types.LineItemDraft(sku="123", quantity=2), types.LineItemDraft(sku="124", quantity=1), ], locale="en", origin=types.CartOrigin.CUSTOMER, )