Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
CMFPlone.tests.testPloneView.TestPloneView Class Reference
Inheritance diagram for CMFPlone.tests.testPloneView.TestPloneView:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.tests.testPloneView.TestPloneView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def testUTool
def testPortal
def testPortalURL
def testMTool
def testATool
def testPUtils
def testWTool
def testIFaceTool
def testSynTool
def testPortalTitle
def testToLocalizedTime
def testIsStructuralFolderWithNonFolder
def testIsStructuralFolderWithFolder
def testIsStructuralFolderWithNonStructuralFolder
def testIsStructuralFolderWithZ2NonStructuralFolder
def testIsDefaultPageInFolder
def testNavigationRootPath
def testNavigationRootUrl
def testGetParentObject
def testIsFolderOrFolderDefaultPage
def testIsPortalOrPortalDefaultPage
def testGetCurrentFolder
def testHavePortlets
def testDisablePortlets
def testCropText
def testUniqueIndexIterator
def testPrepareObjectTabsOnPortalRoot
def testPrepareObjectTabsNonFolder
def testPrepareObjectTabsNonStructuralFolder
def testPrepareObjectTabsDefaultView
def testActionOverrideFromTemplate
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 view

Detailed Description

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.

Definition at line 24 of file testPloneView.py.


Member Function Documentation

Definition at line 29 of file testPloneView.py.

00029 
00030     def afterSetUp(self):
00031         # We need to fiddle the request for zope 2.9+
00032         setDefaultSkin(self.app.REQUEST)
00033         self.folder.invokeFactory('Document', 'test',
00034                                   title='Test default page')
00035         self.view = Plone(self.portal, self.app.REQUEST)
00036         self.view._initializeData()

Definition at line 30 of file PloneTestCase.py.

00030 
00031     def getAuthenticator(self):
00032         tag = AuthenticatorView('context', 'request').authenticator()
00033         pattern = '<input .*name="(\w+)".*value="(\w+)"'
00034         return match(pattern, tag).groups()

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.tests.PloneTestCase.PloneTestCase.setRequestMethod (   self,
  method 
) [inherited]
This is a stub now, but in case you want to try
   something fancy on Your Branch (tm), put it here.

Definition at line 26 of file PloneTestCase.py.

00026 
00027     def setRequestMethod(self, method):
00028         self.app.REQUEST.set('REQUEST_METHOD', method)
00029         self.app.REQUEST.method = method

Here is the caller graph for this function:

Definition at line 35 of file PloneTestCase.py.

00035 
00036     def setupAuthenticator(self):
00037         name, token = self.getAuthenticator()
00038         self.app.REQUEST.form[name] = token
00039 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 262 of file testPloneView.py.

00262 
00263     def testActionOverrideFromTemplate(self):
00264         # We should be able to pass actions in from the template
00265         # and have them override the calculated actions
00266         view = Plone(self.portal, self.app.REQUEST)
00267         view._initializeData()
00268         data = view._data
00269         self.failUnless(data['actions'])
00270         self.failUnless(data['keyed_actions'])
00271         self.failUnless(data['user_actions'])
00272         no_actions = {'folder':[], 'user':[], 'global':[], 'workflow':[]}
00273         view._initializeData(options={'actions':no_actions})
00274         self.assertEqual(data['actions'], no_actions)
00275         self.assertEqual(data['keyed_actions'], no_actions)
00276         self.failIf(data['user_actions'])
00277 

Here is the call graph for this function:

Definition at line 49 of file testPloneView.py.

00049 
00050     def testATool(self):
00051         assert isinstance(self.view._data['atool'], ActionsTool)

Definition at line 206 of file testPloneView.py.

00206 
00207     def testCropText(self):
00208         view = Plone(self.portal, self.app.REQUEST)
00209         self.assertEqual(view.cropText('Hello world', 7), 'Hello ...')
00210         self.assertEqual(view.cropText('Hello world', 99), 'Hello world')
00211         self.assertEqual(view.cropText('Hello world', 10), 'Hello worl...')
00212         self.assertEqual(view.cropText(u'Hello world', 10), u'Hello worl...')
00213         self.assertEqual(view.cropText(u'Koko\u0159\xedn', 5), u'Koko\u0159...')
00214         # Test utf encoded string Kokorin with 'r' and 'i' accented 
00215         # Must return 6 characters, because 5th character is two byte
00216         text = u'Koko\u0159\xedn'.encode('utf8')
00217         self.assertEqual(view.cropText(text, 5), 'Koko\xc5\x99...')
    

