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):
def test_ConvertImage(self):
image = self.portal.newContent(portal_type='Image', id='test_image')
image.edit(file=self.makeImageFileUpload('erp5_logo.png'))
image_type, image_data = image.convert('jpg', display='thumbnail')
self.assertEquals('image/jpeg', image_type)
# magic
self.assertEquals('\xff', image_data[0])
self.assertEquals('\xd8', image_data[1])
def test_ConvertImageQuality(self):
image = self.portal.newContent(portal_type='Image', id='test_image')
image.edit(file=self.makeImageFileUpload('erp5_logo.png'))
image_type, image_data = image.convert('jpg', display='thumbnail',
quality=100)
self.assertEquals('image/jpeg', image_type)
# magic
self.assertEquals('\xff', image_data[0])
self.assertEquals('\xd8', image_data[1])
self.assertEqual('image/png', image.getContentType())
self.assertEqual((320, 250), (image.getWidth(), image.getHeight()))
from Products.ERP5Type.Document import newTempImage
def convert(**kw):
image_type, image_data = image.convert('jpg', display='thumbnail', **kw)
self.assertEqual('image/jpeg', image_type)
thumbnail = newTempImage(self.portal, 'thumbnail', data=image_data)
self.assertEqual(image_type, thumbnail.getContentType())
self.assertEqual((128, 100), (thumbnail.getWidth(),
thumbnail.getHeight()))
return thumbnail.getSize()
self.assertTrue(convert() < convert(quality=100))
def test_ConvertImagePdata(self):
image = self.portal.newContent(portal_type='Image', id='test_image')
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