mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 12:35:46 +00:00
Part API Filter Fix (#3271)
* Fix API filter 'in_bom_for' - get_parts_in_bom() returns a list, not a queryset - Thus, we have to enumerate the ID values, rather than filtering by queryset * Add unit test for part API filter
This commit is contained in:
@ -400,6 +400,21 @@ class PartAPITest(InvenTreeAPITestCase):
|
||||
for part in response.data:
|
||||
self.assertEqual(part['category'], 2)
|
||||
|
||||
def test_filter_by_in_bom(self):
|
||||
"""Test that we can filter part list by the 'in_bom_for' parameter"""
|
||||
|
||||
url = reverse('api-part-list')
|
||||
|
||||
response = self.get(
|
||||
url,
|
||||
{
|
||||
'in_bom_for': 100,
|
||||
},
|
||||
expected_code=200,
|
||||
)
|
||||
|
||||
self.assertEqual(len(response.data), 4)
|
||||
|
||||
def test_filter_by_related(self):
|
||||
"""Test that we can filter by the 'related' status"""
|
||||
url = reverse('api-part-list')
|
||||
|
Reference in New Issue
Block a user