Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def testFolderPublishing
def testCatalogIsUpdatedOnFolderPublish
def testPublishMultiplePaths
def testNoErrorOnBadPaths
def testPublishFailureIsCleanedUp
def testGETRaises
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 catalog
 wtool

Detailed Description

Definition at line 178 of file testFolderButtons.py.


Member Function Documentation

Definition at line 182 of file testFolderButtons.py.

00182 
00183     def afterSetUp(self):
00184         self.catalog = self.portal.portal_catalog
00185         self.wtool = self.portal.portal_workflow
00186         self.folder.invokeFactory('Folder', id='foo')
00187         self.folder.invokeFactory('Folder', id='bar')
00188         self.folder.foo.invokeFactory('Document', id='doc1')
00189         self.folder.bar.invokeFactory('Document', id='doc2')
00190         self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
00191         # folder_publish requires a non-GET request
00192         self.setRequestMethod('POST')

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

00201 
00202     def testCatalogIsUpdatedOnFolderPublish(self):
00203         # Make sure catalog gets updated
00204         doc_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00205         self.login('reviewer')
00206         self.setupAuthenticator()
00207         self.folder.folder_publish(workflow_action='publish',paths=[doc_path])
00208         results = self.catalog(path=doc_path)
00209         self.assertEqual(len(results),1)
00210         self.assertEqual(results[0].review_state,'published')

Here is the call graph for this function:

Definition at line 193 of file testFolderButtons.py.

00193 
00194     def testFolderPublishing(self):
00195         # Make sure object gets published
00196         doc_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00197         self.login('reviewer')
00198         self.setupAuthenticator()
00199         self.folder.folder_publish(workflow_action='publish',paths=[doc_path])
00200         self.assertEqual(self.wtool.getInfoFor(self.folder.foo.doc1, 'review_state',None), 'published')

Here is the call graph for this function:

Definition at line 262 of file testFolderButtons.py.

00262 
00263     def testGETRaises(self):
00264         # folder_rename requires a non-GET request and will fail otherwise
00265         self.setRequestMethod('GET')
00266         self.assertRaises(Forbidden, self.folder.folder_publish,
00267                           'publish', paths=['bogus'])
00268 

Here is the call graph for this function:

Definition at line 221 of file testFolderButtons.py.

00221 
00222     def testNoErrorOnBadPaths(self):
00223         # Ensure we don't fail on a bad path, but transition the good ones
00224         doc1_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00225         doc2_path = '/'.join(self.folder.bar.doc2.getPhysicalPath())
00226         paths=[doc1_path, '/garbage/path', doc2_path]
00227         self.login('reviewer')
00228         self.setupAuthenticator()
00229         self.folder.folder_publish('publish', paths=paths)
00230         self.assertEqual(self.wtool.getInfoFor(self.folder.foo.doc1,
00231                                                'review_state', None),
00232                          'published')
00233         self.assertEqual(self.wtool.getInfoFor(self.folder.bar.doc2,
00234                                                'review_state', None),
00235                          'published')

Here is the call graph for this function:

Definition at line 236 of file testFolderButtons.py.

00236 
00237     def testPublishFailureIsCleanedUp(self):
00238         # Ensure we don't fail on a bad path, but transition the good ones
00239 
00240         # First we add a failing notifySuccess method to the workflow
00241         # via a nasty monkey-patch
00242         from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
00243         def notifySuccess(self, obj, action, result):
00244             raise Exception, 'Cannot transition'
00245         orig_notify = DCWorkflowDefinition.notifySuccess
00246         DCWorkflowDefinition.notifySuccess = notifySuccess
00247 
00248         # now we perform the transition
00249         doc1_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00250         self.login('reviewer')
00251         self.setupAuthenticator()
00252         self.folder.folder_publish('publish', paths=[doc1_path])
00253         # because an error was raised during post transition the
00254         # transaction should have been rolled-back and the state
00255         # should not have changed
00256         self.failIfEqual(self.wtool.getInfoFor(self.folder.foo.doc1,
00257                                                'review_state', None),
00258                          'published')
00259 
00260         # undo our nasty patch
00261         DCWorkflowDefinition.notifySuccess = orig_notify

Here is the call graph for this function:

Definition at line 211 of file testFolderButtons.py.

00211 
00212     def testPublishMultiplePaths(self):
00213         # Make sure publish works for list of paths
00214         doc1_path = '/'.join(self.folder.foo.doc1.getPhysicalPath())
00215         doc2_path = '/'.join(self.folder.bar.doc2.getPhysicalPath())
00216         self.login('reviewer')
00217         self.setupAuthenticator()
00218         self.folder.folder_publish('publish',paths=[doc1_path,doc2_path])
00219         self.assertEqual(self.wtool.getInfoFor(self.folder.foo.doc1, 'review_state',None), 'published')
00220         self.assertEqual(self.wtool.getInfoFor(self.folder.bar.doc2, 'review_state',None), 'published')

Here is the call graph for this function:


Member Data Documentation

Definition at line 183 of file testFolderButtons.py.

Definition at line 184 of file testFolderButtons.py.


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