def test_get_stock_price_empty_stocks(self): product = ProductFactory() StockFactory(product=product, unit_price=2.0, quantity=0) StockFactory(product=product, unit_price=4.0, quantity=0) StockFactory(product=product, unit_price=3.0, quantity=0) with self.assertNumQueries(1): price = get_stock_price(product, Location.LOCATION_STORAGE) self.assertEqual(price, Money(3.0, "EUR"))
def test_get_stock_price_no_stocks(self): price = get_stock_price(ProductFactory(), Location.LOCATION_STORAGE) self.assertEqual(price, Money(0, "EUR"))
def test_get_stock_price(self): price = get_stock_price(self.product_a, Location.LOCATION_STORAGE) self.assertEqual(price, Money(2.6, "EUR"))