Beispiel #1
0
 def test_thumbnail(self):
     # verifica o thumbnail
     obj = self.portal['my-image']
     thumbnail = self.tile.thumbnail(obj)
     self.assertTrue(thumbnail)
     # the thumbnail is an ImageScale
     self.assertTrue(IImageScale.providedBy(thumbnail))
 def test_thumbnail(self):
     # verifica o thumbnail
     obj = self.portal['my-image']
     thumbnail = self.tile.thumbnail(obj)
     self.assertTrue(thumbnail)
     # the thumbnail is an ImageScale
     self.assertTrue(IImageScale.providedBy(thumbnail))
Beispiel #3
0
    def test_thumbnail(self):
        # as a File does not have an image field, we should have no thumbnail
        obj = self.portal['my-file']
        self.assertFalse(self.tile.thumbnail(obj))

        # nitf with Image, we should have a thumbnail
        obj = self.portal['my-news-folder']['my-nitf-with-image']
        [image_child] = [
            i for i in api.content.find(
                context=obj, depth=1, portal_type='Image')
        ]
        thumbnail = self.tile.thumbnail(image_child.getObject())
        self.assertTrue(thumbnail)
        # the thumbnail is an ImageScale
        self.assertTrue(IImageScale.providedBy(thumbnail))

        # nitf without Image, we shouldn't have a thumbnail
        obj = self.portal['my-news-folder']['my-nitf-without-image']
        [image_child] = [
            i for i in api.content.find(
                context=obj, depth=1, portal_type='Image')
        ] or [None]
        thumbnail = self.tile.thumbnail(image_child)
        self.assertFalse(thumbnail)
        # the thumbnail is an ImageScale
        self.assertFalse(IImageScale.providedBy(thumbnail))

        # as an Image does have an image field, we should have a thumbnail
        obj = self.portal['my-image']
        thumbnail = self.tile.thumbnail(obj)
        self.assertTrue(thumbnail)
        # the thumbnail is an ImageScale
        self.assertTrue(IImageScale.providedBy(thumbnail))

        # turn visibility off, we should have no thumbnail
        # XXX: refactor; we need a method to easily change field visibility
        tile_conf = self.tile.get_tile_configuration()
        tile_conf['image']['visibility'] = u'off'
        self.tile.set_tile_configuration(tile_conf)

        self.assertFalse(self.tile._field_is_visible('image'))
        self.assertTrue(self.tile.thumbnail(obj))
Beispiel #4
0
    def test_renderer_thumbnail(self):
        r1 = self._assigned_renderer(self.files)
        r2 = self._assigned_renderer(self.images)

        images = [r1.thumbnail(o) for o in r1.results()]
        self.assertEqual(images, [None, None, None])

        images = [r2.thumbnail(o) for o in r2.results()]
        for img in images:
            self.assertTrue(img)
            self.assertTrue(IImageScale.providedBy(img))
    def test_thumbnail(self):
        # as a File does not have an image field, we should have no thumbnail
        obj = self.portal['my-file']
        self.assertFalse(self.tile.thumbnail(obj))

        # nitf with Image, we should have a thumbnail
        obj = self.portal['my-news-folder']['my-nitf-with-image']
        [image_child] = [i for i in api.content.find(context=obj,
                         depth=1, portal_type='Image')]
        thumbnail = self.tile.thumbnail(image_child.getObject())
        self.assertTrue(thumbnail)
        # the thumbnail is an ImageScale
        self.assertTrue(IImageScale.providedBy(thumbnail))

        # nitf without Image, we shouldn't have a thumbnail
        obj = self.portal['my-news-folder']['my-nitf-without-image']
        [image_child] = [i for i in api.content.find(context=obj,
                         depth=1, portal_type='Image')] or [None]
        thumbnail = self.tile.thumbnail(image_child)
        self.assertFalse(thumbnail)
        # the thumbnail is an ImageScale
        self.assertFalse(IImageScale.providedBy(thumbnail))

        # as an Image does have an image field, we should have a thumbnail
        obj = self.portal['my-image']
        thumbnail = self.tile.thumbnail(obj)
        self.assertTrue(thumbnail)
        # the thumbnail is an ImageScale
        self.assertTrue(IImageScale.providedBy(thumbnail))

        # turn visibility off, we should have no thumbnail
        # XXX: refactor; we need a method to easily change field visibility
        tile_conf = self.tile.get_tile_configuration()
        tile_conf['image']['visibility'] = u'off'
        self.tile.set_tile_configuration(tile_conf)

        self.assertFalse(self.tile._field_is_visible('image'))
        self.assertTrue(self.tile.thumbnail(obj))
 def resolve_image(self, src):
     (image, fullimage, source, description) = resolveuid_and_caption.\
         ResolveUIDAndCaptionFilter.resolve_image(self, src)
     if not IImageScale.providedBy(image):
         url = ''
         obj, subpath, appendix = self.resolve_link(src)
         if image:
             url = image.absolute_url()
         if isinstance(url, unicode):
             url = url.encode('utf8')
         src = '/'.join([url, subpath, appendix])
     else:
         src = image.absolute_url()
     return image, fullimage, src, description
