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." )
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
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)
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, )
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." )
def setUp(self): self.product_class = factories.ProductClassFactory() self.product = factories.create_product( product_class=self.product_class) self.option = factories.OptionFactory()
def setUp(self): self.product_class = factories.ProductClassFactory()
def setUp(self): self.product_class = factories.ProductClassFactory( requires_shipping=False, track_stock=False)