def testGetCurrentFolder(self): # If context is a folder, then the folder is returned view = Plone(self.folder, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # If context is not a folder, then the parent is returned # A bit crude ... we need to make sure our memos don't stick in the # tests self._invalidateRequestMemoizations() view = Plone(self.folder.test, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # The real container is returned regardless of context self._invalidateRequestMemoizations() view = Plone(self.folder.test.__of__(self.portal), self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # A non-structural folder does not count as a folder` f = dummy.NonStructuralFolder('ns_folder') self.folder._setObject('ns_folder', f) self._invalidateRequestMemoizations() view = Plone(self.folder.ns_folder, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # And even a structural folder that is used as a default page # returns its parent self.folder.setDefaultPage('ns_folder') self._invalidateRequestMemoizations() view = Plone(self.folder.ns_folder, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder)
class TestVisibleIdsEnabled(PloneTestCase.PloneTestCase): '''Tests the visibleIdsEnabled method''' def afterSetUp(self): self.view = Plone(self.portal, self.app.REQUEST) self.member = self.portal.portal_membership.getAuthenticatedMember() self.props = self.portal.portal_properties.site_properties def testFailsWithSitePropertyDisabled(self): # Set baseline self.member.setProperties(visible_ids=False) self.props.manage_changeProperties(visible_ids=False) # Should fail when site property is set false self.assertFalse(self.view.visibleIdsEnabled()) self.member.setProperties(visible_ids=True) self.assertFalse(self.view.visibleIdsEnabled()) def testFailsWithMemberPropertyDisabled(self): # Should fail when member property is false self.member.setProperties(visible_ids=False) self.props.manage_changeProperties(visible_ids=True) self.assertFalse(self.view.visibleIdsEnabled()) def testSucceedsWithMemberAndSitePropertyEnabled(self): # Should succeed only when site property and member property are true self.props.manage_changeProperties(visible_ids=True) self.member.setProperties(visible_ids=True) self.assertTrue(self.view.visibleIdsEnabled())
def testGetParentObject(self): view = Plone(self.folder.test, self.app.REQUEST) self.assertEqual(view.getParentObject(), self.folder) # Make sure this looks only at containment del self.app.REQUEST.__annotations__ view = Plone(self.folder.test.__of__(self.portal), self.app.REQUEST) self.assertEqual(view.getParentObject(), self.folder)
def testGetParentObject(self): view = Plone(self.folder.test, self.app.REQUEST) self.assertEqual(view.getParentObject(), self.folder) # Make sure this looks only at containment self._invalidateRequestMemoizations() view = Plone(self.folder.test.__of__(self.portal), self.app.REQUEST) self.assertEqual(view.getParentObject(), self.folder)
class TestVisibleIdsEnabled(PloneTestCase.PloneTestCase): '''Tests the visibleIdsEnabled method''' def afterSetUp(self): self.view = Plone(self.portal, self.app.REQUEST) self.member = self.portal.portal_membership.getAuthenticatedMember() registry = getUtility(IRegistry) self.props = registry.forInterface(IEditingSchema, prefix="plone") def testFailsWithSitePropertyDisabled(self): # Set baseline self.member.setProperties(visible_ids=False) self.props.visible_ids = False # Should fail when site property is set false self.assertFalse(self.view.visibleIdsEnabled()) self.member.setProperties(visible_ids=True) self.assertFalse(self.view.visibleIdsEnabled()) def testFailsWithMemberPropertyDisabled(self): # Should fail when member property is false self.member.setProperties(visible_ids=False) self.props.visible_ids = True self.assertFalse(self.view.visibleIdsEnabled()) def testSucceedsWithMemberAndSitePropertyEnabled(self): # Should succeed only when site property and member property are true self.props.visible_ids = True self.member.setProperties(visible_ids=True) self.assertTrue(self.view.visibleIdsEnabled())
def CroppedDescription(self): registry = getUtility(IRegistry) length = registry.get('plone.search_results_description_length') plone_view = PloneView(None, None) if not length or not isinstance(length, int): # fallback if registry key is None length = 160 return plone_view.cropText(self.flare.Description, length)
def CroppedDescription(self): registry = getUtility(IRegistry) length = registry.get("plone.search_results_description_length") plone_view = PloneView(None, None) if not length or not isinstance(length, int): # fallback if registry key is None length = 160 return plone_view.cropText(self.flare.Description, length)
def testDisablePortlets(self): view = Plone(self.portal, self.app.REQUEST) view._initializeData() data = view._data self.assertEqual(True, data['sr']) self.assertEqual('visualColumnHideOne', data['hidecolumns']) view._initializeData(options={'no_portlets': True}) self.assertEqual(False, data['sr']) self.assertEqual('visualColumnHideOneTwo', data['hidecolumns'])
def testIsDefaultPageInFolder(self): view = Plone(self.folder.test, self.app.REQUEST) self.assertFalse(view.isDefaultPageInFolder()) self.assertTrue(self.folder.canSelectDefaultPage()) self.folder.setDefaultPage('test') # re-create the view, because the old value is cached self._invalidateRequestMemoizations() view = Plone(self.folder.test, self.app.REQUEST) self.assertTrue(view.isDefaultPageInFolder())
def testIsDefaultPageInFolder(self): view = Plone(self.folder.test, self.app.REQUEST) self.failIf(view.isDefaultPageInFolder()) self.failUnless(self.folder.canSelectDefaultPage()) self.folder.saveDefaultPage('test') # re-create the view, because the old value is cached del self.app.REQUEST.__annotations__ view = Plone(self.folder.test, self.app.REQUEST) self.failUnless(view.isDefaultPageInFolder())
def testCropText(self): view = Plone(self.portal, self.app.REQUEST) self.assertEqual(view.cropText(b'Hello world', 7), b'Hello ...') self.assertEqual(view.cropText('Hello world', 7), 'Hello ...') self.assertEqual(view.cropText(b'Hello world', 10), b'Hello worl...') self.assertEqual(view.cropText('Hello world', 10), 'Hello worl...') self.assertEqual(view.cropText(b'Hello world', 99), b'Hello world') self.assertEqual(view.cropText('Hello world', 99), 'Hello world') self.assertEqual(view.cropText('Koko\u0159\xedn', 5), 'Koko\u0159...') # Test utf encoded string Kokorin with 'r' and 'i' accented # Must return 6 characters, because 5th character is two byte text = 'Koko\u0159\xedn'.encode() self.assertEqual(view.cropText(text, 5), b'Koko\xc5\x99...')
def testActionOverrideFromTemplate(self): # We should be able to pass actions in from the template # and have them override the calculated actions view = Plone(self.portal, self.app.REQUEST) view._initializeData() data = view._data self.failUnless(data['actions']) self.failUnless(data['keyed_actions']) self.failUnless(data['user_actions']) no_actions = {'folder':[], 'user':[], 'global':[], 'workflow':[]} view._initializeData(options={'actions':no_actions}) self.assertEqual(data['actions'], no_actions) self.assertEqual(data['keyed_actions'], no_actions) self.failIf(data['user_actions'])
def afterSetUp(self): # We need to fiddle the request for zope 2.9+ setDefaultSkin(self.app.REQUEST) self.folder.invokeFactory('Document', 'test', title='Test default page') self.view = Plone(self.portal, self.app.REQUEST) self.view._initializeData()
def banner(self, obj): # noqa: C901 """ return banner of this object """ banner = {} if getattr(obj, 'banner_image', False): banner['banner_image'] = '{0}/@@images/banner_image'.format( obj.absolute_url()) banner['banner_alt'] = getattr(obj, 'banner_alt', None) if obj.banner_title: banner['banner_title'] = obj.banner_title if obj.banner_description: crop = Plone(self.context, self.request).cropText banner['banner_description'] = crop(obj.banner_description, 400) if obj.banner_text: banner['banner_text'] = obj.banner_text.output if obj.banner_link: to_obj = obj.banner_link.to_object if to_obj: banner['banner_link'] = to_obj.absolute_url() banner['banner_linktext'] = to_obj.Title() if obj.banner_linktext: banner['banner_linktext'] = obj.banner_linktext if obj.banner_fontcolor: banner['banner_fontcolor'] = obj.banner_fontcolor if obj.banner_backgroundcolor: banner['banner_backgroundcolor'] = obj.banner_backgroundcolor if obj.banner_url: banner['banner_url'] = obj.banner_url banner['banner_obj'] = obj return banner
def showEditableBorder(self): """Determine if the editable border should be shown - overridden to suppress it for regular users on submission folders. Since people may add content it would show up otherwise. """ context = aq_inner(self.context) if context.getPortalTypeName() != 'SubmissionFolder': return Plone.showEditableBorder(self) portal_membership = getToolByName(context, 'portal_membership') checkPerm = portal_membership.checkPermission if not checkPerm('Review portal content', context): return False return Plone.showEditableBorder(self)
def testIsPortalOrPortalDefaultPage(self): # an actual folder whould return true view = Plone(self.portal, self.app.REQUEST) self.assertTrue(view.isPortalOrPortalDefaultPage()) # But not a document self.setRoles(['Manager']) self.portal.invokeFactory('Document', 'portal_test', title='Test default page') self._invalidateRequestMemoizations() view = Plone(self.portal.portal_test, self.app.REQUEST) self.assertFalse(view.isPortalOrPortalDefaultPage()) # Unless we make it the default view self.portal.setDefaultPage('portal_test') self._invalidateRequestMemoizations() view = Plone(self.portal.portal_test, self.app.REQUEST) self.assertTrue(view.isPortalOrPortalDefaultPage())
def testIsDefaultPageInFolder(self): view = Plone(self.folder.test, self.app.REQUEST) self.assertFalse(view.isDefaultPageInFolder()) self.assertTrue(self.folder.canSetDefaultPage()) self.folder.setDefaultPage('test') # re-create the view, because the old value is cached self._invalidateRequestMemoizations() view = Plone(self.folder.test, self.app.REQUEST) self.assertTrue(view.isDefaultPageInFolder())
def testIsDefaultPageInFolder(self): view = Plone(self.folder.test, self.app.REQUEST) self.failIf(view.isDefaultPageInFolder()) self.failUnless(self.folder.canSelectDefaultPage()) self.folder.saveDefaultPage('test') # re-create the view, because the old value is cached self._invalidateRequestMemoizations() view = Plone(self.folder.test, self.app.REQUEST) self.failUnless(view.isDefaultPageInFolder())
def testCropText(self): view = Plone(self.portal, self.app.REQUEST) self.assertEqual(view.cropText('Hello world', 7), 'Hello ...') self.assertEqual(view.cropText('Hello world', 99), 'Hello world') self.assertEqual(view.cropText('Hello world', 10), 'Hello worl...') self.assertEqual(view.cropText(u'Hello world', 10), u'Hello worl...') self.assertEqual(view.cropText(u'Koko\u0159\xedn', 5), u'Koko\u0159...') # Test utf encoded string Kokorin with 'r' and 'i' accented # Must return 6 characters, because 5th character is two byte text = u'Koko\u0159\xedn'.encode('utf8') self.assertEqual(view.cropText(text, 5), 'Koko\xc5\x99...')
def toLocalizedTime(self, time, long_format=None, time_only=None, translate=True): """ Remove translation of localized time """ if translate: return Plone.toLocalizedTime(self, time=time, time_only=time_only, long_format=long_format) props = getToolByName(self.context, 'portal_properties').site_properties time = DateTime(time) if long_format: return time.strftime(props.localLongTimeFormat) return time.strftime(props.localTimeFormat)
def testIsFolderOrFolderDefaultPage(self): # an actual folder whould return true view = Plone(self.folder, self.app.REQUEST) self.assertTrue(view.isFolderOrFolderDefaultPage()) # But not a document self._invalidateRequestMemoizations() view = Plone(self.folder.test, self.app.REQUEST) self.assertFalse(view.isFolderOrFolderDefaultPage()) # Unless we make it the default view self.folder.setDefaultPage('test') self._invalidateRequestMemoizations() view = Plone(self.folder.test, self.app.REQUEST) self.assertTrue(view.isFolderOrFolderDefaultPage()) # And if we have a non-structural folder it should not be true f = dummy.NonStructuralFolder('ns_folder') self.folder._setObject('ns_folder', f) self._invalidateRequestMemoizations() view = Plone(self.folder.ns_folder, self.app.REQUEST) self.assertFalse(view.isFolderOrFolderDefaultPage())
def testIsFolderOrFolderDefaultPage(self): # an actual folder whould return true view = Plone(self.folder, self.app.REQUEST) self.failUnless(view.isFolderOrFolderDefaultPage()) # But not a document del self.app.REQUEST.__annotations__ view = Plone(self.folder.test, self.app.REQUEST) self.failIf(view.isFolderOrFolderDefaultPage()) # Unless we make it the default view self.folder.saveDefaultPage('test') del self.app.REQUEST.__annotations__ view = Plone(self.folder.test, self.app.REQUEST) self.failUnless(view.isFolderOrFolderDefaultPage()) # And if we have a non-structural folder it should not be true f = dummy.NonStructuralFolder('ns_folder') self.folder._setObject('ns_folder', f) del self.app.REQUEST.__annotations__ view = Plone(self.folder.ns_folder, self.app.REQUEST) self.failIf(view.isFolderOrFolderDefaultPage())
def testIsPortalOrPortalDefaultPage(self): # an actual folder whould return true view = Plone(self.portal, self.app.REQUEST) self.failUnless(view.isPortalOrPortalDefaultPage()) # But not a document self.setRoles(['Manager']) self.portal.invokeFactory('Document', 'portal_test', title='Test default page') del self.app.REQUEST.__annotations__ view = Plone(self.portal.portal_test, self.app.REQUEST) self.failIf(view.isPortalOrPortalDefaultPage()) # Unless we make it the default view self.portal.saveDefaultPage('portal_test') del self.app.REQUEST.__annotations__ view = Plone(self.portal.portal_test, self.app.REQUEST) self.failUnless(view.isPortalOrPortalDefaultPage())
class TestPloneView(PloneTestCase.PloneTestCase): """Tests the global plone view. All the old global_defines should be in the _data mapping of the view, which is globablized into calling templates.""" def afterSetUp(self): # We need to fiddle the request for zope 2.9+ setDefaultSkin(self.app.REQUEST) self.folder.invokeFactory('Document', 'test', title='Test default page') self.view = Plone(self.portal, self.app.REQUEST) self.view._initializeData() def testUTool(self): assert isinstance(self.view._data['utool'], URLTool) def testPortal(self): assert self.view._data['portal'] == self.portal def testPortalURL(self): assert isinstance(self.view._data['portal_url'], type('')) def testMTool(self): assert isinstance(self.view._data['mtool'], MembershipTool) def testATool(self): assert isinstance(self.view._data['atool'], ActionsTool) def testPUtils(self): pass def testWTool(self): assert isinstance(self.view._data['wtool'], WorkflowTool) def testIFaceTool(self): assert isinstance(self.view._data['ifacetool'], InterfaceTool) def testSynTool(self): assert isinstance(self.view._data['syntool'], SyndicationTool) def testPortalTitle(self): pass def testToLocalizedTime(self): localdate = self.view.toLocalizedTime value = localdate('Mar 9, 1997 1:45pm', long_format=True) self.assertEquals(value, 'Mar 09, 1997 01:45 PM') def testIsStructuralFolderWithNonFolder(self): i = dummy.Item() self.failIf(Plone(i, self.app.REQUEST).isStructuralFolder()) def testIsStructuralFolderWithFolder(self): f = dummy.Folder('struct_folder') self.failUnless(Plone(f, self.app.REQUEST).isStructuralFolder()) def testIsStructuralFolderWithNonStructuralFolder(self): f = dummy.NonStructuralFolder('ns_folder') self.failIf(Plone(f, self.app.REQUEST).isStructuralFolder()) def testIsStructuralFolderWithZ2NonStructuralFolder(self): f = dummy.Folder('z2_nsFolder') f.__implements__ = f.__implements__ + (z2INonStructuralFolder,) view = Plone(f, self.app.REQUEST) value = view.isStructuralFolder() self.failIf(Plone(f, self.app.REQUEST).isStructuralFolder()) def testIsDefaultPageInFolder(self): view = Plone(self.folder.test, self.app.REQUEST) self.failIf(view.isDefaultPageInFolder()) self.failUnless(self.folder.canSelectDefaultPage()) self.folder.saveDefaultPage('test') # re-create the view, because the old value is cached del self.app.REQUEST.__annotations__ view = Plone(self.folder.test, self.app.REQUEST) self.failUnless(view.isDefaultPageInFolder()) def testNavigationRootPath(self): view = Plone(self.folder, self.app.REQUEST) self.assertEqual(view.navigationRootPath(), self.portal.portal_url.getPortalPath()) def testNavigationRootUrl(self): view = Plone(self.folder, self.app.REQUEST) self.assertEqual(view.navigationRootUrl(), self.portal.absolute_url()) def testGetParentObject(self): view = Plone(self.folder.test, self.app.REQUEST) self.assertEqual(view.getParentObject(), self.folder) # Make sure this looks only at containment del self.app.REQUEST.__annotations__ view = Plone(self.folder.test.__of__(self.portal), self.app.REQUEST) self.assertEqual(view.getParentObject(), self.folder) def testIsFolderOrFolderDefaultPage(self): # an actual folder whould return true view = Plone(self.folder, self.app.REQUEST) self.failUnless(view.isFolderOrFolderDefaultPage()) # But not a document del self.app.REQUEST.__annotations__ view = Plone(self.folder.test, self.app.REQUEST) self.failIf(view.isFolderOrFolderDefaultPage()) # Unless we make it the default view self.folder.saveDefaultPage('test') del self.app.REQUEST.__annotations__ view = Plone(self.folder.test, self.app.REQUEST) self.failUnless(view.isFolderOrFolderDefaultPage()) # And if we have a non-structural folder it should not be true f = dummy.NonStructuralFolder('ns_folder') self.folder._setObject('ns_folder', f) del self.app.REQUEST.__annotations__ view = Plone(self.folder.ns_folder, self.app.REQUEST) self.failIf(view.isFolderOrFolderDefaultPage()) def testIsPortalOrPortalDefaultPage(self): # an actual folder whould return true view = Plone(self.portal, self.app.REQUEST) self.failUnless(view.isPortalOrPortalDefaultPage()) # But not a document self.setRoles(['Manager']) self.portal.invokeFactory('Document', 'portal_test', title='Test default page') del self.app.REQUEST.__annotations__ view = Plone(self.portal.portal_test, self.app.REQUEST) self.failIf(view.isPortalOrPortalDefaultPage()) # Unless we make it the default view self.portal.saveDefaultPage('portal_test') del self.app.REQUEST.__annotations__ view = Plone(self.portal.portal_test, self.app.REQUEST) self.failUnless(view.isPortalOrPortalDefaultPage()) def testGetCurrentFolder(self): # If context is a folder, then the folder is returned view = Plone(self.folder, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # If context is not a folder, then the parent is returned # A bit crude ... we need to make sure our memos don't stick in the tests del self.app.REQUEST.__annotations__ view = Plone(self.folder.test, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # The real container is returned regardless of context del self.app.REQUEST.__annotations__ view = Plone(self.folder.test.__of__(self.portal), self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # A non-structural folder does not count as a folder` f = dummy.NonStructuralFolder('ns_folder') self.folder._setObject('ns_folder', f) del self.app.REQUEST.__annotations__ view = Plone(self.folder.ns_folder, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # And even a structural folder that is used as a default page # returns its parent self.setRoles(['Manager']) self.folder.invokeFactory('Topic', 'topic') del self.app.REQUEST.__annotations__ view = Plone(self.folder.topic, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder.topic) self.folder.saveDefaultPage('topic') del self.app.REQUEST.__annotations__ view = Plone(self.folder.topic, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) def testHavePortlets(self): view = Plone(self.portal, self.app.REQUEST) self.assertEqual(False, view.have_portlets('plone.leftcolumn')) self.assertEqual(True, view.have_portlets('plone.rightcolumn')) def testDisablePortlets(self): view = Plone(self.portal, self.app.REQUEST) view._initializeData() data = view._data self.assertEqual(True, data['sr']) self.assertEqual('visualColumnHideOne', data['hidecolumns']) view._initializeData(options={'no_portlets': True}) self.assertEqual(False, data['sr']) self.assertEqual('visualColumnHideOneTwo', data['hidecolumns']) def testCropText(self): view = Plone(self.portal, self.app.REQUEST) self.assertEqual(view.cropText('Hello world', 7), 'Hello ...') self.assertEqual(view.cropText('Hello world', 99), 'Hello world') self.assertEqual(view.cropText('Hello world', 10), 'Hello worl...') self.assertEqual(view.cropText(u'Hello world', 10), u'Hello worl...') self.assertEqual(view.cropText(u'Koko\u0159\xedn', 5), u'Koko\u0159...') # Test utf encoded string Kokorin with 'r' and 'i' accented # Must return 6 characters, because 5th character is two byte text = u'Koko\u0159\xedn'.encode('utf8') self.assertEqual(view.cropText(text, 5), 'Koko\xc5\x99...') def testUniqueIndexIterator(self): iterator = self.view._data['uniqueItemIndex'] self.assertEquals(0, iterator.next()) self.assertEquals(1, iterator.next()) self.assertEquals(2, iterator.next()) def testPrepareObjectTabsOnPortalRoot(self): del self.app.REQUEST.__annotations__ self.loginAsPortalOwner() self.app.REQUEST['ACTUAL_URL'] = self.portal.absolute_url() view = self.portal.restrictedTraverse('@@plone') tabs = view.prepareObjectTabs() self.assertEquals(tabs[0]['id'], 'folderContents') self.assertEquals(['view'], [t['id'] for t in tabs if t['selected']]) def testPrepareObjectTabsNonFolder(self): del self.app.REQUEST.__annotations__ self.loginAsPortalOwner() self.app.REQUEST['ACTUAL_URL'] = self.folder.test.absolute_url() view = self.folder.test.restrictedTraverse('@@plone') tabs = view.prepareObjectTabs() self.assertEquals(0, len([t for t in tabs if t['id'] == 'folderContents'])) self.assertEquals(['view'], [t['id'] for t in tabs if t['selected']]) def testPrepareObjectTabsNonStructuralFolder(self): del self.app.REQUEST.__annotations__ self.loginAsPortalOwner() self.app.REQUEST['ACTUAL_URL'] = self.folder.absolute_url() directlyProvides(self.folder, INonStructuralFolder) view = self.folder.restrictedTraverse('@@plone') tabs = view.prepareObjectTabs() noLongerProvides(self.folder, INonStructuralFolder) self.assertEquals(0, len([t for t in tabs if t['id'] == 'folderContents'])) self.assertEquals(['view'], [t['id'] for t in tabs if t['selected']]) def testPrepareObjectTabsDefaultView(self): del self.app.REQUEST.__annotations__ self.loginAsPortalOwner() self.app.REQUEST['ACTUAL_URL'] = self.folder.test.absolute_url() + '/edit' view = self.folder.test.restrictedTraverse('@@plone') tabs = view.prepareObjectTabs() self.assertEquals(0, len([t for t in tabs if t['id'] == 'folderContents'])) self.assertEquals(['edit'], [t['id'] for t in tabs if t['selected']]) def testActionOverrideFromTemplate(self): # We should be able to pass actions in from the template # and have them override the calculated actions view = Plone(self.portal, self.app.REQUEST) view._initializeData() data = view._data self.failUnless(data['actions']) self.failUnless(data['keyed_actions']) self.failUnless(data['user_actions']) no_actions = {'folder':[], 'user':[], 'global':[], 'workflow':[]} view._initializeData(options={'actions':no_actions}) self.assertEqual(data['actions'], no_actions) self.assertEqual(data['keyed_actions'], no_actions) self.failIf(data['user_actions'])
def testSiteEncoding(self): view = Plone(self.portal, self.app.REQUEST) self.assertEqual('utf-8', view.site_encoding())
def afterSetUp(self): self.folder.invokeFactory('Document', 'test', title='Test default page') self.view = Plone(self.portal, self.app.REQUEST)
def testIsStructuralFolderWithZ2NonStructuralFolder(self): f = dummy.Folder('z2_nsFolder') f.__implements__ = f.__implements__ + (z2INonStructuralFolder,) view = Plone(f, self.app.REQUEST) value = view.isStructuralFolder() self.failIf(Plone(f, self.app.REQUEST).isStructuralFolder())
def testIsStructuralFolderWithFolder(self): f = dummy.Folder('struct_folder') self.failUnless(Plone(f, self.app.REQUEST).isStructuralFolder())
def testNavigationRootPath(self): view = Plone(self.folder, self.app.REQUEST) self.assertEqual(view.navigationRootPath(), self.portal.portal_url.getPortalPath())
def testNavigationRootUrl(self): view = Plone(self.folder, self.app.REQUEST) self.assertEqual(view.navigationRootUrl(), self.portal.absolute_url())
def testIsStructuralFolderWithNonStructuralFolder(self): f = dummy.NonStructuralFolder('ns_folder') self.assertFalse(Plone(f, self.app.REQUEST).isStructuralFolder())
def afterSetUp(self): self.view = Plone(self.portal, self.app.REQUEST) self.member = self.portal.portal_membership.getAuthenticatedMember() self.props = self.portal.portal_properties.site_properties
def testIsStructuralFolderWithFolder(self): f = dummy.Folder('struct_folder') self.assertTrue(Plone(f, self.app.REQUEST).isStructuralFolder())
def testIsStructuralFolderWithNonFolder(self): i = dummy.Item() self.assertFalse(Plone(i, self.app.REQUEST).isStructuralFolder())
def testHavePortlets(self): view = Plone(self.portal, self.app.REQUEST) self.assertEqual(False, view.have_portlets('plone.leftcolumn')) self.assertEqual(True, view.have_portlets('plone.rightcolumn'))
def _strip_text(item, length=500, ellipsis='...'): transformer = ITransformer(item) transformedValue = transformer(item.text, 'text/plain') return Plone.cropText(transformedValue, length=length, ellipsis=ellipsis)
def testGetCurrentFolder(self): # If context is a folder, then the folder is returned view = Plone(self.folder, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # If context is not a folder, then the parent is returned # A bit crude ... we need to make sure our memos don't stick in the tests del self.app.REQUEST.__annotations__ view = Plone(self.folder.test, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # The real container is returned regardless of context del self.app.REQUEST.__annotations__ view = Plone(self.folder.test.__of__(self.portal), self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # A non-structural folder does not count as a folder` f = dummy.NonStructuralFolder('ns_folder') self.folder._setObject('ns_folder', f) del self.app.REQUEST.__annotations__ view = Plone(self.folder.ns_folder, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder) # And even a structural folder that is used as a default page # returns its parent self.setRoles(['Manager']) self.folder.invokeFactory('Topic', 'topic') del self.app.REQUEST.__annotations__ view = Plone(self.folder.topic, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder.topic) self.folder.saveDefaultPage('topic') del self.app.REQUEST.__annotations__ view = Plone(self.folder.topic, self.app.REQUEST) self.assertEqual(view.getCurrentFolder(), self.folder)
def afterSetUp(self): self.view = Plone(self.portal, self.app.REQUEST) self.member = self.portal.portal_membership.getAuthenticatedMember() registry = getUtility(IRegistry) self.props = registry.forInterface(IEditingSchema, prefix="plone")