Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
ATContentTypes.tests.test_browserdefaultmixin.TestBrowserDefaultMixin Class Reference
Inheritance diagram for ATContentTypes.tests.test_browserdefaultmixin.TestBrowserDefaultMixin:
Inheritance graph
[legend]
Collaboration diagram for ATContentTypes.tests.test_browserdefaultmixin.TestBrowserDefaultMixin:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def test_isMixedIn
def test_defaultFolderViews
def test_canSetLayout
def test_setLayout
def test_canSetDefaultPage
def test_setDefaultPage
def test_setDefaultPageUpdatesCatalog
def test_setLayoutUnsetsDefaultPage
def test_inherit_parent_layout
def test_inherit_parent_layout_if_different_type

Public Attributes

 af

Static Public Attributes

string folder_type = 'Folder'
string image_type = 'Image'
string document_type = 'Document'
string file_type = 'File'

Detailed Description

Definition at line 36 of file test_browserdefaultmixin.py.


Member Function Documentation

Definition at line 42 of file test_browserdefaultmixin.py.

00042 
00043     def afterSetUp(self):
00044         atcttestcase.ATCTSiteTestCase.afterSetUp(self)
00045         self.folder.invokeFactory(self.folder_type, id='af')
00046         # an ATCT folder
00047         self.af = self.folder.af
00048         # Needed because getFolderContents needs to clone the REQUEST
00049         self.app.REQUEST.set('PARENTS', [self.app])

Definition at line 93 of file test_browserdefaultmixin.py.

00093 
00094     def test_canSetDefaultPage(self):
00095         self.failUnless(self.af.canSetDefaultPage())
00096         self.af.invokeFactory('Document', 'ad')
00097         self.failIf(self.af.ad.canSetDefaultPage()) # Not folderish
00098         self.portal.manage_permission(permission.ModifyViewTemplate, [], 0)
00099         self.failIf(self.af.canSetDefaultPage()) # Not permitted

Definition at line 72 of file test_browserdefaultmixin.py.

00072 
00073     def test_canSetLayout(self):
00074         self.failUnless(self.af.canSetLayout())
00075         self.af.invokeFactory('Document', 'ad')
00076         self.portal.manage_permission(permission.ModifyViewTemplate, [], 0)
00077         self.failIf(self.af.canSetLayout()) # Not permitted

Definition at line 58 of file test_browserdefaultmixin.py.

00058 
00059     def test_defaultFolderViews(self):
00060         self.assertEqual(self.af.getLayout(), 'folder_listing')
00061         self.assertEqual(self.af.getDefaultPage(), None)
00062         self.assertEqual(self.af.defaultView(), 'folder_listing')
00063         self.assertEqual(self.af.getDefaultLayout(), 'folder_listing')
00064         layoutKeys = [v[0] for v in self.af.getAvailableLayouts()]
00065         self.failUnless('folder_listing' in layoutKeys)
00066         self.failUnless('atct_album_view' in layoutKeys)
00067 
00068         resolved = self.af.unrestrictedTraverse('folder_listing')()
00069         browserDefault = self.af.__browser_default__(None)[1][0]
00070         browserDefaultResolved = self.af.unrestrictedTraverse(browserDefault)()
00071         self.assertEqual(resolved, browserDefaultResolved)

Definition at line 143 of file test_browserdefaultmixin.py.

00143 
00144     def test_inherit_parent_layout(self):
00145         # Check to see if subobjects of the same type inherit the layout set
00146         # on the parent object
00147         af = self.af
00148         af.setLayout('folder_tabular_view')
00149         af.invokeFactory('Folder', 'subfolder', title='folder 2')
00150         subfolder = af.subfolder
00151         self.assertEqual(subfolder.getLayout(), 'folder_tabular_view')

Definition at line 152 of file test_browserdefaultmixin.py.

00152 
00153     def test_inherit_parent_layout_if_different_type(self):
00154         # Objects will not inherit the layout if parent object is a different
00155         # type
00156         af = self.af
00157         af.setLayout('folder_tabular_view')
00158         # Create a subobject of a different type (need to enable LPF globally)
00159         lpf_fti = self.portal.portal_types['Large Plone Folder']
00160         lpf_fti.global_allow = 1
00161         af.invokeFactory('Large Plone Folder', 'subfolder', title='folder 2')
00162         subfolder = af.subfolder
00163         self.failIf(subfolder.getLayout() == 'folder_tabular_view')
00164 
00165 tests.append(TestBrowserDefaultMixin)

Definition at line 50 of file test_browserdefaultmixin.py.

