コード例 #1
0
    def test_issue_262(self):
        # get tiles and assign css_class as before version 5
        layout = self.layout_view.get_layout('view')
        tile_def = layout[0]['children'][0]['children'][0]
        self.tile1 = self.cover.restrictedTraverse('{0}/{1}'.format(tile_def['tile-type'], tile_def['id']))
        tile_config = self.tile1.get_tile_configuration()
        tile_config['css_class'] = {'order': u'0', 'visibility': u'on'}
        self.tile1.set_tile_configuration(tile_config)

        tile_def = layout[0]['children'][1]['children'][0]
        self.tile2 = self.cover.restrictedTraverse('{0}/{1}'.format(tile_def['tile-type'], tile_def['id']))
        tile_config = self.tile2.get_tile_configuration()
        tile_config['css_class'] = u"--NOVALUE--"
        self.tile2.set_tile_configuration(tile_config)

        tile_def = layout[1]['children'][0]['children'][0]
        self.tile3 = self.cover.restrictedTraverse('{0}/{1}'.format(tile_def['tile-type'], tile_def['id']))
        tile_config = self.tile3.get_tile_configuration()
        tile_config['css_class'] = u""
        self.tile3.set_tile_configuration(tile_config)

        tile_def = layout[1]['children'][1]['children'][0]
        self.tile4 = self.cover.restrictedTraverse('{0}/{1}'.format(tile_def['tile-type'], tile_def['id']))
        tile_config = self.tile4.get_tile_configuration()
        tile_config['css_class'] = u"tile-shadow"
        self.tile4.set_tile_configuration(tile_config)

        registry = getUtility(IRegistry)
        record = 'collective.cover.controlpanel.ICoverSettings.styles'
        default_style = u"-Default-|tile-default"

        # default installation includes the '-Default-|tile-default' style
        self.assertIn(default_style, registry[record])

        # old installations (upgraded up to version 4) didn't include default style
        register_styles_record(self.portal)
        self.assertNotIn(default_style, registry[record])

        # upgraded installations (up to version 5) include default style
        update_styles_record_4_5(self.portal)
        self.assertIn(default_style, registry[record])

        # after upgrade step, old tiles have a new default value for
        # css_class field (if they didn't have one)
        set_new_default_class_4_5(self.portal)
        self.assertEqual(self.tile1.get_tile_configuration()['css_class'], u"tile-default")
        self.assertEqual(self.tile2.get_tile_configuration()['css_class'], u"tile-default")
        self.assertEqual(self.tile3.get_tile_configuration()['css_class'], u"tile-default")
        self.assertEqual(self.tile4.get_tile_configuration()['css_class'], u"tile-shadow")
コード例 #2
0
    def test_register_styles_record(self):
        registry = getUtility(IRegistry)
        record = 'collective.cover.controlpanel.ICoverSettings.styles'

        eventtesting.setUp()

        # just delete the existing record and rerun the handler to verify it
        # was added again
        del registry.records[record]
        eventtesting.clearEvents()
        register_styles_record(self.portal)
        events = eventtesting.getEvents(IRecordAddedEvent)
        self.assertNotEqual(len(events), 0)
        self.assertIn(record, registry.records)
        eventtesting.clearEvents()
コード例 #3
0
ファイル: test_upgrades.py プロジェクト: adam139/plonesrc
    def test_register_styles_record(self):
        registry = getUtility(IRegistry)
        record = 'collective.cover.controlpanel.ICoverSettings.styles'

        eventtesting.setUp()

        # calling the handler here should have no effect as we are running the
        # latest profile version
        eventtesting.clearEvents()
        register_styles_record(self.portal)
        events = eventtesting.getEvents(IRecordAddedEvent)
        self.assertEqual(len(events), 0)

        # now we delete the record and rerun the handler to verify the record
        # was added
        del registry.records[record]
        eventtesting.clearEvents()
        register_styles_record(self.portal)
        events = eventtesting.getEvents(IRecordAddedEvent)
        self.assertNotEqual(len(events), 0)
        self.assertIn(record, registry.records)
        eventtesting.clearEvents()
