本文整理汇总了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)
示例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)
示例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)