Semprini / pyMDG

UML Model Driven Generation of schema, code, data and documentation.
Other
21 stars 10 forks source link

Ability to generate test case data in yaml #70

Closed Semprini closed 6 months ago

Semprini commented 7 months ago

render.py: ` for case in test_cases: serialised_json = json.dumps(serialize_instance(case), indent=2) serialised_yaml = yaml.dump(serialize_instance(case), Dumper=yaml.CDumper)

    template_definition: Dict
    for template_definition in settings['test_templates']:
        filename_template: Template = env.from_string(template_definition['dest'])
        filename: str = os.path.abspath(filename_template.render(ins=case))
        dirname: str = os.path.dirname(filename)

        # make sure computed distination path exists
        if not os.path.exists(dirname):
            os.makedirs(dirname)

        with open(filename, 'w') as fh:
            if filename[-4:] in ['yaml', '.yml']:
                fh.write(serialised_yaml)
            else:
                fh.write(serialised_json)`