Back to index

plone3  3.1.7
testBrowserDefaultScripts.py
Go to the documentation of this file.
00001 #
00002 # Test methods used to make browser-default-mixin enabled display menu work
00003 #
00004 
00005 from Products.CMFPlone.tests import PloneTestCase
00006 from Products.CMFPlone.utils import _createObjectByType
00007 
00008 
00009 class TestBrowserDefaultScripts(PloneTestCase.PloneTestCase):
00010     """Tests the browser default and folder-default page scripts"""
00011 
00012     def testNoIndexHtml(self):
00013         # A folder shouldn't have an index_html object at instantiation time
00014         self.failIf(self.folder.hasIndexHtml())
00015 
00016     def testHasIndexHtml(self):
00017         # Make sure we can determine if a container contains a index_html object
00018         self.folder.invokeFactory('Document', 'index_html', 
00019                                   title='Test index')
00020         self.failUnless(self.folder.hasIndexHtml())
00021 
00022     def testGetSelectableViewsWithViews(self):
00023         # Assume folders have at least two possible views to chose from
00024         views = [v[0] for v in self.folder.getSelectableViews()]
00025         self.failUnless(views)
00026         self.failUnless('folder_listing' in views)
00027         self.failUnless('atct_album_view' in views)
00028 
00029     def testGetSelectableViewsWithoutViews(self):
00030         # Assume documents have only one view
00031         self.folder.invokeFactory('Document', 'test', 
00032                                   title='Test default page')
00033         doc = getattr(self.folder, 'test')
00034         self.failIf(doc.getSelectableViews())
00035 
00036     def testSetDefaultPageWithoutPage(self):
00037         # Make sure we can't define a default page if no object in folder
00038         self.failUnless(self.folder.canSelectDefaultPage())
00039 
00040     def testSetDefaultPageWithPage(self):
00041         # Make sure we can define a Document as default page
00042         self.folder.invokeFactory('Document', 'test', 
00043                                   title='Test default page')
00044         self.failUnless(self.folder.canSelectDefaultPage())
00045         self.folder.saveDefaultPage('test')
00046         self.failUnless(self.folder.test.isDefaultPageInFolder())
00047 
00048     def testGetViewTemplateId(self):
00049         self.folder.setLayout('atct_album_view')
00050         self.assertEqual(self.folder.getViewTemplateId(), 'atct_album_view')
00051 
00052 
00053 def test_suite():
00054     from unittest import TestSuite, makeSuite
00055     suite = TestSuite()
00056     suite.addTest(makeSuite(TestBrowserDefaultScripts))
00057     return suite