Back to index

plone3  3.1.7
base.py
Go to the documentation of this file.
00001 """Base class for integration tests, based on ZopeTestCase and PloneTestCase.
00002 
00003 Note that importing this module has various side-effects: it registers a set of
00004 products with Zope, and it sets up a sandbox Plone site with the appropriate
00005 products installed.
00006 """
00007 
00008 from Testing import ZopeTestCase
00009 
00010 # Import PloneTestCase - this registers more products with Zope as a side effect
00011 from Products.PloneTestCase.PloneTestCase import PloneTestCase
00012 from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
00013 from Products.PloneTestCase.PloneTestCase import setupPloneSite
00014 from DateTime import DateTime
00015 
00016 # Set up a Plone site - note that the portlets branch of CMFPlone applies
00017 # a portlets profile.
00018 setupPloneSite()
00019 
00020 class WorkflowTestCase(PloneTestCase):
00021     """Base class for integration tests for plone.app.workflow. This may
00022     provide specific set-up and tear-down operations, or provide convenience
00023     methods.
00024     """
00025     
00026 class WorkflowFunctionalTestCase(FunctionalTestCase):
00027     """Base class for functional integration tests for plone.app.workflow. 
00028     This may provide specific set-up and tear-down operations, or provide 
00029     convenience methods.
00030     """
00031 
00032     def afterSetUp(self):
00033 
00034         self.portal.acl_users._doAddUser('manager', 'secret', ['Manager',],[])
00035         self.portal.acl_users._doAddUser('member', 'secret', ['Member',],[])
00036         self.portal.acl_users._doAddUser('owner', 'secret', ['Owner',],[])
00037         self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer',],[])
00038         self.portal.acl_users._doAddUser('editor', 'secret', ['Editor',],[])
00039         self.portal.acl_users._doAddUser('reader', 'secret', ['Reader',],[])
00040         
00041         self.portal.acl_users._doAddUser('delegate_reader', 'secret', ['Member',],[]) 
00042         self.portal.acl_users._doAddUser('delegate_editor', 'secret', ['Member',],[])
00043         self.portal.acl_users._doAddUser('delegate_contributor', 'secret', ['Member',],[])
00044         self.portal.acl_users._doAddUser('delegate_reviewer', 'secret', ['Member',],[])
00045         #self.portal.acl_users._doAddUser('delegate_manager', 'secret', ['Member',],[])
00046 
00047         self.setRoles(('Manager',))
00048         self.folder.invokeFactory('News Item', 'newsitem1')
00049         self.newsitem = self.folder.newsitem1
00050         self.folder.invokeFactory('Event', 'event1')
00051         self.event = self.folder.event1
00052         self.folder.invokeFactory('Document', 'document1')
00053         self.document = self.folder.document1
00054         self.setRoles(('Member',))
00055 
00056     def setUpDefaultWorkflow(self, defaultWorkflow=None, hasFolderSpecificWorkflow=False):
00057         # XXX - TODO: we'll be able to replace this all with the new remap template
00058         self.workflow = self.portal.portal_workflow
00059         ctypes        = self.portal.allowedContentTypes()
00060         # XXX figure out the real way to get the types
00061         ctypes        = ('Document','Folder','News Item','Event',)
00062 
00063         for ctype in ctypes:
00064             if ctype in ('Folder','Smart Folder') and hasFolderSpecificWorkflow:
00065                 # XXX factor in *_folder_* workflow declarations
00066                 self.workflow.setChainForPortalTypes(('%s' % ctype,), ('%s' % defaultWorkflow,))
00067             else:
00068                 self.workflow.setChainForPortalTypes(('%s' % ctype,), ('%s' % defaultWorkflow,))
00069 
00070