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


Python OrderAndItemCharges.set_basket方法代码示例

本文整理汇总了Python中oscar.apps.shipping.models.OrderAndItemCharges.set_basket方法的典型用法代码示例。如果您正苦于以下问题:Python OrderAndItemCharges.set_basket方法的具体用法?Python OrderAndItemCharges.set_basket怎么用?Python OrderAndItemCharges.set_basket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oscar.apps.shipping.models.OrderAndItemCharges的用法示例。


在下文中一共展示了OrderAndItemCharges.set_basket方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: OrderAndItemChargesTests

# 需要导入模块: from oscar.apps.shipping.models import OrderAndItemCharges [as 别名]
# 或者: from oscar.apps.shipping.models.OrderAndItemCharges import set_basket [as 别名]
class OrderAndItemChargesTests(TestCase):

    def setUp(self):
        self.method = OrderAndItemCharges(
            price_per_order=D('5.00'), price_per_item=D('1.00'))
        self.basket = factories.create_basket(empty=True)
        self.method.set_basket(self.basket)

    def test_tax_is_known(self):
        self.assertTrue(self.method.is_tax_known)

    def test_order_level_charge_for_empty_basket(self):
        self.assertEqual(D('5.00'), self.method.charge_incl_tax)

    def test_single_item_basket(self):
        record = factories.create_stockrecord()
        self.basket.add_product(record.product)
        self.assertEqual(D('5.00') + D('1.00'),
                          self.method.charge_incl_tax)

    def test_single_item_basket_that_doesnt_require_shipping(self):
        # Create a product that doesn't require shipping
        record = factories.create_stockrecord()
        product = record.product
        product.product_class.requires_shipping = False
        product.product_class.save()

        self.basket.add_product(record.product)
        self.assertEqual(D('5.00'), self.method.charge_incl_tax)

    def test_multi_item_basket(self):
        record = factories.create_stockrecord()
        self.basket.add_product(record.product, 7)
        self.assertEqual(D('5.00') + 7*D('1.00'), self.method.charge_incl_tax)
开发者ID:AlfiyaZi,项目名称:django-oscar,代码行数:36,代码来源:model_method_tests.py

示例2: ZeroFreeThresholdTest

# 需要导入模块: from oscar.apps.shipping.models import OrderAndItemCharges [as 别名]
# 或者: from oscar.apps.shipping.models.OrderAndItemCharges import set_basket [as 别名]
class ZeroFreeThresholdTest(TestCase):
    def setUp(self):
        self.method = OrderAndItemCharges(price_per_order=D("10.00"), free_shipping_threshold=D("0.00"))
        self.basket = Basket.objects.create()
        self.method.set_basket(self.basket)

    def test_free_shipping_with_empty_basket(self):
        self.assertEquals(D("0.00"), self.method.basket_charge_incl_tax())

    def test_free_shipping_with_nonempty_basket(self):
        p = create_product(D("5.00"))
        self.basket.add_product(p)
        self.assertEquals(D("0.00"), self.method.basket_charge_incl_tax())
开发者ID:mgmtech,项目名称:django-oscar,代码行数:15,代码来源:shipping_tests.py

示例3: ZeroFreeThresholdTest

# 需要导入模块: from oscar.apps.shipping.models import OrderAndItemCharges [as 别名]
# 或者: from oscar.apps.shipping.models.OrderAndItemCharges import set_basket [as 别名]
class ZeroFreeThresholdTest(TestCase):

    def setUp(self):
        self.method = OrderAndItemCharges(price_per_order=D('10.00'), free_shipping_threshold=D('0.00'))
        self.basket = factories.create_basket(empty=True)
        self.method.set_basket(self.basket)

    def test_free_shipping_with_empty_basket(self):
        self.assertEqual(D('0.00'), self.method.charge_incl_tax)

    def test_free_shipping_with_nonempty_basket(self):
        record = factories.create_stockrecord(price_excl_tax=D('5.00'))
        self.basket.add_product(record.product)
        self.assertEqual(D('0.00'), self.method.charge_incl_tax)
开发者ID:AlfiyaZi,项目名称:django-oscar,代码行数:16,代码来源:model_method_tests.py

示例4: OrderAndItemChargesTests

