def testMigrateControlPanelActionIcons(self): _KNOWN_ACTION_ICONS['controlpanel'].extend(['test_id']) self.aitool.addActionIcon( category='controlpanel', action_id='test_id', icon_expr='test.gif', title='Test my icon', ) self.cptool.registerConfiglet( id='test_id', name='Test Configlet', action='string:${portal_url}/test', permission='Manage portal', category='Plone', visible=True, appId='', icon_expr='', ) action = self.cptool.getActionObject('Plone/test_id') self.assertEqual(action.getIconExpression(), '') # Test it twice for i in range(2): migrateActionIcons(self.portal) icons = [ic._action_id for ic in self.aitool.listActionIcons()] self.assertFalse('test_id' in icons) self.assertEqual(action.getIconExpression(), 'string:$portal_url/test.gif')
def testMigrateActionIcons(self): _KNOWN_ACTION_ICONS['object_buttons'].extend(['test_id', 'test2_id']) self.aitool.addActionIcon( category='object_buttons', action_id='test_id', icon_expr='test.gif', title='Test my icon', ) self.aitool.addActionIcon( category='object_buttons', action_id='test2_id', icon_expr='python:context.getIcon()', title='Test my second icon', ) test_action = Action('test_id', title='Test me', description='', url_expr='', icon_expr='', available_expr='', permissions=('View', ), visible = True) test2_action = Action('test2_id', title='Test me too', description='', url_expr='', icon_expr='', available_expr='', permissions=('View', ), visible = True) object_buttons = self.atool.object_buttons if getattr(object_buttons, 'test_id', None) is None: object_buttons._setObject('test_id', test_action) if getattr(object_buttons, 'test2_id', None) is None: object_buttons._setObject('test2_id', test2_action) self.assertEqual(object_buttons.test_id.icon_expr, '') self.assertEqual(object_buttons.test2_id.icon_expr, '') self.assertEqual( self.aitool.getActionIcon('object_buttons', 'test_id'), 'test.gif') # Test it twice for i in range(2): migrateActionIcons(self.portal) icons = [ic.getActionId() for ic in self.aitool.listActionIcons()] self.failIf('test_id' in icons) self.failIf('test2_id' in icons) self.assertEqual(object_buttons.test_id.icon_expr, 'string:$portal_url/test.gif') self.assertEqual(object_buttons.test2_id.icon_expr, 'python:context.getIcon()')