def test_run_pipeline_parse_context_error_failure_stop( mocked_get_parsed_context, mocked_steps_runner): """Raise on_failure from run_pipeline with Stop.""" mocked_get_parsed_context.side_effect = ValueError('arb') sr = mocked_steps_runner.return_value sr.run_failure_step_group.side_effect = Stop() ctx = pypyr.context.Context() with pytest.raises(Stop): pypyr.pipelinerunner.run_pipeline( pipeline='arb pipe', context=ctx, pipeline_context_input='arb context input') mocked_get_parsed_context.assert_called_once_with( pipeline='arb pipe', context_in_args='arb context input') mocked_steps_runner.assert_called_once_with(pipeline_definition='arb pipe', context=ctx) # No called steps, just on_failure since err on parse context already sr.run_step_groups.assert_not_called() sr.run_failure_step_group.assert_called_once_with('on_failure')
def mocked_run_pipeline_with_stop(*args, **kwargs): """Check pipeline name set on context in child pipeline with Stop.""" assert (kwargs['pipeline_name'] == kwargs['context'].pipeline_name == 'pipe name') raise Stop()
def stop_all_step(context): """Mock stop all step.""" raise Stop()
def step31(context): mock312(context) if context['i'] == 'two': raise Stop()
def step31(context): mock312(context) if context['whileCounter'] == 2: raise Stop()
def run_step(context): """Immediately stop all processing.""" logger.debug("started") logger.info("Stop: stopping pypyr...") raise Stop("pypyr.steps.stop stopped pypyr execution")
mock_run_pipeline.assert_called_once_with( pipeline_name='pipe name', pipeline_context_input='argument here', context=context, parse_input=False, loader='test loader', groups=None, success_group=None, failure_group=None) mock_logger_error.assert_called_once_with( 'Something went wrong pyping pipe name. RuntimeError: whoops') @patch('pypyr.pipelinerunner.load_and_run_pipeline', side_effect=Stop()) def test_pype_use_parent_context_swallow_stop_error(mock_run_pipeline): """Input pype doesn't swallow stop error in child pipeline.""" context = Context({ 'pype': { 'name': 'pipe name', 'pipeArg': 'argument here', 'useParentContext': True, 'skipParse': True, 'raiseError': False } }) with patch_logger('pypyr.steps.pype', logging.ERROR) as mock_logger_error: with pytest.raises(Stop) as err_info: pype.run_step(context)