Back to index

plone3  3.1.7
CMFPlacefulWorkflowTestCase.py
Go to the documentation of this file.
00001 # -*- coding: utf-8 -*-
00002 ## CMFPlacefulWorkflow
00003 ## Copyright (C)2005 Ingeniweb
00004 
00005 ## This program is free software; you can redistribute it and/or modify
00006 ## it under the terms of the GNU General Public License as published by
00007 ## the Free Software Foundation; either version 2 of the License, or
00008 ## (at your option) any later version.
00009 
00010 ## This program is distributed in the hope that it will be useful,
00011 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 ## GNU General Public License for more details.
00014 
00015 ## You should have received a copy of the GNU General Public License
00016 ## along with this program; see the file COPYING. If not, write to the
00017 ## Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 """
00019 CMFPlacefulWorkflow TestCase module
00020 """
00021 __version__ = "$Revision: 41292 $"
00022 # $Source: /cvsroot/ingeniweb/CMFPlacefulWorkflow/tests/CMFPlacefulWorkflowTestCase.py,v $
00023 # $Id: CMFPlacefulWorkflowTestCase.py 41292 2007-04-29 21:20:27Z optilude $
00024 __docformat__ = 'restructuredtext'
00025 
00026 # Zope imports
00027 from Testing import ZopeTestCase
00028 from AccessControl.SecurityManagement import newSecurityManager
00029 from AccessControl.SecurityManagement import noSecurityManager
00030 
00031 # Plone imports
00032 from Products.PloneTestCase import PloneTestCase
00033 
00034 class CMFPlacefulWorkflowTestCase(PloneTestCase.PloneTestCase):
00035 
00036     # Globals
00037     portal_name = 'portal'
00038     portal_owner = 'portal_owner'
00039     user_name = PloneTestCase.default_user
00040     user_password = PloneTestCase.default_password
00041 
00042     class Session(dict):
00043         def set(self, key, value):
00044             self[key] = value
00045 
00046     def _setup(self):
00047         PloneTestCase.PloneTestCase._setup(self)
00048         self.app.REQUEST['SESSION'] = self.Session()
00049 
00050     def beforeTearDown(self):
00051         # logout
00052         noSecurityManager()
00053     
00054     def loginAsPortalMember(self):
00055         '''Use if you need to manipulate site as a member.'''
00056         self._setupUser()
00057         self.mtool.createMemberarea(self.user_name)
00058         member = self.mtool.getMemberById(self.user_name)
00059         member.setMemberProperties({'fullname': self.user_name.capitalize(), 'email': 'test@example.com',})
00060         self.login()
00061 
00062     def loginAsPortalOwner(self):
00063         '''Use if you need to manipulate site as a manager.'''
00064         uf = self.app.acl_users
00065         user = uf.getUserById(self.portal_owner).__of__(uf)
00066         newSecurityManager(None, user)
00067 
00068     def getPermissionsOfRole(self, role):
00069         perms = self.portal.permissionsOfRole(role)
00070         return [p['name'] for p in perms if p['selected']]
00071 
00072 
00073 # Install CMFPlacefulWorkflow
00074 ZopeTestCase.installProduct('MimetypesRegistry')
00075 ZopeTestCase.installProduct('PythonScripts')
00076 ZopeTestCase.installProduct('PortalTransforms')
00077 ZopeTestCase.installProduct('Archetypes')
00078 ZopeTestCase.installProduct('ATContentTypes')
00079 ZopeTestCase.installProduct('PloneInstallation')
00080 ZopeTestCase.installProduct('CMFPlacefulWorkflow')
00081 
00082 # Setup Plone site
00083 PloneTestCase.setupPloneSite(id='plone', products=[
00084     'Archetypes',
00085     'ATContentTypes',
00086     'CMFPlacefulWorkflow',
00087     ], extension_profiles=[
00088     'Products.CMFPlone:testfixture',
00089     ])
00090 
00091 app = ZopeTestCase.app()
00092 ZopeTestCase.close(app)
00093