testing a workflow script
Héctor Velarde
hvelarde at jornada.com.mx
Tue Sep 18 03:12:04 UTC 2007
Rob Miller wrote:
> that being said, your original problem may not be related to the
> security settings on the script at all. it may be that even if you get
> the security all dialed in, there's some explicit security check in the
> code that is causing the problem. if you end up performing your
> operation from trusted code but still have the problem, then you'll need
> to dig more deeply to find out exactly why the action is being
> disallowed. see http://plone.org/documentation/how-to/debug-unauthorized.
I tested this with few luck; fortunately Carlos de la Guardia came into
rescue and recommended me to use import transaction and
transaction.savepoint(optimistic=True).
in case someone needs to do something like this, this is the way it worked:
import transaction
class TestWorkflow(JuliusLiteTestCase):
""" ensure workflow script works """
def afterSetUp(self):
self.catalog = getattr(self.folder, 'portal_catalog')
self.workflow = getattr(self.folder, 'portal_workflow')
self.folder.invokeFactory('News Item', 'object')
self.object = getattr(self.folder, 'object')
self.object.setTitle('test')
def testArchiveItem(self):
""" test the script inside the workflow """
#need to commit transaction to be able to copy and paste
transaction.savepoint(optimistic=True)
self.folder.archiveItem(self)
self.failUnless(getattr(self.folder, 'object', None) is None)
results = self.catalog.searchResults(Title='test')
self.failUnlessEqual(len(results), 1)
More information about the Product-Developers
mailing list