mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add unit tests for .webp support
This commit is contained in:
parent
495798dc98
commit
55f87033b2
@ -970,24 +970,29 @@ 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
|
||||
img = PIL.Image.new('RGB', (128, 128), color='red')
|
||||
img.save('dummy_image.jpg')
|
||||
# Now try to upload a valid image file, in multiple formats
|
||||
for fmt in ['jpg', 'png', 'bmp', 'webp']:
|
||||
fn = f'dummy_image.{fmt}'
|
||||
|
||||
with open('dummy_image.jpg', 'rb') as dummy_image:
|
||||
response = upload_client.patch(
|
||||
url,
|
||||
{
|
||||
'image': dummy_image,
|
||||
},
|
||||
format='multipart',
|
||||
)
|
||||
img = PIL.Image.new('RGB', (128, 128), color='red')
|
||||
img.save(fn)
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
with open(fn, 'rb') as dummy_image:
|
||||
response = upload_client.patch(
|
||||
url,
|
||||
{
|
||||
'image': dummy_image,
|
||||
},
|
||||
format='multipart',
|
||||
)
|
||||
|
||||
# And now check that the image has been set
|
||||
p = Part.objects.get(pk=pk)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# And now check that the image has been set
|
||||
p = Part.objects.get(pk=pk)
|
||||
self.assertIsNotNone(p.image)
|
||||
|
||||
def test_details(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user