Back to index

plone3  3.1.7
testControlPanel.py
Go to the documentation of this file.
00001 #
00002 # Exportimport adapter tests
00003 #
00004 
00005 import os, sys
00006 if __name__ == '__main__':
00007     execfile(os.path.join(sys.path[0], 'framework.py'))
00008 
00009 from Products.CMFPlone.tests import PloneTestCase
00010 from Products.CMFPlone.exportimport.tests.base import BodyAdapterTestCase
00011 
00012 from zope.app.component.hooks import setHooks, setSite
00013 from zope.component import getSiteManager
00014 from Products.CMFActionIcons.interfaces import IActionIconsTool
00015 from Products.CMFPlone.interfaces import IControlPanel
00016 from Products.CMFPlone.PloneControlPanel import PloneControlPanel
00017 from Products.CMFPlone.setuphandlers import PloneGenerator
00018 from OFS.Folder import Folder
00019 
00020 _CONTROLPANEL_XML = """\
00021 <?xml version="1.0"?>
00022 <object name="portal_controlpanel" meta_type="Plone Control Panel Tool">
00023  <configlet title="Add/Remove Products" action_id="QuickInstaller"
00024     appId="QuickInstaller" category="Plone" condition_expr=""
00025     url_expr="string:${portal_url}/prefs_install_products_form"
00026     visible="True">
00027   <permission>Manage portal</permission>
00028  </configlet>
00029 </object>
00030 """
00031 
00032 
00033 class DummyActionIconsTool(Folder):
00034 
00035     id = 'portal_actionicons'
00036     meta_type = 'Dummy Action Icons Tool'
00037 
00038     def queryActionInfo(self, category, action_id, default=None, context=None):
00039         pass
00040 
00041 
00042 class ControlPanelXMLAdapterTests(BodyAdapterTestCase):
00043 
00044     def _getTargetClass(self):
00045         from Products.CMFPlone.exportimport.controlpanel \
00046                     import ControlPanelXMLAdapter
00047         return ControlPanelXMLAdapter
00048 
00049     def _populate(self, obj):
00050         obj.registerConfiglet( id='QuickInstaller'
00051                              , name='Add/Remove Products'
00052                              , action='string:${portal_url}/prefs_install_products_form'
00053                              , permission='Manage portal'
00054                              , category='Plone'
00055                              , visible=True
00056                              , appId='QuickInstaller'
00057                              )
00058 
00059     def setUp(self):
00060         setHooks()
00061         self.site = Folder('site')
00062         gen = PloneGenerator()
00063         gen.enableSite(self.site)
00064         setSite(self.site)
00065         sm = getSiteManager()
00066         self.site.portal_actionicons = DummyActionIconsTool()
00067         sm.registerUtility(self.site.portal_actionicons, IActionIconsTool)
00068         self.site.portal_control_panel = PloneControlPanel()
00069         sm.registerUtility(self.site.portal_control_panel, IControlPanel)
00070 
00071         self._obj = self.site.portal_control_panel
00072         self._BODY = _CONTROLPANEL_XML
00073 
00074 
00075 def test_suite():
00076     from unittest import TestSuite, makeSuite
00077     suite = TestSuite()
00078     suite.addTest(makeSuite(ControlPanelXMLAdapterTests))
00079     return suite
00080 
00081 if __name__ == '__main__':
00082     framework()
00083