From 28dc417a9f2ffccefa51aa3e6975be7102b3cf4e Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 24 Nov 2021 10:52:20 +1100 Subject: [PATCH] Add unit testing for 'validated' filter --- InvenTree/part/test_api.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/InvenTree/part/test_api.py b/InvenTree/part/test_api.py index 99f531306f..9704734234 100644 --- a/InvenTree/part/test_api.py +++ b/InvenTree/part/test_api.py @@ -934,6 +934,38 @@ class BomItemTest(InvenTreeAPITestCase): expected_code=200, ) + # Should be zero validated results + self.assertEqual(len(response.data), 0) + + # Now filter by "not validated" + response = self.get( + url, + data={ + 'validated': False, + }, + expected_code=200 + ) + + # There should be at least one non-validated item + self.assertTrue(len(response.data) > 0) + + # Now, let's validate an item + bom_item = BomItem.objects.first() + + bom_item.validate_hash() + + response = self.get( + url, + data={ + 'validated': True, + }, + expected_code=200 + ) + + # Check that the expected response is returned + self.assertEqual(len(response.data), 1) + self.assertEqual(response.data[0]['pk'], bom_item.pk) + def test_get_bom_detail(self): """ Get the detail view for a single BomItem object