Beispiel #1
0
    def test_handle__normal(self):
        process = MockPipelineProcess()
        parallel_gateway = MockParallelGateway()
        children = [
            MockPipelineProcess()
            for _ in range(len(parallel_gateway.outgoing.all_target_node()))
        ]

        with patch(PIPELINE_PROCESS_FORK_CHILD,
                   MagicMock(side_effect=children)):
            hdl_result = handlers.parallel_gateway_handler(
                process, parallel_gateway, MockStatus())

            fork_child_calls = [
                mock.call(parent=process,
                          current_node_id=target.id,
                          destination_id=parallel_gateway.converge_gateway_id)
                for target in parallel_gateway.outgoing.all_target_node()
            ]
            PipelineProcess.objects.fork_child.assert_has_calls(
                fork_child_calls)

            process.join.assert_called_once_with(children)

            Status.objects.finish.assert_called_once_with(parallel_gateway)

            self.assertIsNone(hdl_result.next_node)
            self.assertTrue(hdl_result.should_return)
            self.assertTrue(hdl_result.should_sleep)
    def test_handle__fork_raise_exception(self):
        process = MockPipelineProcess()
        parallel_gateway = MockParallelGateway()
        e_msg = 'e_msg'

        with patch(PIPELINE_PROCESS_FORK_CHILD, MagicMock(side_effect=PipelineException(e_msg))):
            hdl_result = handlers.parallel_gateway_handler(process, parallel_gateway, MockStatus())

            PipelineProcess.objects.fork_child.assert_called()

            Status.objects.fail.assert_called_once_with(parallel_gateway, e_msg)

            process.join.assert_not_called()

            Status.objects.finish.assert_not_called()

            self.assertIsNone(hdl_result.next_node)
            self.assertTrue(hdl_result.should_return)
            self.assertTrue(hdl_result.should_sleep)