def testManagerPurge(self): context = DummyImportContext(self.portal, purge=False) context._files['portlets.xml'] = """<?xml version="1.0"?> <portlets> <portletmanager name="test.testcolumn" purge="True" /> </portlets> """ importPortlets(context) self.assertRaises(KeyError, assignment_mapping_from_key, self.portal, manager_name=u"test.testcolumn", category=GROUP_CATEGORY, key="Reviewers") self.assertRaises(KeyError, assignment_mapping_from_key, self.portal, manager_name=u"test.testcolumn", category=CONTENT_TYPE_CATEGORY, key="Folder") # context assignment at the root are purged as well mapping = assignment_mapping_from_key(self.portal, manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/") self.assertEqual(0, len(mapping))
def testAssignmentRoot(self): mapping = assignment_mapping_from_key(self.portal, manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/") self.assertEqual(3, len(mapping)) # No assignment in /news subfolder mapping = assignment_mapping_from_key(self.portal, manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/news") self.assertEqual(0, len(mapping)) context = DummyImportContext(self.portal, purge=False) context._files['portlets.xml'] = """<?xml version="1.0"?> <portlets> <assignment manager="test.testcolumn" category="context" key="/news" type="portlets.test.Test" name="test.portlet4" /> </portlets> """ importPortlets(context) # Still 3 portlets in the root mapping = assignment_mapping_from_key(self.portal, manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/") self.assertEqual(3, len(mapping)) # but 1 extra in the /news subfolder mapping = assignment_mapping_from_key(self.portal, manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/news") self.assertEqual(1, len(mapping))
def testPurge(self): manager = queryUtility(IPortletManager, name=u"test.testcolumn") self.assertNotEquals(None, manager) context = DummyImportContext(self.portal, purge=False) context._files['portlets.xml'] = """<?xml version="1.0"?> <portlets purge="True"> </portlets> """ importPortlets(context) manager = queryUtility(IPortletManager, name=u"test.testcolumn") self.assertEqual(None, manager)
def testAssignmentPurging(self): # initially there should be 3 assignments on the root mapping = assignment_mapping_from_key(self.portal, manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/") self.assertEqual(3, len(mapping)) context = DummyImportContext(self.portal, purge=False) context._files['portlets.xml'] = """<?xml version="1.0"?> <portlets> <assignment manager="test.testcolumn" category="context" key="/" purge="True" /> </portlets> """ importPortlets(context) # now they should be gone mapping = assignment_mapping_from_key(self.portal, manager_name=u"test.testcolumn", category=CONTEXT_CATEGORY, key="/") self.assertEqual(0, len(mapping)) # group assignments should still be there mapping = assignment_mapping_from_key(self.portal, manager_name=u"test.testcolumn", category=GROUP_CATEGORY, key="Reviewers") self.assertEqual(1, len(mapping)) # and be purgable context = DummyImportContext(self.portal, purge=False) context._files['portlets.xml'] = """<?xml version="1.0"?> <portlets> <assignment manager="test.testcolumn" category="group" key="Reviewers" purge="True" /> </portlets> """ importPortlets(context) # now they should be gone mapping = assignment_mapping_from_key(self.portal, manager_name=u"test.testcolumn", category=GROUP_CATEGORY, key="Reviewers") self.assertEqual(0, len(mapping)) # also content type assignments should still be there mapping = assignment_mapping_from_key(self.portal, manager_name=u"test.testcolumn", category=CONTENT_TYPE_CATEGORY, key="Folder") self.assertEqual(2, len(mapping)) # and be purgable context = DummyImportContext(self.portal, purge=False) context._files['portlets.xml'] = """<?xml version="1.0"?> <portlets> <assignment manager="test.testcolumn" category="content_type" key="Folder" purge="True" /> </portlets> """ importPortlets(context) # now they should be gone mapping = assignment_mapping_from_key(self.portal, manager_name=u"test.testcolumn", category=CONTENT_TYPE_CATEGORY, key="Folder") self.assertEqual(0, len(mapping))