Here is the call graph for this function:

Definition at line 196 of file testPloneView.py.

00196 
00197     def testDisablePortlets(self):
00198         view = Plone(self.portal, self.app.REQUEST)
00199         view._initializeData()
00200         data = view._data
00201         self.assertEqual(True, data['sr'])
00202         self.assertEqual('visualColumnHideOne', data['hidecolumns'])
00203         view._initializeData(options={'no_portlets': True})
00204         self.assertEqual(False, data['sr'])
00205         self.assertEqual('visualColumnHideOneTwo', data['hidecolumns'])

Here is the call graph for this function:

Definition at line 154 of file testPloneView.py.

00154 
00155     def testGetCurrentFolder(self):
00156         # If context is a folder, then the folder is returned
00157         view = Plone(self.folder, self.app.REQUEST)
00158         self.assertEqual(view.getCurrentFolder(), self.folder)
00159         
00160         # If context is not a folder, then the parent is returned
00161         # A bit crude ... we need to make sure our memos don't stick in the tests
00162         del self.app.REQUEST.__annotations__
00163         view = Plone(self.folder.test, self.app.REQUEST)
00164         self.assertEqual(view.getCurrentFolder(), self.folder)
00165         
00166         # The real container is returned regardless of context
00167         del self.app.REQUEST.__annotations__
00168         view = Plone(self.folder.test.__of__(self.portal), self.app.REQUEST)
00169         self.assertEqual(view.getCurrentFolder(), self.folder)
00170         
00171         # A non-structural folder does not count as a folder`
00172         f = dummy.NonStructuralFolder('ns_folder')
00173         self.folder._setObject('ns_folder', f)
00174         del self.app.REQUEST.__annotations__
00175         view = Plone(self.folder.ns_folder, self.app.REQUEST)
00176         self.assertEqual(view.getCurrentFolder(), self.folder)
00177         
00178         # And even a structural folder that is used as a default page
00179         # returns its parent
00180         self.setRoles(['Manager'])
00181         self.folder.invokeFactory('Topic', 'topic')
00182         
00183         del self.app.REQUEST.__annotations__
00184         view = Plone(self.folder.topic, self.app.REQUEST)
00185         self.assertEqual(view.getCurrentFolder(), self.folder.topic)
00186         self.folder.saveDefaultPage('topic')
00187         
00188         del self.app.REQUEST.__annotations__
00189         view = Plone(self.folder.topic, self.app.REQUEST)
00190         self.assertEqual(view.getCurrentFolder(), self.folder)

Here is the call graph for this function:

Definition at line 109 of file testPloneView.py.

00109 
00110     def testGetParentObject(self):
00111         view = Plone(self.folder.test, self.app.REQUEST)
00112         self.assertEqual(view.getParentObject(), self.folder)
00113         # Make sure this looks only at containment
00114         del self.app.REQUEST.__annotations__
00115         view = Plone(self.folder.test.__of__(self.portal), self.app.REQUEST)
00116         self.assertEqual(view.getParentObject(), self.folder)

Here is the call graph for this function:

Definition at line 191 of file testPloneView.py.

00191 
00192     def testHavePortlets(self):
00193         view = Plone(self.portal, self.app.REQUEST)
00194         self.assertEqual(False, view.have_portlets('plone.leftcolumn'))
00195         self.assertEqual(True, view.have_portlets('plone.rightcolumn'))

Here is the call graph for this function:

Definition at line 58 of file testPloneView.py.

00058 
00059     def testIFaceTool(self):
00060         assert isinstance(self.view._data['ifacetool'], InterfaceTool)

Definition at line 91 of file testPloneView.py.

00091 
00092     def testIsDefaultPageInFolder(self):
00093         view = Plone(self.folder.test, self.app.REQUEST)
00094         self.failIf(view.isDefaultPageInFolder())
00095         self.failUnless(self.folder.canSelectDefaultPage())
00096         self.folder.saveDefaultPage('test')
00097         # re-create the view, because the old value is cached
00098         del self.app.REQUEST.__annotations__
00099         view = Plone(self.folder.test, self.app.REQUEST)
00100         self.failUnless(view.isDefaultPageInFolder())

