# -*- coding: utf-8 -*- # # File: testWorkTeleServiceWorkflow.py # # Copyright (c) 2007 by CommunesPlone # Generator: ArchGenXML Version 1.5.1-svn # http://plone.org/products/archgenxml # # GNU General Public License (GPL) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # __author__ = """Gauthier BASTIEN , Stephan GEULETTE """ __docformat__ = 'plaintext' import os, sys if __name__ == '__main__': execfile(os.path.join(sys.path[0], 'framework.py')) ##code-section module-header #fill in your manual code here from Products.TeleServices.config import * from Products.TeleServices.tests.BaseTeleServicesTestCase import BaseTeleServicesTestCase ##/code-section module-header # # Test-cases for class(es) # from Testing import ZopeTestCase # Import the tested classes ##code-section module-beforeclass #fill in your manual code here from Products.TeleServices.config import * from Products.TeleServices.tests.BaseTeleServicesTestCase import BaseTeleServicesTestCase from AccessControl import Unauthorized from AccessControl.SecurityManagement import getSecurityManager from Products.CMFCore.permissions import View, AccessContentsInformation, ModifyPortalContent from Products.TeleServices import WorkTeleServicesReview, ManageTeleServices from Products.CMFCore.utils import getToolByName ##/code-section module-beforeclass class testWorkTeleServiceWorkflow(BaseTeleServicesTestCase): """Test-cases for class(es) .""" ##code-section class-header_testWorkTeleServiceWorkflow #fill in your manual code here ##/code-section class-header_testWorkTeleServiceWorkflow def afterSetUp(self): BaseTeleServicesTestCase.afterSetup(self) # Manually created methods def testInitialState(self): """ On teste ici l'etat initial d'un WorkTeleService """ wft = self.wft #the Member add a WorkTeleService self.login("member") member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(wft.getInfoFor(wts, 'review_state'), 'pending_confirm') def testPermissionsInStatePendingConfirm(self): """ we test the permissions of differents roles when a WorkTeleService is in state pending_confirm """ self.login("member") member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #the Owner have the 'View', 'Access contents information', 'Modify portal content' #but not the 'TeleServices: Review state' and 'TeleServices: Manage TeleServices' sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Manager has every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failUnless(sm.checkPermission(ManageTeleServices, wts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) def testPermissionsInStateCancelled(self): """ we test the permissions of differents roles when a WorkTeleService is in state cancelled """ self.login("member") member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #we set the wts in cancelled state self.wft.doActionFor(wts, 'cancel') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'cancelled') #the Owner have the 'View', 'Access contents information', 'Modify portal content' #but not the 'TeleServices: Review state' and 'TeleServices: Manage TeleServices' sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Manager has every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failUnless(sm.checkPermission(ManageTeleServices, wts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) def testPermissionsInStateTransmitted(self): """ we test the permissions of differents roles when a WorkTeleService is in state transmitted """ self.login("member") member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #we set the wts in transmitted state self.wft.doActionFor(wts, 'transmit') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'transmitted') #the Owner have the 'View', 'Access contents information', 'Modify portal content' #but not the 'TeleServices: Review state' and 'TeleServices: Manage TeleServices' sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Manager has every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failUnless(sm.checkPermission(ManageTeleServices, wts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) def testPermissionsInStateInTreatment(self): """ we test the permissions of differents roles when a WorkTeleService is in state in_treatment """ self.login("member") member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #we set the wts in in_treatment state self.login("admin") self.wft.doActionFor(wts, 'transmit') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'transmitted') self.wft.doActionFor(wts, 'treat') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'in_treatment') #the Owner have the 'View', 'Access contents information', 'Modify portal content' #but not the 'TeleServices: Review state' and 'TeleServices: Manage TeleServices' self.login("member") sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Manager has every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failUnless(sm.checkPermission(ManageTeleServices, wts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) def testPermissionsInStateClosed(self): """ we test the permissions of differents roles when a WorkTeleService is in state closed """ self.login("member") member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #we set the wts in closed state self.login("admin") self.wft.doActionFor(wts, 'transmit') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'transmitted') self.wft.doActionFor(wts, 'close') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'closed') #the Owner have the 'View', 'Access contents information', 'Modify portal content' #but not the 'TeleServices: Review state' and 'TeleServices: Manage TeleServices' self.login("member") sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Manager has every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failUnless(sm.checkPermission(ManageTeleServices, wts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) def testPermissionsInStateRejected(self): """ we test the permissions of differents roles when a WorkTeleService is in state rejected """ self.login("member") member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #we set the wts in rejected state self.login("admin") self.wft.doActionFor(wts, 'transmit') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'transmitted') self.wft.doActionFor(wts, 'reject') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'rejected') #the Owner have the 'View', 'Access contents information', 'Modify portal content' #but not the 'TeleServices: Review state' and 'TeleServices: Manage TeleServices' self.login("member") sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Manager has every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failUnless(sm.checkPermission(ManageTeleServices, wts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, wts)) self.failUnless(sm.checkPermission(AccessContentsInformation, wts)) self.failUnless(sm.checkPermission(ModifyPortalContent, wts)) self.failUnless(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, wts)) self.failIf(sm.checkPermission(AccessContentsInformation, wts)) self.failIf(sm.checkPermission(ModifyPortalContent, wts)) self.failIf(sm.checkPermission(WorkTeleServicesReview, wts)) self.failIf(sm.checkPermission(ManageTeleServices, wts)) def testTransitionFromPendingConfirm(self): """ we test the available transitions for differents roles when the WTS is in the pending_confirm state """ self.login("member") #the member add a WTS member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #Owner self.checkActionList(wts, ['cancel', 'transmit']) #Manager self.login('admin') self.checkActionList(wts, ['cancel', 'transmit']) #PTSManager self.login('ptsmanager') self.checkActionList(wts, []) #WTSManager self.login('wtsmanager') self.checkActionList(wts, ['cancel', 'transmit']) #Member2 self.login('member2') self.checkActionList(wts, []) #Anonymous self.login('anon') self.checkActionList(wts, []) def testTransitionFromCancelled(self): """ we test the available transitions for differents roles when the WTS is in the cancelled state """ self.login("member") #the member add a WTS member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #we set the wts in cancelled state self.wft.doActionFor(wts, 'cancel') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'cancelled') #Owner self.checkActionList(wts, []) #Manager self.login('admin') self.checkActionList(wts, ['set_pending']) #PTSManager self.login('ptsmanager') self.checkActionList(wts, []) #WTSManager self.login('wtsmanager') self.checkActionList(wts, ['set_pending']) #Member2 self.login('member2') self.checkActionList(wts, []) #Anonymous self.login('anon') self.checkActionList(wts, []) def testTransitionFromTransmitted(self): """ we test the available transitions for differents roles when the WTS is in the transmitted state """ self.login("member") #the member add a WTS member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #we set the wts in transmitted state self.wft.doActionFor(wts, 'transmit') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'transmitted') #Owner self.checkActionList(wts, []) #Manager self.login('admin') self.checkActionList(wts, ['set_pending_from_transmitted', 'close', 'treat', 'reject']) #PTSManager self.login('ptsmanager') self.checkActionList(wts, []) #WTSManager self.login('wtsmanager') self.checkActionList(wts, ['close', 'treat', 'reject']) #Member2 self.login('member2') self.checkActionList(wts, []) #Anonymous self.login('anon') self.checkActionList(wts, []) def testTransitionFromInTreatment(self): """ we test the available transitions for differents roles when the WTS is in the in_treatment state """ self.login("member") #the member add a WTS member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #we set the wts in in_treatment state self.login('admin') self.wft.doActionFor(wts, 'transmit') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'transmitted') self.wft.doActionFor(wts, 'treat') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'in_treatment') #Owner self.login("member") self.checkActionList(wts, []) #Manager self.login('admin') self.checkActionList(wts, ['set_transmitted', 'close', 'reject']) #PTSManager self.login('ptsmanager') self.checkActionList(wts, []) #WTSManager self.login('wtsmanager') self.checkActionList(wts, ['set_transmitted', 'close', 'reject']) #Member2 self.login('member2') self.checkActionList(wts, []) #Anonymous self.login('anon') self.checkActionList(wts, []) def testTransitionFromClosed(self): """ we test the available transitions for differents roles when the WTS is in the closed state """ self.login("member") #the member add a WTS member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #we set the wts in closed state self.login('admin') self.wft.doActionFor(wts, 'transmit') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'transmitted') self.wft.doActionFor(wts, 'close') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'closed') #Owner self.login("member") self.checkActionList(wts, []) #Manager self.login('admin') self.checkActionList(wts, ['set_transmitted', 'correct']) #PTSManager self.login('ptsmanager') self.checkActionList(wts, []) #WTSManager self.login('wtsmanager') self.checkActionList(wts, ['set_transmitted', 'correct']) #Member2 self.login('member2') self.checkActionList(wts, []) #Anonymous self.login('anon') self.checkActionList(wts, []) def testTransitionFromRejected(self): """ we test the available transitions for differents roles when the WTS is in the rejected state """ self.login("member") #the member add a WTS member_home = self.portal.Members.member.myteleservices wts = self.invokeFactoryTS(type_name="WorkTeleService", demand_type="wtsterm1", id="wts", path=member_home) self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'pending_confirm') #we set the wts in rejected state self.login('admin') self.wft.doActionFor(wts, 'transmit') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'transmitted') self.wft.doActionFor(wts, 'reject') self.assertEquals(self.wft.getInfoFor(wts, 'review_state'), 'rejected') #Owner self.login("member") self.checkActionList(wts, []) #Manager self.login('admin') self.checkActionList(wts, ['set_transmitted', 'correct']) #PTSManager self.login('ptsmanager') self.checkActionList(wts, []) #WTSManager self.login('wtsmanager') self.checkActionList(wts, ['set_transmitted', 'correct']) #Member2 self.login('member2') self.checkActionList(wts, []) #Anonymous self.login('anon') self.checkActionList(wts, []) def test_suite(): from unittest import TestSuite, makeSuite suite = TestSuite() suite.addTest(makeSuite(testWorkTeleServiceWorkflow)) return suite ##code-section module-footer #fill in your manual code here ##/code-section module-footer if __name__ == '__main__': framework()