Back to index

plone3  3.1.7
test_setup.py
Go to the documentation of this file.
00001 from zope.app.component.hooks import setSite, setHooks
00002 from zope.component import getSiteManager, getUtilitiesFor, getUtility
00003 
00004 from plone.portlets.interfaces import IPortletManager
00005 from plone.portlets.interfaces import ILocalPortletAssignable
00006 from plone.portlets.interfaces import IPortletType
00007 
00008 from plone.app.portlets.interfaces import ILeftColumn, IRightColumn, IDashboard
00009 
00010 from plone.app.portlets.tests.base import PortletsTestCase
00011 
00012 class TestProductInstall(PortletsTestCase):
00013 
00014     def afterSetUp(self):
00015         setHooks()
00016         setSite(self.portal)
00017 
00018     def testPortletManagersRegistered(self):
00019         sm = getSiteManager(self.portal)
00020         registrations = [r.name for r in sm.registeredUtilities()
00021                             if IPortletManager == r.provided]
00022         self.assertEquals(['plone.dashboard1', 'plone.dashboard2', 'plone.dashboard3', 'plone.dashboard4',
00023                            'plone.leftcolumn', 'plone.rightcolumn'], sorted(registrations))
00024 
00025     def testInterfaces(self):
00026         left = getUtility(IPortletManager, 'plone.leftcolumn')
00027         right = getUtility(IPortletManager, 'plone.rightcolumn')
00028         dashboard = getUtility(IPortletManager, 'plone.dashboard1')
00029 
00030         self.failUnless(ILeftColumn.providedBy(left))
00031         self.failUnless(IRightColumn.providedBy(right))
00032         self.failUnless(IDashboard.providedBy(dashboard))
00033 
00034     def testAssignable(self):
00035         self.failUnless(ILocalPortletAssignable.providedBy(self.folder))
00036         self.failUnless(ILocalPortletAssignable.providedBy(self.portal))
00037 
00038     def testPortletTypesRegistered(self):
00039         portlets = [u[0] for u in getUtilitiesFor(IPortletType)]
00040         self.failUnless('portlets.Classic' in portlets)
00041         self.failUnless('portlets.Login' in portlets)
00042 
00043 def test_suite():
00044     from unittest import TestSuite, makeSuite
00045     suite = TestSuite()
00046     suite.addTest(makeSuite(TestProductInstall))
00047     return suite