Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Jan 25, 2016
1 parent bfc7fdf commit 1c3c1aa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
7 changes: 5 additions & 2 deletions src/collective/cover/tests/test_collection_tile.py
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from collective.cover.config import PLONE_VERSION
from collective.cover.testing import DEXTERITY_ONLY
from collective.cover.tests.base import TestTileMixin
from collective.cover.tests.utils import today
from collective.cover.tiles.collection import CollectionTile
Expand Down Expand Up @@ -109,6 +111,9 @@ def test_delete_collection(self):
self.tile.is_compose_mode = Mock(return_value=False)
self.assertNotIn(msg, self.tile())

@unittest.skipIf(
PLONE_VERSION < '5.0' and DEXTERITY_ONLY,
'https://github.com/plone/plone.app.contenttypes/issues/315')
def test_thumbnail(self):
# as a File does not have an image field, we should have no thumbnail
obj = self.portal['my-file']
Expand All @@ -130,8 +135,6 @@ def test_thumbnail(self):
self.assertFalse(self.tile._field_is_visible('image'))
self.assertFalse(self.tile.thumbnail(obj))

# TODO: test against Dexterity-based content types

def test_number_of_items(self):
collection = self.portal['my-collection']
collection.setQuery(IMAGE_QUERY)
Expand Down
19 changes: 10 additions & 9 deletions src/collective/cover/tiles/contentbody.py
Expand Up @@ -35,19 +35,20 @@ def is_empty(self):
return not self.data.get('uuid', False)

def body(self):
body = ''
"""Return the body text of the related object."""
uuid = self.data.get('uuid', None)
try:
obj = uuid and uuidToObject(uuid)
except Unauthorized:
obj = None
if obj is not None:
if hasattr(obj, 'getText'):
body = obj.getText()
else:
# Probably Dexterity.
body = obj.text.output
return body
return # TODO: handle exception and show message on template

if obj is None:
return '' # obj was deleted

try:
return obj.getText() # Archetypes
except AttributeError:
return obj.text.output if obj.text is not None else '' # Dexterity

def populate_with_object(self, obj):
super(ContentBodyTile, self).populate_with_object(obj)
Expand Down
5 changes: 2 additions & 3 deletions src/collective/cover/tiles/templates/contentbody.pt
Expand Up @@ -16,9 +16,8 @@
</a>
</div>

<tal:text define="text view/body;
len_text python:len(text.strip())">
<div class="discreet" tal:condition="python:not len_text and view.is_compose_mode()"
<tal:text define="text view/body">
<div class="discreet" tal:condition="python:not text and view.is_compose_mode()"
i18n:translate="">This item does not have any body text.</div>
<div class="content" tal:condition="text"
tal:content="structure text">Body</div>
Expand Down

0 comments on commit 1c3c1aa

Please sign in to comment.