Changeset 12145 for main/waeup.ikoba
- Timestamp:
- 4 Dec 2014, 18:11:12 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12119 r12145 31 31 from zope.component import createObject, queryUtility, getUtility 32 32 from zope.component.hooks import setSite, clearSite 33 from zope.schema.interfaces import ConstraintNotSatisfied 33 34 from zope.catalog.interfaces import ICatalog 34 35 from zope.security.interfaces import Unauthorized 35 36 from zope.securitypolicy.interfaces import IPrincipalRoleManager 36 37 from zope.testbrowser.testing import Browser 37 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 38 from hurry.workflow.interfaces import ( 39 IWorkflowInfo, IWorkflowState, InvalidTransitionError) 38 40 from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase 39 41 from waeup.ikoba.app import Company … … 1209 1211 print "Sample contract_slip.pdf written to %s" % path 1210 1212 1213 def test_contract_approval(self): 1214 # This is not a UI test. It just tests the approval 1215 # of contracts. 1216 self.assertRaises(ConstraintNotSatisfied, 1217 self.contract.document_object, self.document) 1218 # Document must be at least submitted 1219 IWorkflowState(self.document).setState('submitted') 1220 self.contract.document_object = self.document 1221 IWorkflowState(self.contract).setState('submitted') 1222 self.assertRaises(InvalidTransitionError, 1223 IWorkflowInfo(self.contract).fireTransition, 'approve') 1224 # Document must be verified for the approval of contracts 1225 IWorkflowState(self.document).setState('verified') 1226 IWorkflowInfo(self.contract).fireTransition('approve') 1227 self.assertEqual(IWorkflowState(self.contract).getState(), 'approved') 1228 return 1229 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py
r12097 r12145 22 22 from zope.component import getUtility 23 23 from hurry.workflow.workflow import Transition, WorkflowState, NullCondition 24 from hurry.workflow.interfaces import IWorkflowState, IWorkflowTransitionEvent 24 from hurry.workflow.interfaces import ( 25 IWorkflowState, IWorkflowTransitionEvent, InvalidTransitionError) 25 26 from waeup.ikoba.interfaces import ( 26 27 IObjectHistory, IIkobaWorkflowInfo, IIkobaUtils, … … 28 29 SUBMITTED, VERIFIED, REJECTED, EXPIRED) 29 30 from waeup.ikoba.interfaces import MessageFactory as _ 30 from waeup.ikoba.workflow import IkobaWorkflow, IkobaWorkflowInfo 31 from waeup.ikoba.workflow import ( 32 IkobaWorkflow, IkobaWorkflowInfo) 31 33 from waeup.ikoba.customers.interfaces import ( 32 34 ICustomer, ICustomersUtils, … … 238 240 239 241 @grok.subscribe(IContract, IWorkflowTransitionEvent) 240 def handle_ document_transition_event(obj, event):241 """Append message to contract history and log file andupdate242 def handle_contract_transition_event(obj, event): 243 """Append message to contract history and log file, also update 242 244 last_transition_date when transition happened. 243 """ 245 246 Undo the approval of contract and raise an exception if contract 247 does not meet the requirements for approval. 248 """ 249 if event.transition.destination == APPROVED: 250 if not obj.is_approvable: 251 # Undo transition and raise an exception. 252 IWorkflowState(obj).setState(event.transition.source) 253 raise InvalidTransitionError( 254 "Documents must be verified first.") 244 255 msg = event.transition.user_data['msg'] 245 256 history = IObjectHistory(obj)
Note: See TracChangeset for help on using the changeset viewer.