Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes
CMFCore.tests.test_PortalFolder.PortalFolderTests Class Reference
Inheritance diagram for CMFCore.tests.test_PortalFolder.PortalFolderTests:
Inheritance graph
[legend]
Collaboration diagram for CMFCore.tests.test_PortalFolder.PortalFolderTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def test_z2interfaces
def test_z3interfaces
def test_contents_methods
def test_deletePropagation
def test_manageDelObjects
def test_catalogUnindexAndIndex
def test_portalfolder_cataloging
def test_tracker261
def test_manageAddFolder
def test_contentPasteAllowedTypes
def test_setObjectRaisesBadRequest
def test__checkId_Duplicate
def test__checkId_PortalRoot
def test__checkId_MethodAlias
def test__checkId_starting_with_dot
def test__checkId_Five
def test_checkIdAvailableCatchesBadRequest

Public Attributes

 site

Static Public Attributes

 layer = FunctionalZCMLLayer

Private Member Functions

def _getTargetClass
def _makeOne

Private Attributes

 _context
 _grabbed_with

Detailed Description

Definition at line 116 of file test_PortalFolder.py.


Member Function Documentation

Definition at line 120 of file test_PortalFolder.py.

00120 
00121     def _getTargetClass(self):
00122         from Products.CMFCore.PortalFolder import PortalFolder
00123 
00124         return PortalFolder

def CMFCore.tests.test_PortalFolder.PortalFolderTests._makeOne (   self,
  id,
  args,
  kw 
) [private]

Definition at line 125 of file test_PortalFolder.py.

00125 
00126     def _makeOne(self, id, *args, **kw):
00127         return self.site._setObject(id,
00128                                     self._getTargetClass()(id, *args, **kw))

Here is the call graph for this function:

Definition at line 129 of file test_PortalFolder.py.

00129 
00130     def setUp(self):
00131         SecurityTest.setUp(self)
00132         self.site = DummySite('site').__of__(self.root)

Definition at line 367 of file test_PortalFolder.py.

00367 
00368     def test__checkId_Duplicate(self):
00369         #
00370         #   _checkId() should raise BadRequest on duplicate id
00371         #
00372         test = self._makeOne('test')
00373         test._setObject('foo', DummyContent('foo'))
00374         self.assertRaises(BadRequest, test._checkId, 'foo')

Here is the call graph for this function:

Definition at line 410 of file test_PortalFolder.py.

00410 
00411     def test__checkId_Five(self):
00412         test = self._makeOne('test')
00413         self.assertRaises(BadRequest, test._checkId, '@@view.html')
00414         self.assertRaises(BadRequest, test._checkId, '++resource++icon.png')

Here is the call graph for this function:

Definition at line 382 of file test_PortalFolder.py.

00382 
00383     def test__checkId_MethodAlias(self):
00384         test = self._makeOne('test')
00385         test._setPortalTypeName('Dummy Content 15')
00386         ttool = self.site._setObject('portal_types', TypesTool())
00387         ttool._setObject('Dummy Content 15', FTI(**FTIDATA_CMF15[0]))
00388         acl_users = self.site._setObject('acl_users', DummyUserFolder())
00389         test._checkId('view.html')
00390         newSecurityManager(None, acl_users.user_foo)
00391         self.assertRaises(BadRequest, test._checkId, 'view.html')

Here is the call graph for this function:

Definition at line 375 of file test_PortalFolder.py.

00375 
00376     def test__checkId_PortalRoot(self):
00377         test = self._makeOne('test')
00378         acl_users = self.site._setObject('acl_users', DummyUserFolder())
00379         test._checkId('acl_users')
00380         newSecurityManager(None, acl_users.user_foo)
00381         self.assertRaises(BadRequest, test._checkId, 'acl_users')

Here is the call graph for this function:

Definition at line 392 of file test_PortalFolder.py.

