Back to index

plone3  3.1.7
Public Member Functions
CMFPlone.tests.testBrowserDefault.TestPortalBrowserDefault Class Reference
Inheritance diagram for CMFPlone.tests.testBrowserDefault.TestPortalBrowserDefault:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.tests.testBrowserDefault.TestPortalBrowserDefault:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def failIfDiff
def testCall
def testDefaultViews
def testCanSetLayout
def testSetLayout
def testCanSetDefaultPage
def testSetDefaultPage
def testSetDefaultPageUpdatesCatalog
def testSetLayoutUnsetsDefaultPage
def testMissingTemplatesIgnored
def testMissingPageIgnored
def testTemplateTitles
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Detailed Description

Test the BrowserDefaultMixin as implemented by the root portal object

Definition at line 252 of file testBrowserDefault.py.


Member Function Documentation

Definition at line 256 of file testBrowserDefault.py.

00256 
00257     def afterSetUp(self):
00258         self.setRoles(['Manager'])
00259         
00260         # Make sure we have the front page; the portal generator should take 
00261         # care of this, but let's not be dependent on that in the test
00262         if not 'front-page' in self.portal.objectIds():
00263             self.portal.invokeFactory('Document', 'front-page',
00264                                       title = 'Welcome to Plone')
00265         self.portal.setDefaultPage('front-page')
00266     
00267         # Also make sure we have folder_listing as a template
00268         self.portal.getTypeInfo().manage_changeProperties(view_methods =
00269                                         ['folder_listing'],
00270                                         default_view = 'folder_listing')
            

Here is the call graph for this function:

Compare two bodies of text.  If they are not the same, fail and output the diff

Definition at line 271 of file testBrowserDefault.py.

00271 
00272     def failIfDiff(self, text1, text2):
00273         """
00274         Compare two bodies of text.  If they are not the same, fail and output the diff
00275         """
00276         if text1 != text2:
00277             diff = difflib.unified_diff(text1.split("\n"), text2.split("\n"))
00278             self.fail("\n".join([line for line in diff]))
00279 

Here is the call graph for this function:

Here is the caller graph for this function:

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 280 of file testBrowserDefault.py.

00280 
00281     def testCall(self):
00282         self.portal.setLayout('folder_listing')
00283         resolved = self.portal()
00284         target = self.portal.unrestrictedTraverse('folder_listing')()
00285         self.failIfDiff(resolved, target)
            

Here is the call graph for this function:

Definition at line 319 of file testBrowserDefault.py.

00319 
00320     def testCanSetDefaultPage(self):
00321         self.failUnless(self.portal.canSetDefaultPage())
00322         self.portal.invokeFactory('Document', 'ad')
00323         self.failIf(self.portal.ad.canSetDefaultPage()) # Not folderish
00324         self.portal.manage_permission("Modify view template", [], 0)
00325         self.failIf(self.portal.canSetDefaultPage()) # Not permitted
        

Definition at line 295 of file testBrowserDefault.py.

00295 
00296     def testCanSetLayout(self):
00297         self.failUnless(self.portal.canSetLayout())
00298         self.portal.manage_permission("Modify view template", [], 0)
00299         self.failIf(self.portal.canSetLayout()) # Not permitted
    

Definition at line 286 of file testBrowserDefault.py.

00286 
00287     def testDefaultViews(self):
00288         self.assertEqual(self.portal.getLayout(), 'folder_listing')
00289         self.assertEqual(self.portal.getDefaultPage(), 'front-page')
00290         self.assertEqual(self.portal.defaultView(), 'front-page')
00291         self.assertEqual(self.portal.getDefaultLayout(), 'folder_listing')
00292         layoutKeys = [v[0] for v in self.portal.getAvailableLayouts()]
00293         self.failUnless('folder_listing' in layoutKeys)
00294         self.assertEqual(self.portal.__browser_default__(None), (self.portal, ['front-page',]))
        

Here is the call graph for this function:

Definition at line 377 of file testBrowserDefault.py.

00377 
00378     def testMissingPageIgnored(self):
00379         self.portal.setDefaultPage('inexistent')
00380         self.assertEqual(self.portal.getDefaultPage(), None)
00381         self.assertEqual(self.portal.defaultView(), 'folder_listing')
00382         self.assertEqual(self.portal.__browser_default__(None), (self.portal, ['folder_listing',]))

Here is the call graph for this function:

Definition at line 372 of file testBrowserDefault.py.

00372 
00373     def testMissingTemplatesIgnored(self):
00374         self.portal.getTypeInfo().manage_changeProperties(view_methods = ['folder_listing', 'foo'])
00375         views = [v[0] for v in self.portal.getAvailableLayouts()]
00376         self.failUnless(views == ['folder_listing'])

