• Jérome Perrin's avatar
    SecurityTestCase: update assertion failure message for new workflow API · 08f88c59
    Jérome Perrin authored
    This test case tries to provide message helpful for debugging in case
    of assertion failure for assertUserCanPassWorkflowTransition, but
    this was not correctly using new workflow API and in case of failure
    there was an error like this:
    
      File ".../custom/test.py"
        self.assertUserCanPassWorkflowTransition(user, 'stop_action', packing_list)
      File "product/ERP5Type/tests/SecurityTestCase.py", line 237, in failUnlessUserCanPassWorkflowTransition
        if wf_transition.trigger_type == TRIGGER_USER_ACTION:
    AttributeError: 'NoneType' object has no attribute 'trigger_type'
    
    The previous implementation was using getGuardSummary, which no
    longer exist in new workflow, so we implement similar logic here.
    
    The new message changes a bit, it now look like this:
    
        AssertionError: User X can NOT pass stop_action transition on Internal Packing List at /erp5/internal_packing_list_module/20220218-22A38 (draft on delivery_causality_workflow, draft on internal_packing_list_notification_workflow, started on packing_list_workflow).
         Roles: [Owner, Member, Authenticated, Associate]
         Available transitions:
                  deliver_action[packing_list_workflow]
                        Expression:
                        Permissions:
                        Groups:
                * stop_action[packing_list_workflow]
                        Expression: python: not(state_change['object'].getPortalType() == "Sale Packing List" and state_change['object'].getSimulationState() == "confirmed")
                        Permissions:
                        Groups:
    08f88c59
SecurityTestCase.py 14.2 KB