예제 #1
0
 def testPublishCustomSize(self):
     # set custom image sizes
     changeAllowedSizes(self.portal, [u'foo 23:23'])
     # make sure traversing works as expected
     base = '/'.join(self.folder.getPhysicalPath())
     credentials = self.getCredentials()
     response = self.publish(base + '/foo-image/image_foo', basic=credentials)
     self.assertEqual(response.getStatus(), 200)
     foo = open(StringIO(response.getBody()))
     self.assertEqual(foo.format, 'GIF')
     self.assertEqual(foo.size, (23, 23))
     # make sure the traversal adapter was call in fact
     self.assertEqual(self.counter, 3)
예제 #2
0
 def testPublishCustomSize(self):
     # set custom image sizes
     changeAllowedSizes(self.portal, [u'foo 23:23'])
     # make sure traversing works as expected
     base = '/'.join(self.folder.getPhysicalPath())
     credentials = self.getCredentials()
     response = self.publish(base + '/foo-image/image_foo',
                             basic=credentials)
     self.assertEqual(response.getStatus(), 200)
     foo = open(StringIO(response.getBody()))
     self.assertEqual(foo.format, 'GIF')
     self.assertEqual(foo.size, (23, 23))
     # make sure the traversal adapter was call in fact
     self.assertEqual(self.counter, 3)
예제 #3
0
 def testCustomSizeChange(self):
     image = self.folder['foo-image']
     # set custom image sizes & view a scale
     changeAllowedSizes(self.portal, [u'foo 23:23'])
     traverse = self.layer['request'].traverseName
     foo = traverse(image, 'image_foo')
     self.assertEqual(foo.width, 23)
     self.assertEqual(foo.height, 23)
     # now let's update the scale dimensions, after which the scale
     # should still be the same...
     changeAllowedSizes(self.portal, [u'foo 42:42'])
     foo = traverse(image, 'image_foo')
     self.assertEqual(foo.width, 23)
     self.assertEqual(foo.height, 23)
     # we first need to trigger recreation of all scales...
     self.portal.portal_atct.recreateImageScales()
     foo = traverse(image, 'image_foo')
     self.assertEqual(foo.width, 42)
     self.assertEqual(foo.height, 42)
예제 #4
0
 def testCustomSizeChange(self):
     image = self.folder['foo-image']
     # set custom image sizes & view a scale
     changeAllowedSizes(self.portal, [u'foo 23:23'])
     traverse = self.layer['request'].traverseName
     foo = traverse(image, 'image_foo')
     self.assertEqual(foo.width, 23)
     self.assertEqual(foo.height, 23)
     # now let's update the scale dimensions, after which the scale
     # should still be the same...
     changeAllowedSizes(self.portal, [u'foo 42:42'])
     foo = traverse(image, 'image_foo')
     self.assertEqual(foo.width, 23)
     self.assertEqual(foo.height, 23)
     # we first need to trigger recreation of all scales...
     self.portal.portal_atct.recreateImageScales()
     foo = traverse(image, 'image_foo')
     self.assertEqual(foo.width, 42)
     self.assertEqual(foo.height, 42)
예제 #5
0
 def testCustomSizes(self):
     image = self.folder['foo-image']
     # set custom image sizes
     changeAllowedSizes(self.portal, [u'foo 23:23', u'bar 6:8'])
     # make sure traversing works with the new sizes
     traverse = self.layer['request'].traverseName
     foo = traverse(image, 'image_foo')
     self.assertEqual(foo.getContentType(), 'image/gif')
     self.assertEqual(foo.data[:6], 'GIF87a')
     self.assertEqual(foo.width, 23)
     self.assertEqual(foo.height, 23)
     # also check the generated tag
     url = image.absolute_url() + '/image_foo'
     tag = '<img src="%s" alt="an image" title="an image" height="23" width="23" />'
     self.assertEqual(foo.tag(), tag % url)
     # and the other specified size
     bar = traverse(image, 'image_bar')
     self.assertEqual(bar.getContentType(), 'image/gif')
     self.assertEqual(bar.data[:6], 'GIF87a')
     self.assertEqual(bar.width, 6)
     self.assertEqual(bar.height, 6)
     # make sure the traversal adapter was call in fact
     self.assertEqual(self.counter, 2)
예제 #6
0
 def testCustomSizes(self):
     image = self.folder['foo-image']
     # set custom image sizes
     changeAllowedSizes(self.portal, [u'foo 23:23', u'bar 6:8'])
     # make sure traversing works with the new sizes
     traverse = self.layer['request'].traverseName
     foo = traverse(image, 'image_foo')
     self.assertEqual(foo.getContentType(), 'image/gif')
     self.assertEqual(foo.data[:6], 'GIF87a')
     self.assertEqual(foo.width, 23)
     self.assertEqual(foo.height, 23)
     # also check the generated tag
     url = image.absolute_url() + '/image_foo'
     tag = '<img src="{0}" alt="an image" title="an image" height="23" width="23" />'  # noqa
     self.assertEqual(foo.tag(), tag.format(url))
     # and the other specified size
     bar = traverse(image, 'image_bar')
     self.assertEqual(bar.getContentType(), 'image/gif')
     self.assertEqual(bar.data[:6], 'GIF87a')
     self.assertEqual(bar.width, 6)
     self.assertEqual(bar.height, 6)
     # make sure the traversal adapter was call in fact
     self.assertEqual(self.counter, 2)
예제 #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'])
예제 #8
0
 def testImageGlobalSizes(self):
     image = self.folder[self.folder.invokeFactory('Image', 'foo')]
     changeAllowedSizes(self.portal, [u'foo 23:23'])
     sizes = image.getField('image').getAvailableSizes(image)
     self.assertEqual(sizes, {'foo': (23, 23)})
예제 #9
0
 def testImageGlobalSizes(self):
     image = self.folder[self.folder.invokeFactory('Image', 'foo')]
     changeAllowedSizes(self.portal, [u'foo 23:23'])
     sizes = image.getField('image').getAvailableSizes(image)
     self.assertEqual(sizes, {'foo': (23, 23)})
예제 #10
0
 def testImageGlobalSizes(self):
     image = self.create()
     changeAllowedSizes(self.portal, [u'foo 23:23'])
     sizes = image.getField('bar').getAvailableSizes(image)
     self.assertEqual(sizes, {'foo': (23, 23)})
예제 #11
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'])
예제 #12
0
 def testImageGlobalSizes(self):
     image = self.create()
     changeAllowedSizes(self.portal, [u'foo 23:23'])
     sizes = image.getField('bar').getAvailableSizes(image)
     self.assertEqual(sizes, {'foo': (23, 23)})