Exemple #1
0
class AreaSourceWriterTestCase(unittest.TestCase):
    def setUp(self):
        self.as_writer = AreaSourceWriter(OUTPUT_NRML)
        self.area_source = create_area_source()

    def test_serialize_area_source_definition(self):
        self.as_writer.serialize([self.area_source])

        xml_tree_written_file = etree.parse(open(OUTPUT_NRML))
        xml_tree_expected_file = etree.parse(open(AREA_SOURCE))

        self.assertEqual(
            etree.tostring(xml_tree_written_file, pretty_print=True),
            etree.tostring(xml_tree_expected_file, pretty_print=True))

    def test_writer_creates_valid_nrml(self):
        self.as_writer.serialize([self.area_source])

        xml_doc = etree.parse(OUTPUT_NRML)
        xml_schema = etree.XMLSchema(etree.parse(SCHEMA))

        self.assertTrue(xml_schema.validate(xml_doc))
Exemple #2
0
from mtoolkit.catalog_filter import CatalogFilter, SourceModelCatalogFilter

if __name__ == '__main__':

    CMD_LINE_ARGS = cmd_line()

    if CMD_LINE_ARGS:

        INPUT_CONFIG_FILENAME = CMD_LINE_ARGS.input_file[0]

        LOG_LEVEL = logging.DEBUG if CMD_LINE_ARGS.detailed else logging.INFO

        build_logger(LOG_LEVEL)

        CONTEXT = Context(INPUT_CONFIG_FILENAME)

        PIPELINE_PREPROCESSING = PreprocessingBuilder().build(CONTEXT.config)

        PIPELINE_PROCESSING = ProcessingBuilder().build(CONTEXT.config)

        if CONTEXT.config['source_model_file']:
            CATALOG_FILTER = CatalogFilter(SourceModelCatalogFilter())
        else:
            CATALOG_FILTER = CatalogFilter()

        WORKFLOW = Workflow(PIPELINE_PREPROCESSING, PIPELINE_PROCESSING)
        WORKFLOW.start(CONTEXT, CATALOG_FILTER)

        WRITER = AreaSourceWriter(CONTEXT.config['result_file'])
        WRITER.serialize(CONTEXT.sm_definitions)