From 80f1d1de9f0425d6f8467e78714f5484376edf51 Mon Sep 17 00:00:00 2001 From: "Asterix\\Oliver" Date: Tue, 17 Jun 2025 21:20:36 +1000 Subject: [PATCH 1/4] Tweak unit tests Ref: https://github.com/inventree/InvenTree/pull/9798 --- test/test_part.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/test_part.py b/test/test_part.py index 8ba0a9fe..5d81cb2b 100644 --- a/test/test_part.py +++ b/test/test_part.py @@ -709,8 +709,6 @@ def test_get_requirements(self): self.assertIn('allocated_build_order_quantity', req) self.assertIn('required_sales_order_quantity', req) self.assertIn('allocated_sales_order_quantity', req) - self.assertIn('allocated', req) - self.assertIn('required', req) class PartBarcodeTest(InvenTreeTestCase): From b39ca905fa2072c4c38230fcfadd8d79d4abffe1 Mon Sep 17 00:00:00 2001 From: "Asterix\\Oliver" Date: Tue, 17 Jun 2025 22:32:31 +1000 Subject: [PATCH 2/4] Account for API version in test --- test/test_part.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/test/test_part.py b/test/test_part.py index 5d81cb2b..a733a0f2 100644 --- a/test/test_part.py +++ b/test/test_part.py @@ -703,13 +703,31 @@ def test_get_requirements(self): # Check for expected content self.assertIsInstance(req, dict) - self.assertIn('available_stock', req) - self.assertIn('on_order', req) - self.assertIn('required_build_order_quantity', req) - self.assertIn('allocated_build_order_quantity', req) - self.assertIn('required_sales_order_quantity', req) - self.assertIn('allocated_sales_order_quantity', req) + if self.api.api_version < 350: # Ref: https://github.com/inventree/InvenTree/pull/9798 + fields = [ + 'on_order', + 'allocated_build_order_quantity', + 'allocated_sales_order_quantity', + 'required_build_order_quantity', + 'required_sales_order_quantity', + ] + else: + fields = [ + 'total_stock', + 'unallocated_stock', + 'can_build', + 'ordering', + 'building', + 'scheduled_to_build', + 'required_for_build_orders', + 'allocated_to_build_orders', + 'required_for_sales_orders', + 'allocated_to_sales_orders', + ] + + for f in fields: + self.assertIn(f, req) class PartBarcodeTest(InvenTreeTestCase): """Tests for Part barcode functionality""" From fd64643b9360196bd485a6bb355a81228caf6480 Mon Sep 17 00:00:00 2001 From: "Asterix\\Oliver" Date: Tue, 17 Jun 2025 22:52:02 +1000 Subject: [PATCH 3/4] Fix comment --- test/test_part.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_part.py b/test/test_part.py index a733a0f2..24cff5f5 100644 --- a/test/test_part.py +++ b/test/test_part.py @@ -704,7 +704,8 @@ def test_get_requirements(self): # Check for expected content self.assertIsInstance(req, dict) - if self.api.api_version < 350: # Ref: https://github.com/inventree/InvenTree/pull/9798 + # Ref: https://github.com/inventree/InvenTree/pull/9798 + if self.api.api_version < 350: fields = [ 'on_order', 'allocated_build_order_quantity', From e0ecff961944c50fe43c72ea80fe3ffd7430a90b Mon Sep 17 00:00:00 2001 From: "Asterix\\Oliver" Date: Tue, 17 Jun 2025 22:54:42 +1000 Subject: [PATCH 4/4] PEP fix --- test/test_part.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_part.py b/test/test_part.py index 24cff5f5..c16e35e2 100644 --- a/test/test_part.py +++ b/test/test_part.py @@ -730,6 +730,7 @@ def test_get_requirements(self): for f in fields: self.assertIn(f, req) + class PartBarcodeTest(InvenTreeTestCase): """Tests for Part barcode functionality"""