# -*- coding: utf-8 -*- # # File: testPopulationTeleServiceWorkflow.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 ##/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 TeleServicesReview, ManageTeleServices from Products.CMFCore.utils import getToolByName ##/code-section module-beforeclass class testPopulationTeleServiceWorkflow(BaseTeleServicesTestCase): """Test-cases for class(es) .""" ##code-section class-header_testPopulationTeleServiceWorkflow #fill in your manual code here ##/code-section class-header_testPopulationTeleServiceWorkflow def afterSetUp(self): BaseTeleServicesTestCase.afterSetup(self) # Manually created methods def testInitialState(self): """ On teste ici l'etat initial d'un PopulationTeleService """ wft = self.wft #the Member add a PopulationTeleService self.login("member") member_home = self.portal.Members.member.myteleservices pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home) self.assertEquals(wft.getInfoFor(pts, 'review_state'), 'pending_confirm') def testPermissionsInStatePendingConfirm(self): """ we test the permssions of differents roles when a PopulationTeleService is in state pending_confirm """ #the Member add a PopulationTeleService self.login("member") member_home = self.portal.Members.member.myteleservices pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home) #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, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Manager has every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failUnless(sm.checkPermission(ManageTeleServices, pts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) def testPermissionsInStateCancelled(self): """ we test the permssions of differents roles when a PopulationTeleService is in state cancelled """ #the Member add a PopulationTeleService self.login("member") member_home = self.portal.Members.member.myteleservices pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home) #we set the pts in cancelled state self.wft.doActionFor(pts, 'cancel') #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, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Manager has every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failUnless(sm.checkPermission(ManageTeleServices, pts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) def testPermissionsInStateWaitingPayment(self): """ we test the permssions of differents roles when a PopulationTeleService is in state waiting_payment """ #the Member add a PopulationTeleService self.login("member") member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) self.wft.doActionFor(pts, 'confirm') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "waiting_payment") #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, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Manager has every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failUnless(sm.checkPermission(ManageTeleServices, pts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) def testPermissionsInStateTransmitted(self): """ we test the permssions of differents roles when a PopulationTeleService is in state transmitted """ #the Member add a PopulationTeleService self.login("member") member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) self.wft.doActionFor(pts, 'confirm') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "waiting_payment") self.login('ptsmanager') self.wft.doActionFor(pts, 'validate_payment') #we check that we are in the transmitted state after the validate_payment transition self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "transmitted") #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, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Manager has every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failUnless(sm.checkPermission(ManageTeleServices, pts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) def testPermissionsInStateInTreatment(self): """ we test the permssions of differents roles when a PopulationTeleService is in state in_treatment """ #the Member add a PopulationTeleService self.login("member") member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) self.wft.doActionFor(pts, 'confirm') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "waiting_payment") self.login('ptsmanager') self.wft.doActionFor(pts, 'validate_payment') #we check that we are in the transmitted state after the validate_payment transition self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "transmitted") self.wft.doActionFor(pts, 'treat') self.assertEquals(self.wft.getInfoFor(pts, '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, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Manager have every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failUnless(sm.checkPermission(ManageTeleServices, pts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) def testPermissionsInStateRejected(self): """ we test the permssions of differents roles when a PopulationTeleService is in state rejected """ #the Member add a PopulationTeleService self.login("member") member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) self.wft.doActionFor(pts, 'confirm') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "waiting_payment") self.login('ptsmanager') self.wft.doActionFor(pts, 'validate_payment') #we check that we are in the transmitted state after the validate_payment transition self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "transmitted") self.wft.doActionFor(pts, 'treat') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "in_treatment") self.wft.doActionFor(pts, 'reject') self.assertEquals(self.wft.getInfoFor(pts, '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, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Manager have every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failUnless(sm.checkPermission(ManageTeleServices, pts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) def testPermissionsInStateClosed(self): """ we test the permssions of differents roles when a PopulationTeleService is in state closed """ #the Member add a PopulationTeleService self.login("member") member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) self.wft.doActionFor(pts, 'confirm') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "waiting_payment") self.login('ptsmanager') self.wft.doActionFor(pts, 'validate_payment') #we check that we are in the transmitted state after the validate_payment transition self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "transmitted") self.wft.doActionFor(pts, 'treat') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "in_treatment") self.wft.doActionFor(pts, 'close') self.assertEquals(self.wft.getInfoFor(pts, '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, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Manager have every permissions self.login('admin') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failUnless(sm.checkPermission(ManageTeleServices, pts)) #PopulationTSManager can see it self.login('ptsmanager') sm = getSecurityManager() self.failUnless(sm.checkPermission(View, pts)) self.failUnless(sm.checkPermission(AccessContentsInformation, pts)) self.failUnless(sm.checkPermission(ModifyPortalContent, pts)) self.failUnless(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #WorkTSManager can NOT see it self.login('wtsmanager') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #Anonymous can NOT see it self.login('anon') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) #another Member can NOT see it self.login('member2') sm = getSecurityManager() self.failIf(sm.checkPermission(View, pts)) self.failIf(sm.checkPermission(AccessContentsInformation, pts)) self.failIf(sm.checkPermission(ModifyPortalContent, pts)) self.failIf(sm.checkPermission(TeleServicesReview, pts)) self.failIf(sm.checkPermission(ManageTeleServices, pts)) def testTransitionFromInTreatment(self): """ we test the available transitions for differents roles when the PTS is in the waiting_payment state """ self.login("member") #the memebr add a PTS member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) #we check that we are in the pending_confirm state self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "pending_confirm") #we cancel the PTS self.wft.doActionFor(pts, 'confirm') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "waiting_payment") #we log as PopulationTeleServicesManager self.login('ptsmanager') self.wft.doActionFor(pts, 'validate_payment') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "transmitted") self.wft.doActionFor(pts, 'treat') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "in_treatment") self.checkActionList(pts, ['set_transmitted', 'close', 'reject']) #Owner self.login("member") self.checkActionList(pts, []) #Manager self.login('admin') self.checkActionList(pts, ['set_transmitted', 'close', 'reject']) #WTSManager self.login('wtsmanager') self.checkActionList(pts, []) #Member2 self.login('member2') self.checkActionList(pts, []) #Anonymous self.login('anon') self.checkActionList(pts, []) def testAutoTransitionFromWaitingPayment(self): """ in some case (PTS.noPayementTransmit()) an automatic transition will set the PTS in the 'transmitted' state """ self.login("member") #the memebr add a PTS member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm1" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) #we check that we are in the pending_confirm state self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "pending_confirm") #we cancel the PTS self.wft.doActionFor(pts, 'confirm') #when confirmed, the automatic transition will set the PTS in the transmitted state self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "transmitted") def testTransitionFromTransmitted(self): """ we test the available transitions for differents roles when the PTS is in the waiting_payment state """ self.login("member") #the memebr add a PTS member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) #we check that we are in the pending_confirm state self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "pending_confirm") #we cancel the PTS self.wft.doActionFor(pts, 'confirm') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "waiting_payment") #we log as PopulationTeleServicesManager self.login('ptsmanager') self.wft.doActionFor(pts, 'validate_payment') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "transmitted") self.checkActionList(pts, ['set_waiting_payment', 'close', 'reject', 'treat']) #Owner self.login("member") self.checkActionList(pts, []) #Manager self.login('admin') self.checkActionList(pts, ['set_pending_from_transmitted', 'set_waiting_payment', 'close', 'reject', 'treat']) #WTSManager self.login('wtsmanager') self.checkActionList(pts, []) #Member2 self.login('member2') self.checkActionList(pts, []) #Anonymous self.login('anon') self.checkActionList(pts, []) def testTransitionFromCancelled(self): """ we test the available transitions for differents roles when the PTS is in the cancelled state """ self.login("member") #the memebr add a PTS member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) #we check that we are in the pending_confirm state self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "pending_confirm") #we cancel the PTS self.wft.doActionFor(pts, 'cancel') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "cancelled") #Owner self.checkActionList(pts, []) #Manager self.login('admin') self.checkActionList(pts, ['set_pending']) #PTSManager self.login('ptsmanager') self.checkActionList(pts, ['set_pending']) #WTSManager self.login('wtsmanager') self.checkActionList(pts, []) #Member2 self.login('member2') self.checkActionList(pts, []) #Anonymous self.login('anon') self.checkActionList(pts, []) def testTransitionFromRejected(self): """ we test the available transitions for differents roles when the PTS is in the waiting_payment state """ self.login("member") #the memebr add a PTS member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) #we check that we are in the pending_confirm state self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "pending_confirm") #we cancel the PTS self.wft.doActionFor(pts, 'confirm') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "waiting_payment") #we log as PopulationTeleServicesManager self.login('ptsmanager') self.wft.doActionFor(pts, 'validate_payment') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "transmitted") self.wft.doActionFor(pts, 'treat') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "in_treatment") self.wft.doActionFor(pts, 'reject') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "rejected") self.checkActionList(pts, ['correct', 'set_waiting_payment', 'set_transmitted']) #Owner self.login("member") self.checkActionList(pts, []) #Manager self.login('admin') self.checkActionList(pts, ['correct', 'set_waiting_payment', 'set_transmitted']) #WTSManager self.login('wtsmanager') self.checkActionList(pts, []) #Member2 self.login('member2') self.checkActionList(pts, []) #Anonymous self.login('anon') self.checkActionList(pts, []) def testTransitionFromWaitingPayment(self): """ we test the available transitions for differents roles when the PTS is in the waiting_payment state """ self.login("member") #the memebr add a PTS member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) #we check that we are in the pending_confirm state self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "pending_confirm") #we cancel the PTS self.wft.doActionFor(pts, 'confirm') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "waiting_payment") #Owner self.checkActionList(pts, []) #Manager self.login('admin') self.checkActionList(pts, ['validate_payment', 'reject']) #PTSManager self.login('ptsmanager') self.checkActionList(pts, ['validate_payment', 'reject']) #WTSManager self.login('wtsmanager') self.checkActionList(pts, []) #Member2 self.login('member2') self.checkActionList(pts, []) #Anonymous self.login('anon') self.checkActionList(pts, []) def testTransitionFromPendingConfirm(self): """ we test the available transitions for differents roles when the PTS is in the pending_confirm state """ self.login("member") #the memebr add a PTS member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) #we check that we are in the pending_confirm state self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "pending_confirm") #Owner self.checkActionList(pts, ['cancel', 'confirm']) #Manager self.login('admin') self.checkActionList(pts, ['cancel', 'confirm']) #PTSManager self.login('ptsmanager') self.checkActionList(pts, ['cancel', 'confirm']) #WTSManager self.login('wtsmanager') self.checkActionList(pts, []) #Member2 self.login('member2') self.checkActionList(pts, []) #Anonymous self.login('anon') self.checkActionList(pts, []) def testTransitionFromClosed(self): """ we test the available transitions for differents roles when the PTS is in the waiting_payment state """ self.login("member") #the memebr add a PTS member_home = self.portal.Members.member.myteleservices dict = { 'motivation': "motivterm1", 'destination': "destterm2" } pts = self.invokeFactoryTS(type_name="PopulationTeleService", demand_type="ptsterm1", id="pts", path=member_home, **dict) #we check that we are in the pending_confirm state self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "pending_confirm") #we cancel the PTS self.wft.doActionFor(pts, 'confirm') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "waiting_payment") #we log as PopulationTeleServicesManager self.login('ptsmanager') self.wft.doActionFor(pts, 'validate_payment') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "transmitted") self.wft.doActionFor(pts, 'treat') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "in_treatment") self.wft.doActionFor(pts, 'close') self.assertEquals(self.wft.getInfoFor(pts, 'review_state'), "closed") self.checkActionList(pts, ['correct', 'set_transmitted']) #Owner self.login("member") self.checkActionList(pts, []) #Manager self.login('admin') self.checkActionList(pts, ['correct', 'set_transmitted']) #WTSManager self.login('wtsmanager') self.checkActionList(pts, []) #Member2 self.login('member2') self.checkActionList(pts, []) #Anonymous self.login('anon') self.checkActionList(pts, []) def test_suite(): from unittest import TestSuite, makeSuite suite = TestSuite() suite.addTest(makeSuite(testPopulationTeleServiceWorkflow)) return suite ##code-section module-footer #fill in your manual code here ##/code-section module-footer if __name__ == '__main__': framework()