From ecc7bd2d5b1a1a604351b24b075475e1dc87b08c Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@gmail.com>
Date: Tue, 7 Sep 2021 22:27:39 +1000
Subject: [PATCH] Unit test fixes

---
 InvenTree/build/test_build.py | 8 +++++++-
 InvenTree/stock/tests.py      | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/InvenTree/build/test_build.py b/InvenTree/build/test_build.py
index b572feb14b..30fe8c488b 100644
--- a/InvenTree/build/test_build.py
+++ b/InvenTree/build/test_build.py
@@ -8,8 +8,9 @@ from django.db.utils import IntegrityError
 from InvenTree import status_codes as status
 
 from build.models import Build, BuildItem, get_next_build_number
-from stock.models import StockItem
 from part.models import Part, BomItem
+from stock.models import StockItem
+from stock.tasks import delete_old_stock_items
 
 
 class BuildTest(TestCase):
@@ -352,6 +353,11 @@ class BuildTest(TestCase):
         # the original BuildItem objects should have been deleted!
         self.assertEqual(BuildItem.objects.count(), 0)
 
+        self.assertEqual(StockItem.objects.count(), 8)
+
+        # Clean up old stock items
+        delete_old_stock_items()
+
         # New stock items should have been created!
         self.assertEqual(StockItem.objects.count(), 7)
 
diff --git a/InvenTree/stock/tests.py b/InvenTree/stock/tests.py
index 52f934544f..cb1bd406bb 100644
--- a/InvenTree/stock/tests.py
+++ b/InvenTree/stock/tests.py
@@ -332,7 +332,7 @@ class StockTest(TestCase):
         w1 = StockItem.objects.get(pk=100)
         w2 = StockItem.objects.get(pk=101)
 
-        self.assertFalse(w2.scheduled_for_depletion)
+        self.assertFalse(w2.scheduled_for_deletion)
 
         # Take 25 units from w1 (there are only 10 in stock)
         w1.take_stock(30, None, notes='Took 30')
@@ -346,7 +346,7 @@ class StockTest(TestCase):
 
         # w2 should now be marked for future deletion
         w2 = StockItem.objects.get(pk=101)
-        self.assertTrue(w2.scheduled_for_depletion)
+        self.assertTrue(w2.scheduled_for_deletion)
 
         from stock.tasks import delete_old_stock_items