mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 15:15:42 +00:00 
			
		
		
		
	Add unit tests for .webp support
This commit is contained in:
		@@ -970,12 +970,16 @@ class PartDetailTests(InvenTreeAPITestCase):
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            self.assertEqual(response.status_code, 400)
 | 
			
		||||
            self.assertIn('Upload a valid image', str(response.data))
 | 
			
		||||
 | 
			
		||||
        # Now try to upload a valid image file, in multiple formats
 | 
			
		||||
        for fmt in ['jpg', 'png', 'bmp', 'webp']:
 | 
			
		||||
            fn = f'dummy_image.{fmt}'
 | 
			
		||||
 | 
			
		||||
        # Now try to upload a valid image file
 | 
			
		||||
            img = PIL.Image.new('RGB', (128, 128), color='red')
 | 
			
		||||
        img.save('dummy_image.jpg')
 | 
			
		||||
            img.save(fn)
 | 
			
		||||
 | 
			
		||||
        with open('dummy_image.jpg', 'rb') as dummy_image:
 | 
			
		||||
            with open(fn, 'rb') as dummy_image:
 | 
			
		||||
                response = upload_client.patch(
 | 
			
		||||
                    url,
 | 
			
		||||
                    {
 | 
			
		||||
@@ -988,6 +992,7 @@ class PartDetailTests(InvenTreeAPITestCase):
 | 
			
		||||
 | 
			
		||||
            # And now check that the image has been set
 | 
			
		||||
            p = Part.objects.get(pk=pk)
 | 
			
		||||
            self.assertIsNotNone(p.image)
 | 
			
		||||
 | 
			
		||||
    def test_details(self):
 | 
			
		||||
        """
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user