def test_step_manager(self):
        def action_function(trail_env, context):
            return 'test return value {}'.format(context)

        step = Step(action_function)
        step.tags[
            'n'] = 7  # Typically this is set automatically. We're setting this manually for testing purposes.
        step.result_queue = MagicMock()
        trail_environment = MagicMock()
        step_manager(step, (trail_environment, ), dict(context='foo'))

        expected_result = StepResult(result=Step.SUCCESS,
                                     return_value='test return value foo')
        step.result_queue.put.assert_called_once_with(expected_result)
    def test_step_manager_with_exception(self):
        def action_function(trail_env, context):
            raise Exception('test exception')
            return 'test return value'

        step = Step(action_function)
        step.tags[
            'n'] = 7  # Typically this is set automatically. We're setting this manually for testing purposes.
        step.result_queue = MagicMock()
        trail_environment = MagicMock()
        step_manager(step, trail_environment, context='foo')

        expected_result = StepResult(result=Step.PAUSED_ON_FAIL,
                                     return_value='test exception')
        step.result_queue.put.assert_called_once_with(expected_result)