Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
plone.app.portlets.tests.test_configuration.TestGenericSetup Class Reference
Inheritance diagram for plone.app.portlets.tests.test_configuration.TestGenericSetup:
Inheritance graph
[legend]
Collaboration diagram for plone.app.portlets.tests.test_configuration.TestGenericSetup:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def testPortletManagerInstalled
def disabled_testPortletTypeRegistered
def testAssignmentCreatedAndOrdered
def testAssignmentPropertiesSet
def testAssignmentRemoval
def testAssignmentPurging
def testBlacklisting
def testPurgeMethod
def testPurge
def testManagerRemove
def testManagerPurge
def testExport

Static Public Attributes

 layer = TestPortletGSLayer

Detailed Description

Definition at line 189 of file test_configuration.py.


Member Function Documentation

Definition at line 197 of file test_configuration.py.

00197 
00198     def disabled_testPortletTypeRegistered(self):
00199         portlet_type = getUtility(IPortletType, name=u"portlets.test.Test")
00200         self.assertEquals('portlets.test.Test', portlet_type.addview)
00201         self.assertEquals([Interface], portlet_type.for_)
00202         # XXX Missing i18n support in the exportimport code
00203         self.failUnless(isinstance(portlet_type.title, Message),
00204                         "Portlet title should be a Message instance")
00205         self.failUnless(isinstance(portlet_type.description, Message),
00206                         "Portlet description should be a Message instance")
00207         self.assertEquals(u"title_test_portlet", portlet_type.title)
00208         self.assertEquals(u"description_test_portlet", portlet_type.description)
00209         self.assertEquals(u"Test portlet", portlet_type.title.default)
00210         self.assertEquals(u"A test portlet", portlet_type.description.default)
00211         self.assertEquals(u"plone", portlet_type.title.domain)
00212         self.assertEquals(u"plone", portlet_type.description.domain)

Definition at line 213 of file test_configuration.py.