Definition at line 326 of file testBrowserDefault.py.

00326 
00327     def testSetDefaultPage(self):
00328         self.portal.invokeFactory('Document', 'ad')
00329         self.portal.setDefaultPage('ad')
00330         self.assertEqual(self.portal.getDefaultPage(), 'ad')
00331         self.assertEqual(self.portal.defaultView(), 'ad')
00332         self.assertEqual(self.portal.__browser_default__(None), (self.portal, ['ad',]))
00333 
00334         # still have layout settings
00335         self.assertEqual(self.portal.getLayout(), 'folder_listing')
00336         self.assertEqual(self.portal.getDefaultLayout(), 'folder_listing')
00337         layoutKeys = [v[0] for v in self.portal.getAvailableLayouts()]
00338         self.failUnless('folder_listing' in layoutKeys)

Here is the call graph for this function:

Definition at line 339 of file testBrowserDefault.py.

00339 
00340     def testSetDefaultPageUpdatesCatalog(self):
00341         # Ensure that Default page changes update the catalog
00342         cat = getToolByName(self.portal, "portal_catalog")
00343         self.portal.invokeFactory('Document', 'ad')
00344         self.portal.invokeFactory('Document', 'other')
00345         self.assertEqual(len(cat(getId=['ad','other'],is_default_page=True)), 0)
00346         self.portal.setDefaultPage('ad')
00347         self.assertEqual(len(cat(getId='ad',is_default_page=True)), 1)
00348         self.portal.setDefaultPage('other')
00349         self.assertEqual(len(cat(getId='other',is_default_page=True)), 1)
00350         self.assertEqual(len(cat(getId='ad',is_default_page=True)), 0)
00351         self.portal.setDefaultPage(None)
00352         self.assertEqual(len(cat(getId=['ad','other'],is_default_page=True)), 0)

Here is the call graph for this function:

Definition at line 300 of file testBrowserDefault.py.

00300 
00301     def testSetLayout(self):
00302         self.portal.setLayout('folder_listing')
00303         self.assertEqual(self.portal.getLayout(), 'folder_listing')
00304         self.assertEqual(self.portal.getDefaultPage(), None)
00305         self.assertEqual(self.portal.defaultView(), 'folder_listing')
00306         self.assertEqual(self.portal.getDefaultLayout(), 'folder_listing')
00307         layoutKeys = [v[0] for v in self.portal.getAvailableLayouts()]
00308         self.failUnless('folder_listing' in layoutKeys)
00309         
00310         view = self.portal.view()
00311         browserDefault = self.portal.__browser_default__(None)[1][0]
00312         browserDefaultResolved = self.portal.unrestrictedTraverse(browserDefault)()
00313         template = self.portal.defaultView()
00314         templateResolved = self.portal.unrestrictedTraverse(template)()
00315         
00316         self.failIfDiff(view, browserDefaultResolved)
00317         self.failIfDiff(view, templateResolved)
00318 
        

Here is the call graph for this function:

Definition at line 353 of file testBrowserDefault.py.

00353 
00354     def testSetLayoutUnsetsDefaultPage(self):
00355         self.portal.invokeFactory('Document', 'ad')
00356         self.portal.setDefaultPage('ad')
00357         self.assertEqual(self.portal.getDefaultPage(), 'ad')
00358         self.assertEqual(self.portal.defaultView(), 'ad')
00359         self.portal.setLayout('folder_listing')
00360 
00361         self.failIfDiff(self.portal.getDefaultPage(), None)
00362         self.failIfDiff(self.portal.defaultView(), 'folder_listing')
00363 
00364         view = self.portal.view()
00365         browserDefault = self.portal.__browser_default__(None)[1][0]
00366         browserDefaultResolved = self.portal.unrestrictedTraverse(browserDefault)()
00367         template = self.portal.defaultView()
00368         templateResolved = self.portal.unrestrictedTraverse(template)()
00369 
00370         self.failIfDiff(view, browserDefaultResolved)
00371         self.failIfDiff(view, templateResolved)

Here is the call graph for this function:

Definition at line 383 of file testBrowserDefault.py.

00383 
00384     def testTemplateTitles(self):
00385         views = [v for v in self.portal.getAvailableLayouts() if v[0] == 'folder_listing']
00386         self.assertEqual(views[0][1], 'Standard view')
00387         try:
00388             folderListing = self.portal.unrestrictedTraverse('folder_listing')
00389             folderListing.title = 'foo'
00390             views = [v for v in self.portal.getAvailableLayouts() if v[0] == 'folder_listing']
00391             self.assertEqual(views[0][1], 'foo')
00392         finally:
00393             # Restore title to avoid side-effects
00394             folderListing.title = 'Standard view'
00395 


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