def test_should_pass_around_values_with_single_step( self, pipeline, app_config): with patch_conversion_pipeline() as mocks: opt = get_file_list_args() step1 = MagicMock(name='step1') step1.get_supported_types.return_value = {MimeTypes.PDF} step1.return_value = {'content': XML_CONTENT_1} pipeline.get_steps.return_value = [step1] with TestPipeline() as p: mocks['ReadFileList'].return_value = beam.Create([PDF_FILE_1]) mocks['read_all_from_path'].return_value = PDF_CONTENT_1 configure_pipeline(p, opt, pipeline, app_config) assert get_counter_value( p.run(), get_step_processed_counter(step1)) == 1 step1.assert_called_with({ 'content': PDF_CONTENT_1, 'source_filename': PDF_FILE_1, 'filename': PDF_FILE_1, 'type': MimeTypes.PDF }) mocks['save_file_content'].assert_called_with( OUTPUT_XML_FILE_1, XML_CONTENT_1)
def test_should_skip_step_if_data_type_doesnt_match_and_increase_ignored_count( self, pipeline, app_config, mocks): opt = get_file_list_args() step1 = _convert_step(name='step1', supported_types={'other'}) pipeline.get_steps.return_value = [step1] with TestPipeline() as p: mocks['ReadFileList'].return_value = beam.Create([PDF_FILE_1]) mocks['read_all_from_path'].return_value = PDF_CONTENT_1 configure_pipeline(p, opt, pipeline, app_config) assert get_counter_value(p.run(), get_step_ignored_counter(step1)) == 1
def test_should_skip_item_causing_exception_and_increase_error_count( self, pipeline, app_config, mocks): opt = get_file_list_args() step1 = _pdf_step() step1.side_effect = RuntimeError('doh1') pipeline.get_steps.return_value = [step1] with TestPipeline() as p: mocks['ReadFileList'].return_value = beam.Create([PDF_FILE_1]) mocks['read_all_from_path'].return_value = PDF_CONTENT_1 configure_pipeline(p, opt, pipeline, app_config) assert get_counter_value(p.run(), get_step_error_counter(step1)) == 1 mocks['save_file_content'].assert_not_called()