00213 
00214     def testAssignmentCreatedAndOrdered(self):
00215         mapping = assignment_mapping_from_key(self.portal,
00216             manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/")
00217         self.assertEquals(3, len(mapping))
00218         self.assertEquals(['test.portlet3', 'test.portlet2', 'test.portlet1'], list(mapping.keys()))
        

Here is the call graph for this function:

Definition at line 219 of file test_configuration.py.

00219 
00220     def testAssignmentPropertiesSet(self):
00221         mapping = assignment_mapping_from_key(self.portal,
00222             manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/")
00223         
00224         assignment = mapping['test.portlet1']
00225         self.assertEquals(u'Test pr\xf6p 1', assignment.test_text)
00226         self.assertEquals(False, assignment.test_bool)
00227         self.assertEquals((u'published', u'private'), assignment.test_tuple)
00228         
00229         assignment = mapping['test.portlet2']
00230         self.assertEquals('Test prop 2', assignment.test_text)
00231         self.assertEquals(True, assignment.test_bool)
00232         self.assertEquals((), assignment.test_tuple)
00233         
00234         assignment = mapping['test.portlet3']
00235         self.assertEquals(None, assignment.test_text)
00236         self.assertEquals(None, assignment.test_bool)
00237         self.assertEquals(None, assignment.test_tuple)
        

Here is the call graph for this function:

Definition at line 267 of file test_configuration.py.

00267 
00268     def testAssignmentPurging(self):
00269         # initially there should be 3 assignments on the root
00270         mapping = assignment_mapping_from_key(self.portal,
00271             manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/")
00272         self.assertEquals(3, len(mapping))
00273 
00274         context = DummyImportContext(self.portal, purge=False)
00275         context._files['portlets.xml'] = """<?xml version="1.0"?>
00276             <portlets>
00277                 <assignment
00278                     manager="test.testcolumn" 
00279                     category="context"
00280                     key="/"
00281                     purge="True"
00282                     />
00283             </portlets>
00284         """
00285         importPortlets(context)
00286 
00287         # now they should be gone
00288         mapping = assignment_mapping_from_key(self.portal,
00289             manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/")
00290         self.assertEquals(0, len(mapping))
00291 
00292         # group assignments should still be there
00293         mapping = assignment_mapping_from_key(self.portal,
00294             manager_name=u"test.testcolumn", category=GROUP_CATEGORY, key="Reviewers")
00295         self.assertEquals(1, len(mapping))
00296 
00297         # and be purgable
00298         context = DummyImportContext(self.portal, purge=False)
00299         context._files['portlets.xml'] = """<?xml version="1.0"?>
00300             <portlets>
00301                 <assignment
00302                     manager="test.testcolumn" 
00303                     category="group"
00304                     key="Reviewers"
00305                     purge="True"
00306                     />
00307             </portlets>
00308         """
00309         importPortlets(context)
00310 
00311         # now they should be gone
00312         mapping = assignment_mapping_from_key(self.portal,
00313             manager_name=u"test.testcolumn", category=GROUP_CATEGORY, key="Reviewers")
00314         self.assertEquals(0, len(mapping))
00315 
00316         # also content type assignments should still be there
00317         mapping = assignment_mapping_from_key(self.portal,
00318             manager_name=u"test.testcolumn", category=CONTENT_TYPE_CATEGORY, key="Folder")
00319         self.assertEquals(2, len(mapping))
00320 
00321         # and be purgable
00322         context = DummyImportContext(self.portal, purge=False)
00323         context._files['portlets.xml'] = """<?xml version="1.0"?>
00324             <portlets>
00325                 <assignment
00326                     manager="test.testcolumn" 
00327                     category="content_type"
00328                     key="Folder"
00329                     purge="True"
00330                     />
00331             </portlets>
00332         """
00333         importPortlets(context)
00334 
00335         # now they should be gone
00336         mapping = assignment_mapping_from_key(self.portal,
00337             manager_name=u"test.testcolumn", category=CONTENT_TYPE_CATEGORY, key="Folder")
00338         self.assertEquals(0, len(mapping))

Here is the call graph for this function:

Definition at line 238 of file test_configuration.py.

00238 
00239     def testAssignmentRemoval(self):
00240         portal_setup = self.portal.portal_setup
00241         
00242         # wait a bit or we get duplicate ids on import
00243         time.sleep(1)
00244         portal_setup.runAllImportStepsFromProfile('profile-plone.app.portlets:testing')
00245 
00246         mapping = assignment_mapping_from_key(self.portal,
00247             manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/")
00248 
00249         # initally there should be no portlet7
00250         self.assertEqual(mapping.get('test.portlet7', None), None)
00251 
00252         # now we add one
00253         portlet_factory = getUtility(IFactory, name='portlets.test.Test')
00254         assignment = portlet_factory()
00255         mapping['test.portlet7'] = assignment
00256 
00257         # make sure it's there
00258         self.assertNotEqual(mapping.get('test.portlet7', None), None)
00259 
00260         # wait a bit or we get duplicate ids on import
00261         time.sleep(1)
00262         # run the profile
00263         portal_setup.runAllImportStepsFromProfile('profile-plone.app.portlets:testing')
00264 
00265         # and should have got rid of it again
00266         self.assertEqual(mapping.get('test.portlet7', None), None)

Here is the call graph for this function:

Definition at line 339 of file test_configuration.py.

00339 
00340     def testBlacklisting(self):
00341         news = self.portal.news
00342         manager = getUtility(IPortletManager, name=u"test.testcolumn")
00343         
00344         assignable = getMultiAdapter((news, manager), ILocalPortletAssignmentManager)
00345         self.assertEquals(True, assignable.getBlacklistStatus(CONTEXT_CATEGORY))
00346         self.assertEquals(False, assignable.getBlacklistStatus(GROUP_CATEGORY))
00347         self.assertEquals(None, assignable.getBlacklistStatus(CONTENT_TYPE_CATEGORY))

Definition at line 416 of file test_configuration.py.

00416 
00417     def testExport(self):
00418         sm = getSiteManager()
00419         context = TarballExportContext(self.portal.portal_setup)
00420         handler = getMultiAdapter((sm, context), IBody, name=u'plone.portlets')
00421         handler._purgePortlets()
00422         
00423         time.sleep(1)
00424         
00425         portal_setup = self.portal.portal_setup
00426         portal_setup.runAllImportStepsFromProfile('profile-plone.app.portlets:testing')
00427 
00428         expected = """\
00429 <?xml version="1.0"?>
00430 <portlets>
00431  <portletmanager name="test.testcolumn"
00432     type="plone.app.portlets.tests.test_configuration.ITestColumn"/>
00433  <portlet title="Test portlet" addview="portlets.test.Test"
00434     description="A test portlet"/>
00435  <assignment name="test.portlet6" category="group" key="Reviewers"
00436     manager="test.testcolumn" type="portlets.test.Test">
00437   <property name="test_bool"/>
00438   <property name="test_tuple"/>
00439   <property name="test_text"/>
00440  </assignment>
00441  <assignment name="test.portlet4" category="content_type" key="Folder"
00442     manager="test.testcolumn" type="portlets.test.Test">
00443   <property name="test_bool"/>
00444   <property name="test_tuple"/>
00445   <property name="test_text"/>
00446  </assignment>
00447  <assignment name="test.portlet5" category="content_type" key="Folder"
00448     manager="test.testcolumn" type="portlets.test.Test">
00449   <property name="test_bool"/>
00450   <property name="test_tuple"/>
00451   <property name="test_text"/>
00452  </assignment>
00453  <assignment name="test.portlet3" category="context" key="/"
00454     manager="test.testcolumn" type="portlets.test.Test">
00455   <property name="test_bool"/>
00456   <property name="test_tuple"/>
00457   <property name="test_text"/>
00458  </assignment>
00459  <assignment name="test.portlet2" category="context" key="/"
00460     manager="test.testcolumn" type="portlets.test.Test">
00461   <property name="test_bool">True</property>
00462   <property name="test_tuple"/>
00463   <property name="test_text">Test prop 2</property>
00464  </assignment>
00465  <assignment name="test.portlet1" category="context" key="/"
00466     manager="test.testcolumn" type="portlets.test.Test">
00467   <property name="test_bool">False</property>
00468   <property name="test_tuple"/>
00469   <property name="test_text">Test pröp 1</property>
00470  </assignment>
00471  <blacklist category="user" location="/" manager="test.testcolumn"
00472     status="acquire"/>
00473  <blacklist category="group" location="/" manager="test.testcolumn"
00474     status="show"/>
00475  <blacklist category="content_type" location="/" manager="test.testcolumn"
00476     status="block"/>
00477  <blacklist category="context" location="/" manager="test.testcolumn"
00478     status="acquire"/>
00479 </portlets>
00480 """
00481 
00482         body = handler.body
00483         self.assertEquals(expected.strip(), body.strip(), body)
00484         

Definition at line 389 of file test_configuration.py.

00389 
00390     def testManagerPurge(self):
00391         context = DummyImportContext(self.portal, purge=False)
00392         context._files['portlets.xml'] = """<?xml version="1.0"?>
00393             <portlets>
00394                 <portletmanager 
00395                     name="test.testcolumn" 
00396                     purge="True"
00397                     />
00398             </portlets>
00399         """
00400         importPortlets(context)
00401 
00402         self.assertRaises(KeyError,
00403                           assignment_mapping_from_key,
00404                           self.portal, manager_name=u"test.testcolumn",
00405                           category=GROUP_CATEGORY, key="Reviewers")
00406 
00407         self.assertRaises(KeyError,
00408                           assignment_mapping_from_key,
00409                           self.portal, manager_name=u"test.testcolumn",
00410                           category=CONTENT_TYPE_CATEGORY, key="Folder")
00411 
00412         # context assignment at the root are purged as well
00413         mapping = assignment_mapping_from_key(self.portal,
00414             manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/")
00415         self.assertEquals(0, len(mapping))

Here is the call graph for this function:

Definition at line 371 of file test_configuration.py.

00371 
00372     def testManagerRemove(self):
00373         manager = queryUtility(IPortletManager, name=u"test.testcolumn")
00374         self.assertNotEquals(None, manager)
00375 
00376         context = DummyImportContext(self.portal, purge=False)
00377         context._files['portlets.xml'] = """<?xml version="1.0"?>
00378             <portlets>
00379                 <portletmanager 
00380                     name="test.testcolumn" 
00381                     remove="True"
00382                     />
00383             </portlets>
00384         """
00385         importPortlets(context)
00386 
00387         manager = queryUtility(IPortletManager, name=u"test.testcolumn")
00388         self.assertEquals(None, manager)

Here is the call graph for this function:

Definition at line 193 of file test_configuration.py.

00193 
00194     def testPortletManagerInstalled(self):
00195         manager = getUtility(IPortletManager, name=u"test.testcolumn")
00196         self.failUnless(ITestColumn.providedBy(manager))
    

Definition at line 357 of file test_configuration.py.

00357 
00358     def testPurge(self):
00359         manager = queryUtility(IPortletManager, name=u"test.testcolumn")
00360         self.assertNotEquals(None, manager)
00361 
00362         context = DummyImportContext(self.portal, purge=False)
00363         context._files['portlets.xml'] = """<?xml version="1.0"?>
00364             <portlets purge="True">
00365             </portlets>
00366         """
00367         importPortlets(context)
00368 
00369         manager = queryUtility(IPortletManager, name=u"test.testcolumn")
00370         self.assertEquals(None, manager)

Here is the call graph for this function:

Definition at line 348 of file test_configuration.py.

00348 
00349     def testPurgeMethod(self):
00350         sm = getSiteManager()
00351         context = TarballExportContext(self.portal.portal_setup)
00352         handler = getMultiAdapter((sm, context), IBody, name=u'plone.portlets')
00353         handler._purgePortlets()
00354         
00355         manager = queryUtility(IPortletManager, name=u"test.testcolumn")
00356         self.assertEquals(None, manager)


Member Data Documentation

Definition at line 191 of file test_configuration.py.


The documentation for this class was generated from the following file: