Ejemplo n.º 1
0
 def test_get_branch_invalid_action(self):
     flag = Condition('HelloWorld',
                      action_name='regMatch',
                      arguments=[Argument('regex', value='aaa')])
     branch = Branch(source_uid="1",
                     destination_uid='next',
                     conditions=[flag])
     action = Action('HelloWorld', 'helloWorld', uid="2")
     action._output = ActionResult(result='bbb', status='Success')
     workflow = Workflow(actions=[action], branches=[branch])
     self.assertIsNone(workflow.get_branch(action, {}))
Ejemplo n.º 2
0
 def test_branch_with_priority(self):
     flag = Condition('HelloWorld',
                      action_name='regMatch',
                      arguments=[Argument('regex', value='aaa')])
     branch_one = Branch(source_uid="1",
                         destination_uid='five',
                         conditions=[flag],
                         priority="5")
     branch_two = Branch(source_uid="1",
                         destination_uid='one',
                         conditions=[flag],
                         priority="1")
     action = Action('HelloWorld', 'helloWorld', uid="1")
     action._output = ActionResult(result='aaa', status='Success')
     workflow = Workflow(actions=[action],
                         branches=[branch_one, branch_two])
     self.assertEqual(workflow.get_branch(action, {}), "one")
Ejemplo n.º 3
0
    def test_get_branch(self):
        flag = Condition('HelloWorld',
                         action_name='regMatch',
                         arguments=[Argument('regex', value='aaa')])
        branch = Branch(source_uid="1", destination_uid="2", conditions=[flag])
        action = Action('HelloWorld', 'helloWorld', uid="1")
        action._output = ActionResult(result='aaa', status='Success')
        workflow = Workflow(actions=[action], branches=[branch])

        result = {'triggered': False}

        def validate_sent_data(sender, **kwargs):
            if isinstance(sender, Branch):
                self.assertIn('event', kwargs)
                self.assertEqual(kwargs['event'], WalkoffEvent.BranchTaken)
                result['triggered'] = True

        WalkoffEvent.CommonWorkflowSignal.connect(validate_sent_data)

        self.assertEqual(workflow.get_branch(action, {}), '2')
        self.assertTrue(result['triggered'])