00392 
00393     def test__checkId_starting_with_dot(self):
00394         #
00395         # doted prefixed names at the root of the portal can be overriden
00396         #
00397 
00398         # Create a .foo at the root
00399         self.site._setObject('.foo', DummyContent('.foo'))
00400 
00401         # Create a sub-folder
00402         sub = self._makeOne('sub')
00403 
00404         # It should be possible to create another .foo object in the
00405         # sub-folder
00406         acl_users = self.site._setObject('acl_users', DummyUserFolder())
00407         newSecurityManager(None, acl_users.user_foo)
00408 
00409         self.assert_(sub.checkIdAvailable('.foo'))

Here is the call graph for this function:

Definition at line 213 of file test_PortalFolder.py.

00213 
00214     def test_catalogUnindexAndIndex(self):
00215         #
00216         # Test is a new object does get cataloged upon _setObject
00217         # and uncataloged upon manage_deleteObjects
00218         #
00219         test = self._makeOne('test')
00220         ttool = self.site._setObject( 'portal_types', TypesTool() )
00221         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
00222         self.assertEqual( len(ctool), 0 )
00223 
00224         test._setObject( 'foo', DummyContent( 'foo' , catalog=1 ) )
00225         foo = test.foo
00226         self.failUnless( foo.after_add_called )
00227         self.failIf( foo.before_delete_called )
00228         self.assertEqual( len(ctool), 1 )
00229 
00230         foo.reset()
00231         test._delObject('foo')
00232         self.failIf( foo.after_add_called )
00233         self.failUnless( foo.before_delete_called )
00234         self.assertEqual( len(ctool), 0 )

Here is the call graph for this function:

Definition at line 415 of file test_PortalFolder.py.

00415 
00416     def test_checkIdAvailableCatchesBadRequest(self):
00417         #
00418         #   checkIdAvailable() should catch BadRequest
00419         #
00420         test = self._makeOne('test')
00421         test._setObject('foo', DummyContent('foo'))
00422         self.failIf(test.checkIdAvailable('foo'))
00423 

Here is the call graph for this function:

Definition at line 331 of file test_PortalFolder.py.

00331 
00332     def test_contentPasteAllowedTypes(self):
00333         #
00334         #   _verifyObjectPaste() should honor allowed content types
00335         #
00336         ttool = self.site._setObject( 'portal_types', TypesTool() )
00337         fti = FTIDATA_DUMMY[0].copy()
00338         ttool._setObject( 'Dummy Content', FTI(**fti) )
00339         ttool._setObject( 'Folder', FTI(**fti) )
00340         sub1 = self._makeOne('sub1')
00341         sub1._setObject( 'dummy', DummyContent( 'dummy' ) )
00342         sub2 = self._makeOne('sub2')
00343         sub2.all_meta_types = extra_meta_types()
00344 
00345         # Allow adding of Dummy Content
00346         ttool.Folder.manage_changeProperties(filter_content_types=False)
00347 
00348         # Copy/paste should work fine
00349         cookie = sub1.manage_copyObjects( ids = ['dummy'] )
00350         sub2.manage_pasteObjects( cookie )
00351 
00352         # Disallow adding of Dummy Content
00353         ttool.Folder.manage_changeProperties(filter_content_types=True)
00354 
00355         # Now copy/paste should raise a ValueError
00356         cookie = sub1.manage_copyObjects( ids = ( 'dummy', ) )
00357         self.assertRaises( ValueError, sub2.manage_pasteObjects, cookie )

Here is the call graph for this function:

Definition at line 145 of file test_PortalFolder.py.

