Permalink
Browse files

Test for the news collection criteria, sort order and layout settings.

  • Loading branch information...
1 parent 203290f commit 0cf5c59f5e3482f34df5e613b2ded1c69cdfcb28 @pumazi pumazi committed Dec 8, 2011
Showing with 40 additions and 10 deletions.
  1. +25 −10 plone/app/contenttypes/setuphandlers.py
  2. +15 −0 plone/app/contenttypes/tests/test_content_profile.py
@@ -172,22 +172,33 @@ def importContent(context):
id='aggregator', title=title,
description=description)
aggregator = container['aggregator']
- container.setOrdering('unordered')
+
+ # Set the content-types that can be added to this container.
# FIXME The following 3 lines
##container.setConstrainTypesMode(constraintypes.ENABLED)
##container.setLocallyAllowedTypes(allowed_types)
##container.setImmediatelyAddableTypes(allowed_types)
+
+ container.setOrdering('unordered')
container.setDefaultPage('aggregator')
_publish(container)
- # TODO Set the Collection criteria.
- # type_crit = topic.addCriterion('Type', 'ATPortalTypeCriterion')
- # type_crit.setValue('News Item')
- # topic.addCriterion('created', 'ATSortCriterion')
- # state_crit = topic.addCriterion('review_state', 'ATSimpleStringCriterion')
- # state_crit.setValue('published')
- # topic.setSortCriterion('effective', True)
- # topic.setLayout('folder_summary_view')
+ # Set the Collection criteria.
+ #: Sort on the Effective date
+ aggregator.sort_on = u'effective'
+ aggregator.reverse_sort = True
+ #: Query by Type and Review State
+ aggregator.query = [
+ {'i': u'portal_type',
+ 'o': u'plone.app.querystring.operation.selection.is',
+ 'v': [u'News Item'],
+ },
+ {'i': u'review_state',
+ 'o': u'plone.app.querystring.operation.selection.is',
+ 'v': [u'published'],
+ },
+ ]
+ aggregator.setLayout('summary_view')
_publish(aggregator)
@@ -206,14 +217,18 @@ def importContent(context):
id='aggregator', title=title,
description=description)
aggregator = container['aggregator']
- container.setOrdering('unordered')
+
+ # Set the content-types that can be added to this container.
# FIXME The following 3 lines
##container.setConstrainTypesMode(constraintypes.ENABLED)
##container.setLocallyAllowedTypes(allowed_types)
##container.setImmediatelyAddableTypes(allowed_types)
+
+ container.setOrdering('unordered')
container.setDefaultPage('aggregator')
_publish(container)
+ # Set up the collection
# type_crit = topic.addCriterion('Type', 'ATPortalTypeCriterion')
# type_crit.setValue('Event')
# topic.addCriterion('start', 'ATSortCriterion')
@@ -144,3 +144,18 @@ def test_news_allowable_types(self):
# to a container is currently not implemented anywhere.
self.fail("The implementation for local allowed types on containers "
"is missing.")
+
+ def test_news_aggregator_settings(self):
+ # Has the news aggregator (Collection) been set up?
+ query = [dict(i=u'portal_type',
+ o=u'plone.app.querystring.operation.selection.is',
+ v=[u'News Item']),
+ dict(i=u'review_state',
+ o=u'plone.app.querystring.operation.selection.is',
+ v=[u'published']),
+ ]
+ collection = self.portal['news']['aggregator']
+ self.assertEqual(collection.sort_on, u'effective')
+ self.assertEqual(collection.reverse_sort, True)
+ self.assertItemsEqual(collection.query, query)
+ self.assertEqual(collection.getLayout(), 'summary_view')

0 comments on commit 0cf5c59

Please sign in to comment.