Commit dd8495f3 authored by Julien Muchembled's avatar Julien Muchembled

Test that images are converted to the correct size (cf r29505)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29517 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1f063f0d
...@@ -1253,22 +1253,20 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -1253,22 +1253,20 @@ class TestERP5Base(ERP5TypeTestCase):
def test_ConvertImage(self): def test_ConvertImage(self):
image = self.portal.newContent(portal_type='Image', id='test_image') image = self.portal.newContent(portal_type='Image', id='test_image')
image.edit(file=self.makeImageFileUpload('erp5_logo.png')) image.edit(file=self.makeImageFileUpload('erp5_logo.png'))
image_type, image_data = image.convert('jpg', display='thumbnail') self.assertEqual('image/png', image.getContentType())
self.assertEquals('image/jpeg', image_type) self.assertEqual((320, 250), (image.getWidth(), image.getHeight()))
# magic
self.assertEquals('\xff', image_data[0]) from Products.ERP5Type.Document import newTempImage
self.assertEquals('\xd8', image_data[1]) def convert(**kw):
image_type, image_data = image.convert('jpg', display='thumbnail', **kw)
def test_ConvertImageQuality(self): self.assertEqual('image/jpeg', image_type)
image = self.portal.newContent(portal_type='Image', id='test_image') thumbnail = newTempImage(self.portal, 'thumbnail', data=image_data)
image.edit(file=self.makeImageFileUpload('erp5_logo.png')) self.assertEqual(image_type, thumbnail.getContentType())
image_type, image_data = image.convert('jpg', display='thumbnail', self.assertEqual((128, 100), (thumbnail.getWidth(),
quality=100) thumbnail.getHeight()))
self.assertEquals('image/jpeg', image_type) return thumbnail.getSize()
# magic self.assertTrue(convert() < convert(quality=100))
self.assertEquals('\xff', image_data[0])
self.assertEquals('\xd8', image_data[1])
def test_ConvertImagePdata(self): def test_ConvertImagePdata(self):
image = self.portal.newContent(portal_type='Image', id='test_image') image = self.portal.newContent(portal_type='Image', id='test_image')
image.edit(file=self.makeImageFileUpload('erp5_logo.bmp')) image.edit(file=self.makeImageFileUpload('erp5_logo.bmp'))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment