コード例 #1
0
    def test_consume_stock_allocations_track_stock_on(self):
        product_class = factories.ProductClassFactory(
            requires_shipping=False, track_stock=True)
        product = factories.ProductFactory(product_class=product_class)
        basket = factories.create_basket(empty=True)
        add_product(basket, D('10.00'), 5, product=product)
        order = factories.create_order(basket=basket)

        stockrecord = product.stockrecords.get()
        num_in_stock = stockrecord.num_in_stock
        num_allocated = stockrecord.num_allocated

        lines = order.lines.all()
        self.handler.consume_stock_allocations(
            order, lines, [line.quantity for line in lines])

        stockrecord.refresh_from_db()
        self.assertEqual(
            stockrecord.num_allocated,
            num_allocated - 5,
            "Allocated stock should have decreased, but didn't."
        )
        self.assertEqual(
            stockrecord.num_in_stock,
            num_in_stock - 5,
            "Stock should have decreased, but didn't."
        )
コード例 #2
0
ファイル: __init__.py プロジェクト: vituocgia/wshop-core
 def create_digital_product(self):
     product_class = factories.ProductClassFactory(requires_shipping=False,
                                                   track_stock=False)
     product = factories.ProductFactory(product_class=product_class)
     factories.StockRecordFactory(num_in_stock=None,
                                  price_excl_tax=D('12.00'),
                                  product=product)
     return product
コード例 #3
0
 def test_availability_does_not_require_price(self):
     # regression test for https://github.com/vituocgia/wshop-core/issues/2664
     # The availability policy should be independent of price.
     product_class = factories.ProductClassFactory(track_stock=False)
     product = factories.ProductFactory(product_class=product_class,
                                        stockrecords=[])
     factories.StockRecordFactory(price_excl_tax=None, product=product)
     info = self.strategy.fetch_for_product(product)
     self.assertTrue(info.availability.is_available_to_buy)
コード例 #4
0
    def test_are_stock_allocations_available_track_stock_off(self):
        product_class = factories.ProductClassFactory(
            requires_shipping=False, track_stock=False)
        product = factories.ProductFactory(product_class=product_class)
        basket = factories.create_basket(empty=True)
        add_product(basket, D('10.00'), 5, product=product)
        order = factories.create_order(basket=basket)

        line = order.lines.get()
        self.assertEqual(
            self.handler.are_stock_allocations_available(
                [line], [105]),
            True,
        )
コード例 #5
0
    def test_cancel_stock_allocations_without_line_arguments(self):
        product_class = factories.ProductClassFactory(
            requires_shipping=False, track_stock=True)
        product = factories.ProductFactory(product_class=product_class)
        basket = factories.create_basket(empty=True)
        add_product(basket, D('10.00'), 5, product=product)
        order = factories.create_order(basket=basket)

        stockrecord = product.stockrecords.get()
        num_allocated = stockrecord.num_allocated

        self.handler.cancel_stock_allocations(order)

        stockrecord.refresh_from_db()
        self.assertEqual(
            stockrecord.num_allocated,
            num_allocated - 5,
            "Allocated stock should have decreased, but didn't."
        )
コード例 #6
0
ファイル: test_options.py プロジェクト: vituocgia/wshop-core
 def setUp(self):
     self.product_class = factories.ProductClassFactory()
     self.product = factories.create_product(
         product_class=self.product_class)
     self.option = factories.OptionFactory()
コード例 #7
0
 def setUp(self):
     self.product_class = factories.ProductClassFactory()
コード例 #8
0
ファイル: test_models.py プロジェクト: vituocgia/wshop-core
 def setUp(self):
     self.product_class = factories.ProductClassFactory(
         requires_shipping=False, track_stock=False)