Beispiel #7
0
    def test_thumbnail(self):
        # as a File does not have an image field, we should have no thumbnail
        obj = self.portal['my-file']
        self.assertFalse(self.tile.thumbnail(obj))

        # as an Image does have an image field, we should have a thumbnail
        obj = self.portal['my-image']
        thumbnail = self.tile.thumbnail(obj)
        self.assertTrue(thumbnail)
        # the thumbnail is an ImageScale
        self.assertTrue(IImageScale.providedBy(thumbnail))
        tile_conf = self.tile.get_tile_configuration()
        tile_conf['image']['visibility'] = u'on'
        self.tile.set_tile_configuration(tile_conf)
        self.assertTrue(self.tile._field_is_visible('image'))
        self.assertTrue(self.tile.thumbnail(obj))
Beispiel #8
0
    def test_thumbnail(self):
        # as a File does not have an image field, we should have no thumbnail
        obj = self.portal['my-file']
        self.assertFalse(self.tile.thumbnail(obj))

        # as an Image does have an image field, we should have a thumbnail
        obj = self.portal['my-image']
        thumbnail = self.tile.thumbnail(obj)
        self.assertTrue(thumbnail)

        # FIXME: https://github.com/plone/plone.app.contenttypes/issues/315
        from collective.cover.testing import DEXTERITY_ONLY
        from plone.app.imaging.interfaces import IImageScale
        if not DEXTERITY_ONLY:
            # the thumbnail is an ImageScale
            self.assertTrue(IImageScale.providedBy(thumbnail))
    def test_thumbnail(self):
        # as a File does not have an image field, we should have no thumbnail
        obj = self.portal["my-file"]
        self.assertFalse(self.tile.thumbnail(obj))

        # as an Image does have an image field, we should have a thumbnail
        obj = self.portal["my-image"]
        thumbnail = self.tile.thumbnail(obj)
        self.assertTrue(thumbnail)
        # the thumbnail is an ImageScale
        self.assertTrue(IImageScale.providedBy(thumbnail))
        tile_conf = self.tile.get_tile_configuration()
        tile_conf["image"]["visibility"] = u"on"
        self.tile.set_tile_configuration(tile_conf)
        self.assertTrue(self.tile._field_is_visible("image"))
        self.assertTrue(self.tile.thumbnail(obj))
    def test_thumbnail(self):
        # as a File does not have an image field, we should have no thumbnail
        obj = self.portal['my-file']
        self.assertFalse(self.tile.thumbnail(obj))

        # as an Image does have an image field, we should have a thumbnail
        obj = self.portal['my-image']
        thumbnail = self.tile.thumbnail(obj)
        self.assertTrue(thumbnail)
        # the thumbnail is an ImageScale
        self.assertTrue(IImageScale.providedBy(thumbnail))

        # turn visibility off, we should have no thumbnail
        # XXX: refactor; we need a method to easily change field visibility
        tile_conf = self.tile.get_tile_configuration()
        tile_conf['image']['visibility'] = u'off'
        self.tile.set_tile_configuration(tile_conf)

        self.assertFalse(self.tile._field_is_visible('image'))
        self.assertFalse(self.tile.thumbnail(obj))