From d22f003f9c7c4339c6800faa177ce873f0b373b9 Mon Sep 17 00:00:00 2001 From: hvelarde Date: Thu, 18 Aug 2016 11:05:53 -0300 Subject: [PATCH] Disable calendar tile in Plone 5 Refs. https://github.com/collective/collective.cover/issues/633 --- .../cover/tests/test_calendar_tile.py | 10 +++ src/collective/cover/tests/test_upgrades.py | 2 + .../cover/tests/test_vocabularies.py | 69 +++++++++++-------- src/collective/cover/vocabularies.py | 19 +++-- 4 files changed, 67 insertions(+), 33 deletions(-) diff --git a/src/collective/cover/tests/test_calendar_tile.py b/src/collective/cover/tests/test_calendar_tile.py index bfc14db73..8e5c32af3 100644 --- a/src/collective/cover/tests/test_calendar_tile.py +++ b/src/collective/cover/tests/test_calendar_tile.py @@ -27,3 +27,13 @@ def test_default_configuration(self): def test_accepted_content_types(self): self.assertEqual(self.tile.accepted_ct(), []) + + +# load tests only in Plone < 5 +def test_suite(): + # FIXME: https://github.com/collective/collective.cover/issues/633 + from collective.cover.config import IS_PLONE_5 + if IS_PLONE_5: + return unittest.TestSuite() + + return unittest.defaultTestLoader.loadTestsFromName(__name__) diff --git a/src/collective/cover/tests/test_upgrades.py b/src/collective/cover/tests/test_upgrades.py index 9420d13bd..4f96c199a 100644 --- a/src/collective/cover/tests/test_upgrades.py +++ b/src/collective/cover/tests/test_upgrades.py @@ -524,6 +524,8 @@ def test_registrations(self): self.assertGreaterEqual(int(version), int(self.to_version)) self.assertEqual(self._how_many_upgrades_to_do(), 4) + # FIXME: https://github.com/collective/collective.cover/issues/633 + @unittest.skipIf(IS_PLONE_5, 'Upgrade step not supported under Plone 5') def test_register_calendar_tile(self): # address also an issue with Setup permission title = u'Register calendar tile' diff --git a/src/collective/cover/tests/test_vocabularies.py b/src/collective/cover/tests/test_vocabularies.py index 5dce9675e..75256ec19 100644 --- a/src/collective/cover/tests/test_vocabularies.py +++ b/src/collective/cover/tests/test_vocabularies.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- - +from collective.cover.config import IS_PLONE_5 from collective.cover.controlpanel import ICoverSettings from collective.cover.testing import INTEGRATION_TESTING from plone.registry.interfaces import IRegistry @@ -33,38 +33,53 @@ def test_available_tiles_vocabulary(self): vocabulary = queryUtility(IVocabularyFactory, name) self.assertIsNotNone(vocabulary) tiles = vocabulary(self.portal) - self.assertEqual(len(tiles), 10) - self.assertIn(u'collective.cover.banner', tiles) - self.assertIn(u'collective.cover.basic', tiles) - self.assertIn(u'collective.cover.carousel', tiles) - self.assertIn(u'collective.cover.collection', tiles) - self.assertIn(u'collective.cover.contentbody', tiles) - self.assertIn(u'collective.cover.embed', tiles) - self.assertIn(u'collective.cover.file', tiles) - self.assertIn(u'collective.cover.list', tiles) - self.assertIn(u'collective.cover.richtext', tiles) + expected = [ + 'collective.cover.banner', + 'collective.cover.basic', + 'collective.cover.calendar', + 'collective.cover.carousel', + 'collective.cover.collection', + 'collective.cover.contentbody', + 'collective.cover.embed', + 'collective.cover.file', + 'collective.cover.list', + 'collective.cover.richtext', + ] + + # FIXME: https://github.com/collective/collective.cover/issues/633 + if IS_PLONE_5: + expected.remove('collective.cover.calendar') + + self.assertEqual(len(tiles), len(expected)) + for i in expected: + self.assertIn(i, tiles) def test_enabled_tiles_vocabulary(self): name = 'collective.cover.EnabledTiles' vocabulary = queryUtility(IVocabularyFactory, name) self.assertIsNotNone(vocabulary) tiles = vocabulary(self.portal) - self.assertEqual(len(tiles), 11) - self.assertIn(u'collective.cover.banner', tiles) - self.assertIn(u'collective.cover.basic', tiles) - self.assertIn(u'collective.cover.carousel', tiles) - self.assertIn(u'collective.cover.collection', tiles) - self.assertIn(u'collective.cover.contentbody', tiles) - self.assertIn(u'collective.cover.embed', tiles) - self.assertIn(u'collective.cover.file', tiles) - self.assertIn(u'collective.cover.list', tiles) - self.assertIn(u'collective.cover.richtext', tiles) - # FIXME see: https://github.com/collective/collective.cover/issues/194 - self.assertIn(u'collective.cover.pfg', tiles) - # XXX: https://github.com/collective/collective.cover/issues/81 - # standard tiles are not enabled... yet - self.assertNotIn(u'plone.app.imagetile', tiles) - self.assertNotIn(u'plone.app.texttile', tiles) + expected = [ + 'collective.cover.banner', + 'collective.cover.basic', + 'collective.cover.calendar', + 'collective.cover.carousel', + 'collective.cover.collection', + 'collective.cover.contentbody', + 'collective.cover.embed', + 'collective.cover.file', + 'collective.cover.list', + 'collective.cover.pfg', # FIXME: https://github.com/collective/collective.cover/issues/194 + 'collective.cover.richtext', + ] + + # FIXME: https://github.com/collective/collective.cover/issues/633 + if IS_PLONE_5: + expected.remove('collective.cover.calendar') + + self.assertEqual(len(tiles), len(expected)) + for i in expected: + self.assertIn(i, tiles) def test_available_content_types_vocabulary(self): name = 'collective.cover.AvailableContentTypes' diff --git a/src/collective/cover/vocabularies.py b/src/collective/cover/vocabularies.py index 7c5d0b204..69126afd9 100644 --- a/src/collective/cover/vocabularies.py +++ b/src/collective/cover/vocabularies.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- - +from collective.cover.config import IS_PLONE_5 from collective.cover.controlpanel import ICoverSettings from collective.cover.interfaces import IGridSystem from collective.cover.tiles.base import IPersistentCoverTile @@ -33,9 +33,12 @@ class AvailableTilesVocabulary(object): def __call__(self, context): registry = getUtility(IRegistry) - tiles = registry[ - 'collective.cover.controlpanel.ICoverSettings.available_tiles' - ] + settings = registry.forInterface(ICoverSettings) + tiles = settings.available_tiles + + # FIXME: https://github.com/collective/collective.cover/issues/633 + if IS_PLONE_5 and 'collective.cover.calendar' in tiles: + tiles.remove('collective.cover.calendar') items = [SimpleTerm(value=i, title=i) for i in tiles] return SimpleVocabulary(items) @@ -52,10 +55,14 @@ def __call__(self, context): @implementer(IVocabularyFactory) class EnabledTilesVocabulary(object): - """Return a list of tiles ready to work with collective.cover. - """ + + """Return a list of tiles ready to work with collective.cover.""" def _enabled(self, name): + # FIXME: https://github.com/collective/collective.cover/issues/633 + if IS_PLONE_5 and name == 'collective.cover.calendar': + return False + tile_type = queryUtility(ITileType, name) if tile_type: return issubclass(tile_type.schema, IPersistentCoverTile)