def test_should_call_get_pipeline_for_configuration_with_config_and_args(
            self, get_pipeline_for_configuration_and_args, args):

        config = dict_to_config(DEFAULT_CONFIG)
        create_simple_pipeline_runner_from_config(config, args)
        get_pipeline_for_configuration_and_args.assert_called_with(config,
                                                                   args=args)
Пример #2
0
def _dict_to_cfg_content(d):
    config = dict_to_config(d)
    fp = StringIO()
    config.write(fp)
    content = fp.getvalue()
    LOGGER.debug('content: %s', content)
    return content
Пример #3
0
 def test_should_default_pipeline_to_point_to_another_pipeline_configuration(
         self, import_module):
     config = dict_to_config({
         u'pipelines': {
             u'default': u'custom',
             u'custom': DEFAULT_PIPELINE_MODULE
         }
     })
     get_pipeline_for_configuration(config)
     import_module.assert_called_with(DEFAULT_PIPELINE_MODULE)
 def test_should_load_steps_and_run_them_on_convert(self, pipeline, args,
                                                    step):
     config = dict_to_config(DEFAULT_CONFIG)
     pipeline.get_steps.return_value = [step]
     pipeline_runner = create_simple_pipeline_runner_from_config(
         config, args)
     step.get_supported_types.return_value = {MimeTypes.PDF}
     assert (pipeline_runner.convert(
         content=PDF_CONTENT,
         filename=PDF_FILENAME,
         data_type=MimeTypes.PDF) == step.return_value)
 def test_should_skip_first_step_if_content_type_does_not_match(
         self, pipeline, args, step):
     config = dict_to_config(DEFAULT_CONFIG)
     pipeline.get_steps.return_value = [
         FunctionPipelineStep(lambda _: None, set(), 'dummy'), step
     ]
     pipeline_runner = create_simple_pipeline_runner_from_config(
         config, args)
     step.get_supported_types.return_value = {MimeTypes.PDF}
     assert (pipeline_runner.convert(
         content=PDF_CONTENT,
         filename=PDF_FILENAME,
         data_type=MimeTypes.PDF) == step.return_value)
 def test_should_pass_includes_to_first_step(self, pipeline, args, step):
   config = dict_to_config(DEFAULT_CONFIG)
   pipeline.get_steps.return_value = [step]
   pipeline_runner = create_simple_pipeline_runner_from_config(config, args)
   step.get_supported_types.return_value = {MimeTypes.PDF}
   pipeline_runner.convert(
     content=PDF_CONTENT, filename=PDF_FILENAME, data_type=MimeTypes.PDF,
     includes={FieldNames.TITLE}
   )
   step.assert_called_with({
     StepDataProps.FILENAME: PDF_FILENAME,
     StepDataProps.CONTENT: PDF_CONTENT,
     StepDataProps.TYPE: MimeTypes.PDF,
     StepDataProps.INCLUDES: {FieldNames.TITLE}
   })
def get_default_config():
    return dict_to_config({})
Пример #8
0
 def test_should_return_pipeline_steps(self, pipeline, args, step):
     config = dict_to_config(DEFAULT_CONFIG)
     pipeline.get_steps.return_value = [step]
     pipeline = get_pipeline_for_configuration(config)
     step.get_supported_types.return_value = {MimeTypes.PDF}
     assert pipeline.get_steps(config, args) == [step]
Пример #9
0
 def test_should_pass_args_and_config_to_get_steps(self, pipeline, args,
                                                   step):
     config = dict_to_config(DEFAULT_CONFIG)
     pipeline.get_steps.return_value = [step]
     get_pipeline_for_configuration(config).get_steps(config, args)
     pipeline.get_steps.assert_called_with(config, args)
Пример #10
0
 def test_should_call_import_module_with_configured_default_pipeline(
         self, import_module):
     config = dict_to_config(DEFAULT_CONFIG)
     get_pipeline_for_configuration(config)
     import_module.assert_called_with(DEFAULT_PIPELINE_MODULE)
Пример #11
0
 def test_should_return_concatenated_pipeline(self):
     config = dict_to_config(DEFAULT_CONFIG)
     assert get_pipeline_expression_for_configuration(
         config, '%s, %s' %
         (PIPELINE_1, PIPELINE_2)) == '%s, %s' % (PIPELINE_MODULE_1,
                                                  PIPELINE_MODULE_2)
Пример #12
0
 def test_should_return_specified_pipeline(self):
     config = dict_to_config(DEFAULT_CONFIG)
     assert get_pipeline_expression_for_configuration(
         config, PIPELINE_1) == PIPELINE_MODULE_1
Пример #13
0
 def test_should_return_default_pipeline(self):
     config = dict_to_config(DEFAULT_CONFIG)
     assert get_pipeline_expression_for_configuration(
         config, '') == DEFAULT_PIPELINE_MODULE
Пример #14
0
def _config():
    return dict_to_config({})
 def test_should_pass_args_and_config_to_get_steps(self, pipeline, args,
                                                   step):
     config = dict_to_config(DEFAULT_CONFIG)
     pipeline.get_steps.return_value = [step]
     create_simple_pipeline_runner_from_config(config, args)
     pipeline.get_steps.assert_called_with(config, args)