Fix tests.

This commit is contained in:
Víðir Valberg Guðmundsson 2019-03-27 23:45:08 +01:00
parent f708864d14
commit 863e089c2b

View file

@ -23,14 +23,17 @@ class ProductAvailabilityTest(TestCase):
product = ProductFactory(stock_amount=2) product = ProductFactory(stock_amount=2)
opr1 = OrderProductRelationFactory(product=product) opr1 = OrderProductRelationFactory(product=product)
opr1.order.mark_as_paid()
opr2 = OrderProductRelationFactory(product=product) opr2 = OrderProductRelationFactory(product=product)
opr2.order.mark_as_paid()
self.assertEqual(product.left_in_stock, 0) self.assertEqual(product.left_in_stock, 0)
self.assertFalse(product.is_stock_available) self.assertFalse(product.is_stock_available)
self.assertFalse(product.is_available()) self.assertFalse(product.is_available())
# Cancel one order # Cancel one order
opr1.order.mark_as_cancelled() opr1.order.cancelled = True
opr1.order.save()
self.assertEqual(product.left_in_stock, 1) self.assertEqual(product.left_in_stock, 1)
self.assertTrue(product.is_stock_available) self.assertTrue(product.is_stock_available)