Scheduling api fix (#5093)

* Fix query for part scheduling API

* Add unit test for scheduling endpoint

* Remove length check
This commit is contained in:
Oliver 2023-06-23 23:55:52 +10:00 committed by GitHub
parent 603aef5da9
commit fab738cd75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -597,8 +597,8 @@ class PartScheduling(RetrieveAPI):
# Grab all allocations against the specified BomItem # Grab all allocations against the specified BomItem
allocations = BuildItem.objects.filter( allocations = BuildItem.objects.filter(
bom_item=bom_item, build_line__bom_item=bom_item,
build=build, build_line__build=build,
) )
# Total allocated for *this* part # Total allocated for *this* part

View File

@ -536,6 +536,7 @@ class PartAPITestBase(InvenTreeAPITestCase):
'part', 'part',
'location', 'location',
'bom', 'bom',
'build',
'company', 'company',
'test_templates', 'test_templates',
'manufacturer_part', 'manufacturer_part',
@ -3056,3 +3057,22 @@ class PartMetadataAPITest(InvenTreeAPITestCase):
'api-bom-item-metadata': BomItem, 'api-bom-item-metadata': BomItem,
}.items(): }.items():
self.metatester(apikey, model) self.metatester(apikey, model)
class PartSchedulingTest(PartAPITestBase):
"""Unit tests for the 'part scheduling' API endpoint"""
def test_get_schedule(self):
"""Test that the scheduling endpoint returns OK"""
part_ids = [
1, 3, 100, 101,
]
for pk in part_ids:
url = reverse('api-part-scheduling', kwargs={'pk': pk})
data = self.get(url, expected_code=200).data
for entry in data:
for k in ['date', 'quantity', 'label']:
self.assertIn(k, entry)