当前位置: 首页>>代码示例>>Python>>正文


Python Cart.get_total方法代码示例

本文整理汇总了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'))
开发者ID:brew,项目名称:cart-exercise,代码行数:9,代码来源:tests.py

示例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'))
开发者ID:brew,项目名称:cart-exercise,代码行数:11,代码来源:tests.py

示例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'))
开发者ID:brew,项目名称:cart-exercise,代码行数:13,代码来源:tests.py

示例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'))
开发者ID:brew,项目名称:cart-exercise,代码行数:14,代码来源:tests.py

示例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'))
开发者ID:brew,项目名称:cart-exercise,代码行数:7,代码来源:tests.py

示例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)
开发者ID:brew,项目名称:cart-exercise,代码行数:6,代码来源:tests.py

示例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'))
开发者ID:brew,项目名称:cart-exercise,代码行数:8,代码来源:tests.py

示例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'))
开发者ID:brew,项目名称:cart-exercise,代码行数:7,代码来源:tests.py


注:本文中的cart.Cart.get_total方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。