mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 15:15:42 +00:00 
			
		
		
		
	Scheduling api fix (#5093)
* Fix query for part scheduling API * Add unit test for scheduling endpoint * Remove length check
This commit is contained in:
		@@ -597,8 +597,8 @@ class PartScheduling(RetrieveAPI):
 | 
			
		||||
 | 
			
		||||
                # Grab all allocations against the specified BomItem
 | 
			
		||||
                allocations = BuildItem.objects.filter(
 | 
			
		||||
                    bom_item=bom_item,
 | 
			
		||||
                    build=build,
 | 
			
		||||
                    build_line__bom_item=bom_item,
 | 
			
		||||
                    build_line__build=build,
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
                # Total allocated for *this* part
 | 
			
		||||
 
 | 
			
		||||
@@ -536,6 +536,7 @@ class PartAPITestBase(InvenTreeAPITestCase):
 | 
			
		||||
        'part',
 | 
			
		||||
        'location',
 | 
			
		||||
        'bom',
 | 
			
		||||
        'build',
 | 
			
		||||
        'company',
 | 
			
		||||
        'test_templates',
 | 
			
		||||
        'manufacturer_part',
 | 
			
		||||
@@ -3056,3 +3057,22 @@ class PartMetadataAPITest(InvenTreeAPITestCase):
 | 
			
		||||
            'api-bom-item-metadata': BomItem,
 | 
			
		||||
        }.items():
 | 
			
		||||
            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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user