00050 
00051     def test_isMixedIn(self):
00052         self.failUnless(isinstance(self.af, BrowserDefaultMixin),
00053                         "ISelectableBrowserDefault was not mixed in to ATFolder")
00054         self.failUnless(ZopeTwoISelectableBrowserDefault.isImplementedBy(self.af),
00055                         "ISelectableBrowserDefault not implemented by ATFolder instance")
00056         self.failUnless(ISelectableBrowserDefault.providedBy(self.af),
00057                         "ISelectableBrowserDefault not implemented by ATFolder instance")

Definition at line 100 of file test_browserdefaultmixin.py.

00100 
00101     def test_setDefaultPage(self):
00102         self.af.invokeFactory('Document', 'ad')
00103         self.af.setDefaultPage('ad')
00104         self.assertEqual(self.af.getDefaultPage(), 'ad')
00105         self.assertEqual(self.af.defaultView(), 'ad')
00106         self.assertEqual(self.af.__browser_default__(None), (self.af, ['ad',]))
00107 
00108         # still have layout settings
00109         self.assertEqual(self.af.getLayout(), 'folder_listing')
00110         self.assertEqual(self.af.getDefaultLayout(), 'folder_listing')
00111         layoutKeys = [v[0] for v in self.af.getAvailableLayouts()]
00112         self.failUnless('folder_listing' in layoutKeys)
00113         self.failUnless('atct_album_view' in layoutKeys)

Definition at line 114 of file test_browserdefaultmixin.py.

00114 
00115     def test_setDefaultPageUpdatesCatalog(self):
00116         # Ensure that Default page changes update the catalog
00117         cat = self.portal.portal_catalog
00118         self.af.invokeFactory('Document', 'ad')
00119         self.af.invokeFactory('Document', 'other')
00120         self.assertEqual(len(cat(getId=['ad','other'],is_default_page=True)), 0)
00121         self.af.setDefaultPage('ad')
00122         self.assertEqual(len(cat(getId='ad',is_default_page=True)), 1)
00123         self.af.setDefaultPage('other')
00124         self.assertEqual(len(cat(getId='other',is_default_page=True)), 1)
00125         self.assertEqual(len(cat(getId='ad',is_default_page=True)), 0)
00126         self.af.setDefaultPage(None)
00127         self.assertEqual(len(cat(getId=['ad','other'],is_default_page=True)), 0)
00128         

Definition at line 78 of file test_browserdefaultmixin.py.

00078 
00079     def test_setLayout(self):
00080         self.af.setLayout('atct_album_view')
00081         self.assertEqual(self.af.getLayout(), 'atct_album_view')
00082         self.assertEqual(self.af.getDefaultPage(), None)
00083         self.assertEqual(self.af.defaultView(), 'atct_album_view')
00084         self.assertEqual(self.af.getDefaultLayout(), 'folder_listing')
00085         layoutKeys = [v[0] for v in self.af.getAvailableLayouts()]
00086         self.failUnless('folder_listing' in layoutKeys)
00087         self.failUnless('atct_album_view' in layoutKeys)
00088 
00089         resolved = self.af.unrestrictedTraverse('atct_album_view')()
00090         browserDefault = self.af.__browser_default__(None)[1][0]
00091         browserDefaultResolved = self.af.unrestrictedTraverse(browserDefault)()
00092         self.assertEqual(resolved, browserDefaultResolved)

Definition at line 129 of file test_browserdefaultmixin.py.

00129 
00130     def test_setLayoutUnsetsDefaultPage(self):
00131         layout = 'atct_album_view'
00132         self.af.invokeFactory('Document', 'ad')
00133         self.af.setDefaultPage('ad')
00134         self.assertEqual(self.af.getDefaultPage(), 'ad')
00135         self.assertEqual(self.af.defaultView(), 'ad')
00136         self.af.setLayout(layout)
00137         self.assertEqual(self.af.getDefaultPage(), None)
00138         self.assertEqual(self.af.defaultView(), layout)
00139         resolved = self.af.unrestrictedTraverse(layout)()
00140         browserDefault = self.af.__browser_default__(None)[1][0]
00141         browserDefaultResolved = self.af.unrestrictedTraverse(browserDefault)()
00142         self.assertEqual(resolved, browserDefaultResolved)


Member Data Documentation

Definition at line 46 of file test_browserdefaultmixin.py.

Definition at line 39 of file test_browserdefaultmixin.py.

Definition at line 40 of file test_browserdefaultmixin.py.

Definition at line 37 of file test_browserdefaultmixin.py.

Definition at line 38 of file test_browserdefaultmixin.py.


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