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


Python Basket.merge方法代码示例

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


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

示例1: BasketMergingTests

# 需要导入模块: from oscar.apps.basket.models import Basket [as 别名]
# 或者: from oscar.apps.basket.models.Basket import merge [as 别名]
class BasketMergingTests(TestCase):

    def setUp(self):
        self.product = create_product()
        self.user_basket = Basket()
        self.user_basket.add_product(self.product)
        self.cookie_basket = Basket()
        self.cookie_basket.add_product(self.product, 2)
        self.user_basket.merge(self.cookie_basket, add_quantities=False)

    def test_cookie_basket_has_status_set(self):
        self.assertEqual('Merged', self.cookie_basket.status)

    def test_lines_are_moved_across(self):
        self.assertEqual(1, self.user_basket.lines.all().count())

    def test_merge_line_takes_max_quantity(self):
        line = self.user_basket.lines.get(product=self.product)
        self.assertEqual(2, line.quantity)
开发者ID:ArtS,项目名称:django-oscar,代码行数:21,代码来源:basket_tests.py

示例2: TestBasketMerging

# 需要导入模块: from oscar.apps.basket.models import Basket [as 别名]
# 或者: from oscar.apps.basket.models.Basket import merge [as 别名]
class TestBasketMerging(TestCase):

    def setUp(self):
        self.product = create_product(num_in_stock=10)
        self.user_basket = Basket()
        self.user_basket.strategy = strategy.Default()
        add_product(self.user_basket, product=self.product)
        self.cookie_basket = Basket()
        self.cookie_basket.strategy = strategy.Default()
        add_product(self.cookie_basket, quantity=2, product=self.product)
        self.user_basket.merge(self.cookie_basket, add_quantities=False)

    def test_cookie_basket_has_status_set(self):
        self.assertEqual(Basket.MERGED, self.cookie_basket.status)

    def test_lines_are_moved_across(self):
        self.assertEqual(1, self.user_basket.lines.all().count())

    def test_merge_line_takes_max_quantity(self):
        line = self.user_basket.lines.get(product=self.product)
        self.assertEqual(2, line.quantity)
开发者ID:marangonico,项目名称:django-oscar,代码行数:23,代码来源:test_basket.py

示例3: TestMergingTwoBaskets

# 需要导入模块: from oscar.apps.basket.models import Basket [as 别名]
# 或者: from oscar.apps.basket.models.Basket import merge [as 别名]
class TestMergingTwoBaskets(TestCase):
    def setUp(self):
        self.product = factories.create_product()
        self.record = factories.create_stockrecord(self.product, price_excl_tax=D("10.00"))
        self.purchase_info = factories.create_purchase_info(self.record)

        self.main_basket = Basket()
        self.main_basket.strategy = strategy.Default()
        self.main_basket.add(self.product, quantity=2)

        self.merge_basket = Basket()
        self.merge_basket.strategy = strategy.Default()
        self.merge_basket.add(self.product, quantity=1)

        self.main_basket.merge(self.merge_basket)

    def test_doesnt_sum_quantities(self):
        self.assertEquals(1, self.main_basket.num_lines)

    def test_changes_status_of_merge_basket(self):
        self.assertEquals(Basket.MERGED, self.merge_basket.status)
开发者ID:jduarte,项目名称:django-oscar,代码行数:23,代码来源:model_tests.py


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