本文整理汇总了Python中shop.models.productmodel.Product.get_product_reference方法的典型用法代码示例。如果您正苦于以下问题:Python Product.get_product_reference方法的具体用法?Python Product.get_product_reference怎么用?Python Product.get_product_reference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shop.models.productmodel.Product
的用法示例。
在下文中一共展示了Product.get_product_reference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OrderConversionTestCase
# 需要导入模块: from shop.models.productmodel import Product [as 别名]
# 或者: from shop.models.productmodel.Product import get_product_reference [as 别名]
#.........这里部分代码省略.........
self.assertEqual(ois[0].line_subtotal, self.PRODUCT_PRICE)
self.assertEqual(ois[0].line_total, self.PRODUCT_PRICE)
self.assertEqual(o.order_subtotal, self.cart.subtotal_price)
self.assertEqual(o.order_total, self.cart.total_price)
def test_create_order_order_items_proper_product_name(self):
baseproduct = BaseProduct.objects.create(
name="Table",
unit_price=self.PRODUCT_PRICE
)
variation = ProductVariation.objects.create(
baseproduct=baseproduct,
name="white"
)
self.cart.add_product(variation)
self.cart.update()
self.cart.save()
o = Order.objects.create_from_cart(self.cart)
ois = OrderItem.objects.filter(order=o)
self.assertEqual(ois[0].product_name, "Table - white")
def test_create_order_from_taxed_cart(self):
"""
This time assert that everything is consistent with a tax cart modifier
"""
MODIFIERS = [
'shop.cart.modifiers.tax_modifiers.TenPercentGlobalTaxModifier']
with SettingsOverride(SHOP_CART_MODIFIERS=MODIFIERS):
self.cart.add_product(self.product)
self.cart.update()
self.cart.save()
o = Order.objects.create_from_cart(self.cart,)
# Must not return None, obviously
self.assertNotEqual(o, None)
# Compare all the OrderItems to all CartItems (length)
ois = OrderItem.objects.filter(order=o)
cis = CartItem.objects.filter(cart=self.cart)
self.assertEqual(len(ois), len(cis))
self.assertEqual(ois[0].line_subtotal, self.PRODUCT_PRICE)
self.assertEqual(ois[0].line_total, self.PRODUCT_PRICE)
# Assert that there are as many extra_cart_price_fields than there
# are extra order price fields
e_cart_fields = self.cart.extra_price_fields
e_order_fields = ExtraOrderPriceField.objects.filter(order=o)
self.assertEqual(len(e_cart_fields), len(e_order_fields))
# Check that totals match
self.assertEqual(o.order_subtotal, self.cart.subtotal_price)
self.assertEqual(o.order_total, self.cart.total_price)
self.assertNotEqual(o.order_subtotal, Decimal("0"))
self.assertNotEqual(o.order_total, Decimal("0"))
def test_order_addresses_match_user_preferences(self):
self.cart.add_product(self.product)
self.cart.update()
self.cart.save()
self.address.is_billing = False
self.address.save()
o = Order.objects.create_from_cart(self.cart)
# Must not return None, obviously
self.assertNotEqual(o, None)
o.set_shipping_address(self.address)
o.set_billing_address(self.address2)
self.assertEqual(o.shipping_address_text, self.address.as_text())
self.assertEqual(o.billing_address_text, self.address2.as_text())
def test_create_order_respects_product_specific_get_price_method(self):
if SKIP_BASEPRODUCT_TEST:
return
baseproduct = BaseProduct.objects.create(unit_price=Decimal('10.0'))
product = ProductVariation.objects.create(baseproduct=baseproduct)
self.cart.add_product(product)
self.cart.update()
self.cart.save()
o = Order.objects.create_from_cart(self.cart)
oi = OrderItem.objects.filter(order=o)[0]
self.assertEqual(oi.unit_price, baseproduct.unit_price)
def test_create_from_cart_respects_get_product_reference(self):
self.cart.add_product(self.product)
self.cart.update()
self.cart.save()
o = Order.objects.create_from_cart(self.cart)
oi = OrderItem.objects.filter(order=o)[0]
self.assertEqual(oi.product_reference, self.product.get_product_reference())