Ejemplo n.º 1
0
 def testCreateScaleWithoutData(self):
     folder = self.folder
     image = folder[folder.invokeFactory('Image', id='image')]
     field = image.getField('image')
     handler = BlobImageScaleHandler(field)
     foo = handler.createScale(image, 'foo', 100, 80)
     self.assertEqual(foo, None)
Ejemplo n.º 2
0
 def testCreateScaleWithoutData(self):
     folder = self.folder
     image = folder[folder.invokeFactory('Image', id='image')]
     field = image.getField('image')
     handler = BlobImageScaleHandler(field)
     foo = handler.createScale(image, 'foo', 100, 80)
     self.assertEqual(foo, None)
Ejemplo n.º 3
0
 def afterSetUp(self):
     data = getData('image.gif')
     folder = self.folder
     self.image = folder[folder.invokeFactory('Image', id='foo', image=data)]
     self.field = self.image.getField('image')
     self.handler = BlobImageScaleHandler(self.field)
     iprops = self.portal.portal_properties.imaging_properties
     iprops.manage_changeProperties(allowed_sizes=['foo 60:60'])
Ejemplo n.º 4
0
class BlobAdapterTests(ReplacementTestCase):

    def afterSetUp(self):
        data = getData('image.gif')
        folder = self.folder
        self.image = folder[folder.invokeFactory('Image', id='foo', image=data)]
        self.field = self.image.getField('image')
        self.handler = BlobImageScaleHandler(self.field)
        iprops = self.portal.portal_properties.imaging_properties
        iprops.manage_changeProperties(allowed_sizes=['foo 60:60'])

    def testCreateScale(self):
        foo = self.handler.createScale(self.image, 'foo', 100, 80)
        self.assertEqual(foo['id'], 'image_foo')
        self.assertEqual(foo['content_type'], 'image/png')
        self.assertEqual(foo['data'][:4], '\x89PNG')

    def testCreateScaleWithZeroWidth(self):
        foo = self.handler.createScale(self.image, 'foo', 100, 0)
        self.assertEqual(foo, None)

    def testCreateScaleWithoutData(self):
        folder = self.folder
        image = folder[folder.invokeFactory('Image', id='image')]
        field = image.getField('image')
        handler = BlobImageScaleHandler(field)
        foo = handler.createScale(image, 'foo', 100, 80)
        self.assertEqual(foo, None)

    def testGetScale(self):
        foo = self.handler.getScale(self.image, 'foo')
        self.assertEqual(foo.getId(), 'image_foo')
        self.assertEqual(foo.getContentType(), 'image/png')
        self.assertEqual(foo.data[:4], '\x89PNG')
        self.assertEqual(foo.width, 60)
        self.assertEqual(foo.height, 60)

    def testGetUnknownScale(self):
        foo = self.handler.getScale(self.image, 'foo?')
        self.assertEqual(foo, None)
Ejemplo n.º 5
0
class BlobAdapterTests(ReplacementTestCase):

    def afterSetUp(self):
        self.image = self.folder['foo-image']
        self.field = self.image.getField('image')
        self.handler = BlobImageScaleHandler(self.field)
        changeAllowedSizes(self.portal, [u'foo 60:60'])

    def testCreateScale(self):
        foo = self.handler.createScale(self.image, 'foo', 100, 80)
        self.assertEqual(foo['id'], 'image_foo')
        self.assertEqual(foo['content_type'], 'image/gif')
        self.assertEqual(foo['data'][:6], 'GIF87a')

    def testCreateScaleWithZeroWidth(self):
        foo = self.handler.createScale(self.image, 'foo', 100, 0)
        self.assertEqual(foo, None)

    def testCreateScaleWithoutData(self):
        folder = self.folder
        image = folder[folder.invokeFactory('Image', id='image')]
        field = image.getField('image')
        handler = BlobImageScaleHandler(field)
        foo = handler.createScale(image, 'foo', 100, 80)
        self.assertEqual(foo, None)

    def testGetScale(self):
        foo = self.handler.getScale(self.image, 'foo')
        self.assertEqual(foo.getId(), 'image_foo')
        self.assertEqual(foo.getContentType(), 'image/gif')
        self.assertEqual(foo.data[:6], 'GIF87a')
        self.assertEqual(foo.width, 60)
        self.assertEqual(foo.height, 60)

    def testGetUnknownScale(self):
        foo = self.handler.getScale(self.image, 'foo?')
        self.assertEqual(foo, None)
Ejemplo n.º 6
0
 def afterSetUp(self):
     self.image = self.folder['foo-image']
     self.field = self.image.getField('image')
     self.handler = BlobImageScaleHandler(self.field)
     changeAllowedSizes(self.portal, [u'foo 60:60'])
Ejemplo n.º 7
0
 def afterSetUp(self):
     self.image = self.folder['foo-image']
     self.field = self.image.getField('image')
     self.handler = BlobImageScaleHandler(self.field)
     changeAllowedSizes(self.portal, [u'foo 60:60'])