mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 20:45:44 +00:00
Further unit test fixes
This commit is contained in:
@ -910,6 +910,12 @@ class PartAPIAggregationTest(InvenTreeAPITestCase):
|
||||
self.assertEqual(in_stock, 126)
|
||||
self.assertEqual(data['unallocated_stock'], in_stock)
|
||||
|
||||
# Check that model functions return the same values
|
||||
self.assertEqual(part.build_order_allocation_count(), 0)
|
||||
self.assertEqual(part.sales_order_allocation_count(), 0)
|
||||
self.assertEqual(part.total_stock, in_stock)
|
||||
self.assertEqual(part.available_stock(), in_stock)
|
||||
|
||||
# Now, let's create a sales order, and allocate some stock
|
||||
so = order.models.SalesOrder.objects.create(
|
||||
reference='001',
|
||||
@ -1000,6 +1006,12 @@ class PartAPIAggregationTest(InvenTreeAPITestCase):
|
||||
self.assertEqual(data['in_stock'], 91)
|
||||
self.assertEqual(data['unallocated_stock'], 66)
|
||||
|
||||
# Again, check that the direct model functions return the same values
|
||||
self.assertEqual(part.build_order_allocation_count(), 10)
|
||||
self.assertEqual(part.sales_order_allocation_count(), 15)
|
||||
self.assertEqual(part.total_stock, 91)
|
||||
self.assertEqual(part.available_stock(), 66)
|
||||
|
||||
# Allocate further stock against the build
|
||||
build.models.BuildItem.objects.create(
|
||||
build=bo,
|
||||
@ -1016,6 +1028,12 @@ class PartAPIAggregationTest(InvenTreeAPITestCase):
|
||||
self.assertEqual(data['in_stock'], 91)
|
||||
self.assertEqual(data['unallocated_stock'], 56)
|
||||
|
||||
# Again, check that the direct model functions return the same values
|
||||
self.assertEqual(part.build_order_allocation_count(), 20)
|
||||
self.assertEqual(part.sales_order_allocation_count(), 15)
|
||||
self.assertEqual(part.total_stock, 91)
|
||||
self.assertEqual(part.available_stock(), 56)
|
||||
|
||||
|
||||
class BomItemTest(InvenTreeAPITestCase):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user