本文整理汇总了Python中cart.Cart.get_total方法的典型用法代码示例。如果您正苦于以下问题:Python Cart.get_total方法的具体用法?Python Cart.get_total怎么用?Python Cart.get_total使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cart.Cart
的用法示例。
在下文中一共展示了Cart.get_total方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_total_multiple_items_multiple_quantity
# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import get_total [as 别名]
def test_get_total_multiple_items_multiple_quantity(self):
'''Correct total for multiple items with multiple quantities in
cart.'''
cart = Cart(self._create_product_store())
cart.add('apple', 2)
cart.add('strawberries', 3)
self.assertEqual(cart.get_total(), Decimal('6.30'))
示例2: test_get_total_with_one_offer
# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import get_total [as 别名]
def test_get_total_with_one_offer(self):
'''Cart get_total returns correct value with a bogof offer applied.'''
product_store = self._create_product_store()
bogof_strawberries = MultiBuyOffer('strawberries', 1, 1)
cart = Cart(product_store)
cart.add('strawberries', 2)
cart.add('apple')
self.assertEqual(
cart.get_total(offers=[bogof_strawberries]), Decimal('2.15'))
示例3: test_get_total_with_dependent_discount_offer
# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import get_total [as 别名]
def test_get_total_with_dependent_discount_offer(self):
'''Cart get_total returns correct value with a dependent discount
offer applied.'''
product_store = self._create_product_store()
strawberries_apple_20_discount = DependentDiscountOffer(
'strawberries', 'apple', Decimal('0.2'))
cart = Cart(product_store)
cart.add('strawberries', 2)
cart.add('apple')
self.assertEqual(
cart.get_total(offers=[strawberries_apple_20_discount]), Decimal('3.75'))
示例4: test_get_total_with_two_offers_on_same_target
# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import get_total [as 别名]
def test_get_total_with_two_offers_on_same_target(self):
'''Cart get_total returns cheapest total when two offers are
applicable for the same target.'''
product_store = self._create_product_store()
bogof_strawberries = MultiBuyOffer('strawberries', 1, 1)
strawberries_apple_20_discount = DependentDiscountOffer(
'strawberries', 'apple', Decimal('0.2'))
cart = Cart(product_store)
cart.add('strawberries', 2)
cart.add('apple')
self.assertEqual(cart.get_total(
offers=[bogof_strawberries, strawberries_apple_20_discount]), Decimal('2.15'))
示例5: test_get_total_one_item
# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import get_total [as 别名]
def test_get_total_one_item(self):
'''Correct total for one item in cart.'''
cart = Cart(self._create_product_store())
cart.add('apple')
self.assertEqual(cart.get_total(), Decimal('0.15'))
示例6: test_get_total_is_decimal
# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import get_total [as 别名]
def test_get_total_is_decimal(self):
'''Cart.get_total() returns a Decimal.'''
cart = Cart()
self.assertTrue(type(cart.get_total()) is Decimal)
示例7: test_get_total_multiple_items
# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import get_total [as 别名]
def test_get_total_multiple_items(self):
'''Correct total for multiple items in cart.'''
cart = Cart(self._create_product_store())
cart.add('apple')
cart.add('strawberries')
self.assertEqual(cart.get_total(), Decimal('2.15'))
示例8: test_get_total_one_item_multiple_quantity
# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import get_total [as 别名]
def test_get_total_one_item_multiple_quantity(self):
'''Correct total for one item with multiple quantity in cart.'''
cart = Cart(self._create_product_store())
cart.add('apple', 3)
self.assertEqual(cart.get_total(), Decimal('0.45'))