00145 
00146     def test_contents_methods(self):
00147         ttool = self.site._setObject( 'portal_types', TypesTool() )
00148         f = self._makeOne('foo')
00149         self.assertEqual( f.objectValues(), [] )
00150         self.assertEqual( f.contentIds(), [] )
00151         self.assertEqual( f.contentItems(), [] )
00152         self.assertEqual( f.contentValues(), [] )
00153         self.assertEqual( f.listFolderContents(), [] )
00154         self.assertEqual( f.listDAVObjects(), [] )
00155 
00156         f._setObject('sub1', DummyContent('sub1') )
00157         self.assertEqual( f.objectValues(), [f.sub1] )
00158         self.assertEqual( f.contentIds(), [] )
00159         self.assertEqual( f.contentItems(), [] )
00160         self.assertEqual( f.contentValues(), [] )
00161         self.assertEqual( f.listFolderContents(), [] )
00162         self.assertEqual( f.listDAVObjects(), [f.sub1] )
00163 
00164         fti = FTIDATA_DUMMY[0].copy()
00165         ttool._setObject( 'Dummy Content', FTI(**fti) )
00166         self.assertEqual( f.objectValues(), [f.sub1] )
00167         self.assertEqual( f.contentIds(), ['sub1'] )
00168         self.assertEqual( f.contentItems(), [ ('sub1', f.sub1) ] )
00169         self.assertEqual( f.contentValues(), [f.sub1] )
00170         self.assertEqual( f.listFolderContents(), [f.sub1] )
00171         self.assertEqual( f.listDAVObjects(), [f.sub1] )
00172 
00173         f._setObject('hidden_sub2', DummyContent('hidden_sub2') )
00174         self.assertEqual( f.objectValues(), [f.sub1, f.hidden_sub2] )
00175         self.assertEqual( f.contentIds(), ['sub1', 'hidden_sub2'] )
00176         self.assertEqual( f.contentItems(), [ ('sub1', f.sub1),
00177                                             ('hidden_sub2', f.hidden_sub2) ] )
00178         self.assertEqual( f.contentValues(), [f.sub1, f.hidden_sub2] )
00179         self.assertEqual( f.listFolderContents(), [f.sub1] )
00180         self.assertEqual( f.listDAVObjects(), [f.sub1, f.hidden_sub2] )

Here is the call graph for this function:

Definition at line 181 of file test_PortalFolder.py.

00181 
00182     def test_deletePropagation(self):
00183         test = self._makeOne('test')
00184         foo = DummyContent('foo')
00185         foo.reset()
00186         self.failIf( foo.after_add_called )
00187         self.failIf( foo.before_delete_called )
00188 
00189         test._setObject('foo', foo)
00190         self.failUnless( foo.after_add_called )
00191         self.failIf( foo.before_delete_called )
00192 
00193         foo.reset()
00194         test._delObject('foo')
00195         self.failIf( foo.after_add_called )
00196         self.failUnless( foo.before_delete_called )
00197 
00198         foo.reset()
00199         test._setObject('foo', foo)
00200         test._delOb('foo')    # doesn't propagate
00201         self.failUnless( foo.after_add_called )
00202         self.failIf( foo.before_delete_called )

Here is the call graph for this function:

Definition at line 276 of file test_PortalFolder.py.

00276 
00277     def test_manageAddFolder(self):
00278         #
00279         #   Does MKDIR/MKCOL intercept work?
00280         #
00281         from Products.CMFCore.PortalFolder import PortalFolder
00282 
00283         test = self._makeOne('test')
00284 
00285         ttool = self.site._setObject( 'portal_types', TypesTool() )
00286         ttool._setObject( 'Folder'
00287                         , FTI( id='Folder'
00288                              , title='Folder or Directory'
00289                              , meta_type=PortalFolder.meta_type
00290                              , factory='cmf.folder'
00291                              , filter_content_types=0
00292                              )
00293                         )
00294         ttool._setObject( 'Grabbed'
00295                         , FTI( 'Grabbed'
00296                              , title='Grabbed Content'
00297                              , meta_type=PortalFolder.meta_type
00298                              , factory='cmf.folder'
00299                              )
00300                         )
00301 
00302         # First, test default behavior
00303         test.manage_addFolder(id='simple', title='Simple')
00304         self.assertEqual( test.simple.getPortalTypeName(), 'Folder' )
00305         self.assertEqual( test.simple.Type(), 'Folder or Directory' )
00306         self.assertEqual( test.simple.getId(), 'simple' )
00307         self.assertEqual( test.simple.Title(), 'Simple' )
00308 
00309         # Now, test overridden behavior
00310         ttool.Folder.setMethodAliases( {'mkdir': 'grabbed'} )
00311 
00312         class Grabbed:
00313 
00314             _grabbed_with = None
00315 
00316             def __init__( self, context ):
00317                 self._context = context
00318 
00319             def __call__( self, id ):
00320                 self._grabbed_with = id
00321                 self._context._setOb( id, PortalFolder( id ) )
00322                 self._context._getOb( id )._setPortalTypeName( 'Grabbed' )
00323 
00324         self.root.grabbed = Grabbed(test)
00325 
00326         test.manage_addFolder(id='indirect', title='Indirect')
00327         self.assertEqual( test.indirect.getPortalTypeName(), 'Grabbed' )
00328         self.assertEqual( test.indirect.Type(), 'Grabbed Content' )
00329         self.assertEqual( test.indirect.getId(), 'indirect' )
00330         self.assertEqual( test.indirect.Title(), 'Indirect' )