# 需要导入模块: from oscar.apps.shipping.models import OrderAndItemCharges [as 别名]
# 或者: from oscar.apps.shipping.models.OrderAndItemCharges import set_basket [as 别名]
class OrderAndItemChargesTests(TestCase):
    def setUp(self):
        self.method = OrderAndItemCharges(price_per_order=D("5.00"), price_per_item=D("1.00"))
        self.basket = Basket.objects.create()
        self.method.set_basket(self.basket)

    def test_order_level_charge_for_empty_basket(self):
        self.assertEquals(D("5.00"), self.method.basket_charge_incl_tax())

    def test_single_item_basket(self):
        p = create_product()
        self.basket.add_product(p)
        self.assertEquals(D("5.00") + D("1.00"), self.method.basket_charge_incl_tax())

    def test_multi_item_basket(self):
        p = create_product()
        self.basket.add_product(p, 7)
        self.assertEquals(D("5.00") + 7 * D("1.00"), self.method.basket_charge_incl_tax())
开发者ID:mgmtech,项目名称:django-oscar,代码行数:20,代码来源:shipping_tests.py

示例5: OrderAndItemChargesTests

# 需要导入模块: from oscar.apps.shipping.models import OrderAndItemCharges [as 别名]
# 或者: from oscar.apps.shipping.models.OrderAndItemCharges import set_basket [as 别名]
class OrderAndItemChargesTests(TestCase):

    def setUp(self):
        self.method = OrderAndItemCharges(price_per_order=D('5.00'), price_per_item=D('1.00'))
        self.basket = factories.create_basket(empty=True)
        self.method.set_basket(self.basket)

    def test_order_level_charge_for_empty_basket(self):
        self.assertEquals(D('5.00'), self.method.charge_incl_tax)

    def test_single_item_basket(self):
        record = factories.create_stockrecord()
        self.basket.add_product(record.product)
        self.assertEquals(D('5.00') + D('1.00'),
                          self.method.charge_incl_tax)

    def test_multi_item_basket(self):
        record = factories.create_stockrecord()
        self.basket.add_product(record.product, 7)
        self.assertEquals(D('5.00') + 7*D('1.00'), self.method.charge_incl_tax)
开发者ID:ButchershopCreative,项目名称:django-oscar,代码行数:22,代码来源:model_method_tests.py

示例6: NonZeroFreeThresholdTest

# 需要导入模块: from oscar.apps.shipping.models import OrderAndItemCharges [as 别名]
# 或者: from oscar.apps.shipping.models.OrderAndItemCharges import set_basket [as 别名]
class NonZeroFreeThresholdTest(TestCase):
    
    def setUp(self):
        self.method = OrderAndItemCharges(price_per_order=D('10.00'), free_shipping_threshold=D('20.00'))
        self.basket = Basket.objects.create()
        self.method.set_basket(self.basket)
        
    def test_basket_below_threshold(self):
        p = create_product(D('5.00'))
        self.basket.add_product(p)
        self.assertEquals(D('10.00'), self.method.basket_charge_incl_tax())
        
    def test_basket_on_threshold(self):
        p = create_product(D('5.00'))
        self.basket.add_product(p, 4)
        self.assertEquals(D('0.00'), self.method.basket_charge_incl_tax())
        
    def test_basket_above_threshold(self):
        p = create_product(D('5.00'))
        self.basket.add_product(p, 8)
        self.assertEquals(D('0.00'), self.method.basket_charge_incl_tax())
开发者ID:bakanov,项目名称:django-oscar,代码行数:23,代码来源:shipping_tests.py

示例7: NonZeroFreeThresholdTest

# 需要导入模块: from oscar.apps.shipping.models import OrderAndItemCharges [as 别名]
# 或者: from oscar.apps.shipping.models.OrderAndItemCharges import set_basket [as 别名]
class NonZeroFreeThresholdTest(TestCase):

    def setUp(self):
        self.method = OrderAndItemCharges(
            price_per_order=D('10.00'), free_shipping_threshold=D('20.00'))
        self.basket = factories.create_basket(empty=True)
        self.method.set_basket(self.basket)

    def test_basket_below_threshold(self):
        record = factories.create_stockrecord(price_excl_tax=D('5.00'))
        self.basket.add_product(record.product)
        self.assertEquals(D('10.00'), self.method.charge_incl_tax)

    def test_basket_on_threshold(self):
        record = factories.create_stockrecord(price_excl_tax=D('5.00'))
        self.basket.add_product(record.product, quantity=4)
        self.assertEquals(D('0.00'), self.method.charge_incl_tax)

    def test_basket_above_threshold(self):
        record = factories.create_stockrecord(price_excl_tax=D('5.00'))
        self.basket.add_product(record.product, quantity=8)
        self.assertEquals(D('0.00'), self.method.charge_incl_tax)
开发者ID:FRKodes,项目名称:django-oscar,代码行数:24,代码来源:model_method_tests.py


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