From a18886f1968685a6cfa6c4282c850559436fea34 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 28 Sep 2020 22:00:17 +1000 Subject: [PATCH] Add some unit tests for the new functions --- InvenTree/stock/tests.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/InvenTree/stock/tests.py b/InvenTree/stock/tests.py index 1001ed12ea..b500f1c6e5 100644 --- a/InvenTree/stock/tests.py +++ b/InvenTree/stock/tests.py @@ -335,6 +335,35 @@ class StockTest(TestCase): # Serialize the remainder of the stock item.serializeStock(2, [99, 100], self.user) + def test_installation(self): + """ + Test that the functions to install stock items in other stock items work. + """ + + item_1 = StockItem.objects.get(pk=1) + item_2 = StockItem.objects.get(pk=2) + + self.assertEqual(item_1.belongs_to, None) + self.assertFalse(item_2.hasInstalledItems()) + + n = item_1.tracking_info_count + + # Now, let's install item_1 into item_2 + item_1.installIntoStockItem(item_2, self.user, "Hello world!") + + # Check that it installed properly! + self.assertEqual(item_1.tracking_info_count, n + 1) + self.assertTrue(item_2.hasInstalledItems()) + self.assertEqual(item_1.belongs_to, item_2) + + # Now, let's uninstall it! + item_1.uninstallIntoLocation(item_1.location, self.user, "Wello horld!") + + # Check that it uninstalled + self.assertEqual(item_1.tracking_info_count, n + 2) + self.assertFalse(item_2.hasInstalledItems()) + self.assertEqual(item_1.belongs_to, None) + class VariantTest(StockTest): """