Here is the call graph for this function:

Definition at line 203 of file test_PortalFolder.py.

00203 
00204     def test_manageDelObjects(self):
00205         test = self._makeOne('test')
00206         foo = DummyContent('foo')
00207 
00208         test._setObject('foo', foo)
00209         foo.reset()
00210         test.manage_delObjects( ids=['foo'] )
00211         self.failIf( foo.after_add_called )
00212         self.failUnless( foo.before_delete_called )

Here is the call graph for this function:

Definition at line 235 of file test_PortalFolder.py.

00235 
00236     def test_portalfolder_cataloging(self):
00237         #
00238         # Test to ensure a portal folder itself is *not* cataloged upon
00239         # instantiation (Tracker issue 309)
00240         #
00241         ttool = self.site._setObject( 'portal_types', TypesTool() )
00242         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
00243         wftool = self.site._setObject( 'portal_workflow', WorkflowTool() )
00244         test = self._makeOne('test')
00245         wftool.notifyCreated(test)
00246         self.assertEqual( len(ctool), 0 )

Here is the call graph for this function:

Definition at line 358 of file test_PortalFolder.py.

00358 
00359     def test_setObjectRaisesBadRequest(self):
00360         #
00361         #   _setObject() should raise BadRequest on duplicate id
00362         #
00363         test = self._makeOne('test')
00364         test._setObject('foo', DummyContent('foo'))
00365         self.assertRaises(BadRequest, test._setObject, 'foo',
00366                                       DummyContent('foo'))

Here is the call graph for this function:

Definition at line 247 of file test_PortalFolder.py.

00247 
00248     def test_tracker261(self):
00249         #
00250         #   Tracker issue #261 says that content in a deleted folder
00251         #   is not being uncatalogued.  Try creating a subfolder with
00252         #   content object, and test.
00253         #
00254         from Products.CMFCore.PortalFolder import PortalFolder
00255 
00256         test = self._makeOne('test')
00257         ttool = self.site._setObject( 'portal_types', TypesTool() )
00258         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
00259         self.assertEqual( len(ctool), 0 )
00260 
00261         test._setObject( 'sub', PortalFolder( 'sub', '' ) )
00262         sub = test.sub
00263 
00264         sub._setObject( 'foo', DummyContent( 'foo', catalog=1 ) )
00265         foo = sub.foo
00266 
00267         self.failUnless( foo.after_add_called )
00268         self.failIf( foo.before_delete_called )
00269         self.assertEqual( len(ctool), 1 )
00270 
00271         foo.reset()
00272         test._delObject('sub')
00273         self.failIf( foo.after_add_called )
00274         self.failUnless( foo.before_delete_called )
00275         self.assertEqual( len(ctool), 0 )

Here is the call graph for this function:

Definition at line 133 of file test_PortalFolder.py.

00133 
00134     def test_z2interfaces(self):
00135         from Interface.Verify import verifyClass
00136         from OFS.IOrderSupport import IOrderedContainer
00137 
00138         verifyClass(IOrderedContainer, self._getTargetClass())

Here is the call graph for this function:

Definition at line 139 of file test_PortalFolder.py.

00139 
00140     def test_z3interfaces(self):
00141         from zope.interface.verify import verifyClass
00142         from OFS.interfaces import IOrderedContainer
00143 
00144         verifyClass(IOrderedContainer, self._getTargetClass())

Here is the call graph for this function:


Member Data Documentation

Definition at line 316 of file test_PortalFolder.py.

Definition at line 319 of file test_PortalFolder.py.

Definition at line 118 of file test_PortalFolder.py.

Definition at line 131 of file test_PortalFolder.py.


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