Definition at line 117 of file testPloneView.py.

00117 
00118     def testIsFolderOrFolderDefaultPage(self):
00119         # an actual folder whould return true
00120         view = Plone(self.folder, self.app.REQUEST)
00121         self.failUnless(view.isFolderOrFolderDefaultPage())
00122         # But not a document
00123         del self.app.REQUEST.__annotations__
00124         view = Plone(self.folder.test, self.app.REQUEST)
00125         self.failIf(view.isFolderOrFolderDefaultPage())
00126         # Unless we make it the default view
00127         self.folder.saveDefaultPage('test')
00128         del self.app.REQUEST.__annotations__
00129         view = Plone(self.folder.test, self.app.REQUEST)
00130         self.failUnless(view.isFolderOrFolderDefaultPage())
00131         # And if we have a non-structural folder it should not be true
00132         f = dummy.NonStructuralFolder('ns_folder')
00133         self.folder._setObject('ns_folder', f)
00134         del self.app.REQUEST.__annotations__
00135         view = Plone(self.folder.ns_folder, self.app.REQUEST)
00136         self.failIf(view.isFolderOrFolderDefaultPage())

Here is the call graph for this function:

Definition at line 137 of file testPloneView.py.

00137 
00138     def testIsPortalOrPortalDefaultPage(self):
00139         # an actual folder whould return true
00140         view = Plone(self.portal, self.app.REQUEST)
00141         self.failUnless(view.isPortalOrPortalDefaultPage())
00142         # But not a document
00143         self.setRoles(['Manager'])
00144         self.portal.invokeFactory('Document', 'portal_test',
00145                                   title='Test default page')
00146         del self.app.REQUEST.__annotations__
00147         view = Plone(self.portal.portal_test, self.app.REQUEST)
00148         self.failIf(view.isPortalOrPortalDefaultPage())
00149         # Unless we make it the default view
00150         self.portal.saveDefaultPage('portal_test')
00151         del self.app.REQUEST.__annotations__
00152         view = Plone(self.portal.portal_test, self.app.REQUEST)
00153         self.failUnless(view.isPortalOrPortalDefaultPage())

Here is the call graph for this function:

Definition at line 76 of file testPloneView.py.

00076 
00077     def testIsStructuralFolderWithFolder(self):
00078         f = dummy.Folder('struct_folder')
00079         self.failUnless(Plone(f, self.app.REQUEST).isStructuralFolder())

Definition at line 72 of file testPloneView.py.

00072 
00073     def testIsStructuralFolderWithNonFolder(self):
00074         i = dummy.Item()
00075         self.failIf(Plone(i, self.app.REQUEST).isStructuralFolder())

Definition at line 80 of file testPloneView.py.

00080 
00081     def testIsStructuralFolderWithNonStructuralFolder(self):
00082         f = dummy.NonStructuralFolder('ns_folder')
00083         self.failIf(Plone(f, self.app.REQUEST).isStructuralFolder())

Definition at line 84 of file testPloneView.py.

00084 
00085     def testIsStructuralFolderWithZ2NonStructuralFolder(self):
00086         f = dummy.Folder('z2_nsFolder')
00087         f.__implements__ = f.__implements__ + (z2INonStructuralFolder,)
00088         view = Plone(f, self.app.REQUEST)
00089         value = view.isStructuralFolder()
00090         self.failIf(Plone(f, self.app.REQUEST).isStructuralFolder())

Definition at line 46 of file testPloneView.py.

00046 
00047     def testMTool(self):
00048         assert isinstance(self.view._data['mtool'], MembershipTool)

Definition at line 101 of file testPloneView.py.

00101 
00102     def testNavigationRootPath(self):
00103         view = Plone(self.folder, self.app.REQUEST)
00104         self.assertEqual(view.navigationRootPath(), self.portal.portal_url.getPortalPath())

Here is the call graph for this function:

Definition at line 105 of file testPloneView.py.

00105 
00106     def testNavigationRootUrl(self):
00107         view = Plone(self.folder, self.app.REQUEST)
00108         self.assertEqual(view.navigationRootUrl(), self.portal.absolute_url())

Here is the call graph for this function:

Definition at line 40 of file testPloneView.py.

00040 
00041     def testPortal(self):
00042         assert self.view._data['portal'] == self.portal

