Skip to content

Commit

Permalink
Merge ef26894 into 0dc3e7c
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Sep 16, 2016
2 parents 0dc3e7c + ef26894 commit 828b113
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/collective/cover/tests/test_collection_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,32 @@ def test_thumbnail(self):
obj = self.portal['my-image']
thumbnail = self.tile.thumbnail(obj)
self.assertTrue(thumbnail)
# the thumbnail is an ImageScale

# FIXME: https://github.com/plone/plone.app.contenttypes/issues/315
# from plone.app.imaging.interfaces import IImageScale
# self.assertTrue(IImageScale.providedBy(thumbnail))
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_not_visible(self):
# 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)
assert not self.tile._field_is_visible('image')
obj = self.portal['my-image']
self.assertIsNone(self.tile.thumbnail(obj))

self.assertFalse(self.tile._field_is_visible('image'))
self.assertFalse(self.tile.thumbnail(obj))
def test_thumbnail_original_image(self):
# use original image instead of a thumbnail
tile_conf = self.tile.get_tile_configuration()
tile_conf['image']['imgsize'] = '_original'
self.tile.set_tile_configuration(tile_conf)
obj = self.portal['my-image']
self.assertTrue(self.tile.thumbnail(obj))
self.assertIsInstance(self.tile(), unicode)

def test_number_of_items(self):
obj = self.portal['mandelbrot-set']
Expand Down
36 changes: 36 additions & 0 deletions src/collective/cover/tests/test_list_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,39 @@ def test_get_alt(self):
self.assertIn('<img ', rendered)
self.assertIn(
'alt="This image was created for testing purposes"', rendered)

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_not_visible(self):
# 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)
assert not self.tile._field_is_visible('image')
obj = self.portal['my-image']
self.assertIsNone(self.tile.thumbnail(obj))

def test_thumbnail_original_image(self):
# use original image instead of a thumbnail
tile_conf = self.tile.get_tile_configuration()
tile_conf['image']['imgsize'] = '_original'
self.tile.set_tile_configuration(tile_conf)
obj = self.portal['my-image']
self.assertTrue(self.tile.thumbnail(obj))
self.assertIsInstance(self.tile(), unicode)

0 comments on commit 828b113

Please sign in to comment.