Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def beforeTearDown
def testFolderDeletion
def testCatalogIsUpdatedOnFolderDelete
def testDeleteMultiplePaths
def testNoErrorOnBadPaths
def testObjectDeleteFailureIsCleanedUp
def testGETRaisesUnauthorized
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 catalog

Detailed Description

Definition at line 101 of file testFolderButtons.py.


Member Function Documentation

Definition at line 104 of file testFolderButtons.py.

00104 
00105     def afterSetUp(self):
00106         self.catalog = self.portal.portal_catalog
00107         self.folder.invokeFactory('Folder', id='foo')
00108         self.folder.invokeFactory('Folder', id='bar')
00109         self.folder.foo.invokeFactory('Document', id='doc1')
00110         self.folder.bar.invokeFactory('Document', id='doc2')
00111         undeletable = Item('no_delete', 'Just Try!')
00112         # make it undeletable
00113         directlyProvides(undeletable, ICantBeDeleted)
00114         component.provideHandler(disallow_delete_handler, [ICantBeDeleted,
00115                                                            IObjectRemovedEvent])
00116         self.folder._setObject('no_delete', undeletable)
00117         # folder_delete requires a non-GET request
00118         self.setRequestMethod('POST')
00119         self.setupAuthenticator()

Definition at line 120 of file testFolderButtons.py.

00120 
00121     def beforeTearDown(self):
00122         # unregister our deletion event subscriber
00123         component.getSiteManager().unregisterHandler(disallow_delete_handler,
00124                                                      [ICantBeDeleted,
00125                                                       IObjectRemovedEvent])

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 133 of file testFolderButtons.py.

00133 
00134     def testCatalogIsUpdatedOnFolderDelete(self):
00135         # Make sure catalog gets updated
00136         doc_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00137         self.app.REQUEST.set('paths', [doc_path])
00138         self.folder.folder_delete()
00139         results = self.catalog(path=doc_path)
00140         self.failIf(results)

Definition at line 141 of file testFolderButtons.py.

00141 
00142     def testDeleteMultiplePaths(self):
00143         # Make sure deletion works for list of paths
00144         doc1_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00145         doc2_path = '/'.join(self.folder.bar.doc2.getPhysicalPath())
00146         self.app.REQUEST.set('paths', [doc1_path,doc2_path])
00147         self.folder.folder_delete()
00148         self.assertEqual(getattr(self.folder.foo, 'doc1', None), None)
00149         self.assertEqual(getattr(self.folder.bar, 'doc2', None), None)

Definition at line 126 of file testFolderButtons.py.

00126 
00127     def testFolderDeletion(self):
00128         # Make sure object gets deleted
00129         doc_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00130         self.app.REQUEST.set('paths', [doc_path])
00131         self.folder.folder_delete()
00132         self.assertEqual(getattr(self.folder.foo, 'doc1', None), None)

Definition at line 171 of file testFolderButtons.py.

00171 
00172     def testGETRaisesUnauthorized(self):
00173         # folder_delete requires a non-GET request and will fail otherwise
00174         self.setRequestMethod('GET')
00175         self.assertRaises(Forbidden, self.folder.folder_delete)
00176 
00177 

Here is the call graph for this function:

Definition at line 150 of file testFolderButtons.py.

00150 
00151     def testNoErrorOnBadPaths(self):
00152         # Ensure we don't fail on a bad path
00153         self.app.REQUEST.set('paths', ['/garbage/path'])
00154         self.folder.folder_delete()

Definition at line 155 of file testFolderButtons.py.

00155 
00156     def testObjectDeleteFailureIsCleanedUp(self):
00157         doc1_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00158         doc2_path = '/'.join(self.folder.bar.doc2.getPhysicalPath())
00159         undeletable_path = '/'.join(self.folder.no_delete.getPhysicalPath())
00160         self.app.REQUEST.set('paths', [doc1_path, undeletable_path, doc2_path])
00161         self.folder.folder_delete()
00162         # The two deletable object should have been deleted
00163         self.assertEqual(getattr(self.folder.foo, 'doc1', None), None)
00164         self.assertEqual(getattr(self.folder.bar, 'doc2', None), None)
00165         # but the undeletable object will still be in place
00166         undeletable = getattr(self.folder, 'no_delete', None)
00167         self.failIfEqual(undeletable, None)
00168         # manage_beforeDelete will have been called, but the change it
00169         # makes should have been rolled back
00170         self.failIf(hasattr(undeletable, 'delete_attempted'))

Here is the call graph for this function:


Member Data Documentation

Definition at line 105 of file testFolderButtons.py.


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