Here is the call graph for this function:

Definition at line 64 of file testPloneView.py.

00064 
00065     def testPortalTitle(self):
00066         pass

Definition at line 43 of file testPloneView.py.

00043 
00044     def testPortalURL(self):
00045         assert isinstance(self.view._data['portal_url'], type(''))

Definition at line 253 of file testPloneView.py.

00253 
00254     def testPrepareObjectTabsDefaultView(self):
00255         del self.app.REQUEST.__annotations__
00256         self.loginAsPortalOwner()
00257         self.app.REQUEST['ACTUAL_URL'] = self.folder.test.absolute_url() + '/edit'
00258         view = self.folder.test.restrictedTraverse('@@plone')
00259         tabs = view.prepareObjectTabs()
00260         self.assertEquals(0, len([t for t in tabs if t['id'] == 'folderContents']))
00261         self.assertEquals(['edit'], [t['id'] for t in tabs if t['selected']])

Here is the call graph for this function:

Definition at line 233 of file testPloneView.py.

00233 
00234     def testPrepareObjectTabsNonFolder(self):
00235         del self.app.REQUEST.__annotations__
00236         self.loginAsPortalOwner()
00237         self.app.REQUEST['ACTUAL_URL'] = self.folder.test.absolute_url()
00238         view = self.folder.test.restrictedTraverse('@@plone')
00239         tabs = view.prepareObjectTabs()
00240         self.assertEquals(0, len([t for t in tabs if t['id'] == 'folderContents']))
00241         self.assertEquals(['view'], [t['id'] for t in tabs if t['selected']])
        

Here is the call graph for this function:

Definition at line 242 of file testPloneView.py.

00242 
00243     def testPrepareObjectTabsNonStructuralFolder(self):
00244         del self.app.REQUEST.__annotations__
00245         self.loginAsPortalOwner()
00246         self.app.REQUEST['ACTUAL_URL'] = self.folder.absolute_url()
00247         directlyProvides(self.folder, INonStructuralFolder)
00248         view = self.folder.restrictedTraverse('@@plone')
00249         tabs = view.prepareObjectTabs()
00250         noLongerProvides(self.folder, INonStructuralFolder)
00251         self.assertEquals(0, len([t for t in tabs if t['id'] == 'folderContents']))
00252         self.assertEquals(['view'], [t['id'] for t in tabs if t['selected']])
        

Here is the call graph for this function:

Definition at line 224 of file testPloneView.py.

00224 
00225     def testPrepareObjectTabsOnPortalRoot(self):
00226         del self.app.REQUEST.__annotations__
00227         self.loginAsPortalOwner()
00228         self.app.REQUEST['ACTUAL_URL'] = self.portal.absolute_url()
00229         view = self.portal.restrictedTraverse('@@plone')
00230         tabs = view.prepareObjectTabs()
00231         self.assertEquals(tabs[0]['id'], 'folderContents')
00232         self.assertEquals(['view'], [t['id'] for t in tabs if t['selected']])
        

Here is the call graph for this function:

Definition at line 52 of file testPloneView.py.

00052 
00053     def testPUtils(self):
00054         pass

Definition at line 61 of file testPloneView.py.

00061 
00062     def testSynTool(self):
00063         assert isinstance(self.view._data['syntool'], SyndicationTool)

Definition at line 67 of file testPloneView.py.

00067 
00068     def testToLocalizedTime(self):
00069         localdate = self.view.toLocalizedTime
00070         value = localdate('Mar 9, 1997 1:45pm', long_format=True)
00071         self.assertEquals(value, 'Mar 09, 1997 01:45 PM')

Definition at line 218 of file testPloneView.py.

00218 
00219     def testUniqueIndexIterator(self):
00220         iterator = self.view._data['uniqueItemIndex']
00221         self.assertEquals(0, iterator.next())
00222         self.assertEquals(1, iterator.next())
00223         self.assertEquals(2, iterator.next())
        

Definition at line 37 of file testPloneView.py.

00037 
00038     def testUTool(self):
00039         assert isinstance(self.view._data['utool'], URLTool)

Definition at line 55 of file testPloneView.py.

00055 
00056     def testWTool(self):
00057         assert isinstance(self.view._data['wtool'], WorkflowTool)


Member Data Documentation

Definition at line 34 of file testPloneView.py.


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