Unit test fixes

This commit is contained in:
Oliver committed 2021-09-07 17:36:53 +10:00
1 parent 918106c225
commit 5ab4be7025
3 files changed
+15 -4

No files matched your search

+12
View File
@@ -332,6 +332,8 @@ class StockTest(TestCase):
w1 = StockItem.objects.get(pk=100)
w2 = StockItem.objects.get(pk=101)
self.assertFalse(w2.scheduled_for_depletion)
# Take 25 units from w1 (there are only 10 in stock)
w1.take_stock(30, None, notes='Took 30')
@@ -342,6 +344,16 @@ class StockTest(TestCase):
# Take 25 units from w2 (will be deleted)
w2.take_stock(30, None, notes='Took 30')
# w2 should now be marked for future deletion
w2 = StockItem.objects.get(pk=101)
self.assertTrue(w2.scheduled_for_depletion)
from stock.tasks import delete_old_stock_items
# Now run the "background task" to delete these stock items
delete_old_stock_items()
# This StockItem should now have been deleted
with self.assertRaises(StockItem.DoesNotExist):
w2 = StockItem.objects.get(pk=101)