Commit d8649a5c authored by Jérome Perrin's avatar Jérome Perrin

more tests for image conversion:

  when image is stored as pdata
  when quality argument is passed


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22940 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6b4a88e4
...@@ -1202,6 +1202,28 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -1202,6 +1202,28 @@ class TestERP5Base(ERP5TypeTestCase):
self.assertEquals('\xff', image_data[0]) self.assertEquals('\xff', image_data[0])
self.assertEquals('\xd8', image_data[1]) 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])
def test_ConvertImagePdata(self):
image = self.portal.newContent(portal_type='Image', id='test_image')
image.edit(file=self.makeImageFileUpload('erp5_logo.bmp'))
from OFS.Image import Pdata
self.assertTrue(isinstance(image.data, Pdata))
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_ImageSize(self): def test_ImageSize(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'))
......
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