Add some unit tests for the new functions

This commit is contained in:
Oliver Walters 2020-09-28 22:00:17 +10:00
parent df8d1fb32b
commit a18886f196

View File

@ -335,6 +335,35 @@ class StockTest(TestCase):
# Serialize the remainder of the stock # Serialize the remainder of the stock
item.serializeStock(2, [99, 100], self.user) 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): class VariantTest(StockTest):
""" """