本文整理汇总了Python中oscar.apps.basket.models.Basket.strategy方法的典型用法代码示例。如果您正苦于以下问题:Python Basket.strategy方法的具体用法?Python Basket.strategy怎么用?Python Basket.strategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oscar.apps.basket.models.Basket
的用法示例。
在下文中一共展示了Basket.strategy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_line_tax_for_zero_tax_strategies
# 需要导入模块: from oscar.apps.basket.models import Basket [as 别名]
# 或者: from oscar.apps.basket.models.Basket import strategy [as 别名]
def test_line_tax_for_zero_tax_strategies(self):
basket = Basket()
basket.strategy = strategy.Default()
product = factories.create_product()
# Tax for the default strategy will be 0
factories.create_stockrecord(
product, price_excl_tax=D('75.00'), num_in_stock=10)
basket.add(product, 1)
self.assertEqual(basket.lines.first().line_tax, D('0'))
示例2: test_totals_for_free_products
# 需要导入模块: from oscar.apps.basket.models import Basket [as 别名]
# 或者: from oscar.apps.basket.models.Basket import strategy [as 别名]
def test_totals_for_free_products(self):
basket = Basket()
basket.strategy = strategy.Default()
# Add a zero-priced product to the basket
product = factories.create_product()
factories.create_stockrecord(
product, price_excl_tax=D('0.00'), num_in_stock=10)
basket.add(product, 1)
self.assertEqual(basket.lines.count(), 1)
self.assertEqual(basket.total_excl_tax, 0)
self.assertEqual(basket.total_incl_tax, 0)
示例3: test_line_tax_for_unknown_tax_strategies
# 需要导入模块: from oscar.apps.basket.models import Basket [as 别名]
# 或者: from oscar.apps.basket.models.Basket import strategy [as 别名]
def test_line_tax_for_unknown_tax_strategies(self):
class UnknownTaxStrategy(strategy.Default):
""" A test strategy where the tax is not known """
def pricing_policy(self, product, stockrecord):
return prices.FixedPrice('GBP', stockrecord.price_excl_tax, tax=None)
basket = Basket()
basket.strategy = UnknownTaxStrategy()
product = factories.create_product()
factories.create_stockrecord(product, num_in_stock=10)
basket.add(product, 1)
self.assertEqual(basket.lines.first().line_tax, None)
示例4: test_basket_lines_are_converted_to_xml
# 需要导入模块: from oscar.apps.basket.models import Basket [as 别名]
# 或者: from oscar.apps.basket.models.Basket import strategy [as 别名]
def test_basket_lines_are_converted_to_xml(self):
product = factories.create_product(price=D("12.99"))
basket = Basket()
# Nasty hack to make test suite work with both Oscar 0.5 and 0.6
try:
from oscar.apps.partner import strategy
except ImportError:
pass
else:
basket.strategy = strategy.Default()
basket.add_product(product)
data = the3rdman.build_data_dict(basket=basket)
doc = the3rdman.add_fraud_fields(**data)
xml = doc.toxml()
self.assertXmlElementEquals(xml, "3", "The3rdMan.CustomerInformation.sales_channel")