Commit 104db7f1 authored by Jérome Perrin's avatar Jérome Perrin

minimal test for Image.convert


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20804 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1d9a4fca
......@@ -27,12 +27,14 @@
##############################################################################
import os
import unittest
from DateTime import DateTime
from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import FileUpload
from AccessControl.SecurityManagement import newSecurityManager
......@@ -83,6 +85,11 @@ class TestERP5Base(ERP5TypeTestCase):
## Usefull methods
##################################
def makeImageFileUpload(self, filename):
return FileUpload(
os.path.join(os.path.dirname(__file__),
'test_data', 'images', filename), 'rb')
def login(self):
"""Create a new manager user and login.
"""
......@@ -958,6 +965,15 @@ class TestERP5Base(ERP5TypeTestCase):
self.assertEquals([], image.checkConsistency())
image.view() # viewing the image does not cause error
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_Person_getCareerStartDate(self):
# Person_getCareerStartDate scripts returns the date when an employee
# started to work for an employer
......
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