コード例 #4
0
    def test_register_styles_record(self):
        registry = getUtility(IRegistry)
        record = 'collective.cover.controlpanel.ICoverSettings.styles'

        eventtesting.setUp()

        # calling the handler here should have no effect as we are running the
        # latest profile version
        eventtesting.clearEvents()
        register_styles_record(self.portal)
        events = eventtesting.getEvents(IRecordAddedEvent)
        self.assertEqual(len(events), 0)

        # now we delete the record and rerun the handler to verify the record
        # was added
        del registry.records[record]
        eventtesting.clearEvents()
        register_styles_record(self.portal)
        events = eventtesting.getEvents(IRecordAddedEvent)
        self.assertNotEqual(len(events), 0)
        self.assertIn(record, registry.records)
        eventtesting.clearEvents()
コード例 #5
0
    def test_issue_262(self):
        # check if the upgrade step is registered
        title = u'issue_262'
        description = u"Default value for css_class."
        step = self._get_upgrade_step(title)
        self.assertIsNotNone(step)
        self.assertEqual(step['description'], description)

        # get tiles and assign css_class as before version 5
        layout = self.layout_view.get_layout('view')
        tile_def = layout[0]['children'][0]['children'][0]
        self.tile1 = self.cover.restrictedTraverse('{0}/{1}'.format(tile_def['tile-type'], tile_def['id']))
        tile_config = self.tile1.get_tile_configuration()
        tile_config['css_class'] = {'order': u'0', 'visibility': u'on'}
        self.tile1.set_tile_configuration(tile_config)

        tile_def = layout[0]['children'][1]['children'][0]
        self.tile2 = self.cover.restrictedTraverse('{0}/{1}'.format(tile_def['tile-type'], tile_def['id']))
        tile_config = self.tile2.get_tile_configuration()
        tile_config['css_class'] = u"--NOVALUE--"
        self.tile2.set_tile_configuration(tile_config)

        tile_def = layout[1]['children'][0]['children'][0]
        self.tile3 = self.cover.restrictedTraverse('{0}/{1}'.format(tile_def['tile-type'], tile_def['id']))
        tile_config = self.tile3.get_tile_configuration()
        tile_config['css_class'] = u""
        self.tile3.set_tile_configuration(tile_config)

        tile_def = layout[1]['children'][1]['children'][0]
        self.tile4 = self.cover.restrictedTraverse('{0}/{1}'.format(tile_def['tile-type'], tile_def['id']))
        tile_config = self.tile4.get_tile_configuration()
        tile_config['css_class'] = u"tile-shadow"
        self.tile4.set_tile_configuration(tile_config)

        registry = getUtility(IRegistry)
        record = 'collective.cover.controlpanel.ICoverSettings.styles'
        default_style = u"-Default-|tile-default"

        # FIXME: this must be tested outside the upgrade step also
        # default installation includes the '-Default-|tile-default' style
        self.assertIn(default_style, registry[record])

        # simulate version 4 state by removing default style
        register_styles_record(self.portal)
        self.assertNotIn(default_style, registry[record])

        # after upgrade step, old tiles have a new default value for
        # css_class field (if they didn't have one)
        self._do_upgrade_step(step)

        # upgraded installations include default style
        self.assertIn(default_style, registry[record])

        self.assertEqual(
            self.tile1.get_tile_configuration()['css_class'], u"tile-default")
        self.assertEqual(
            self.tile2.get_tile_configuration()['css_class'], u"tile-default")
        self.assertEqual(
            self.tile3.get_tile_configuration()['css_class'], u"tile-default")
        self.assertEqual(
            self.tile4.get_tile_configuration()['css_class'], u"tile-shadow")