37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
from pytest import raises
|
|
from pathlib import Path
|
|
from rougail import Rougail, RougailConfig
|
|
from rougail.output_hcl import RougailOutputHcl as RougailOutput
|
|
from rougail.error import DictConsistencyError
|
|
|
|
|
|
def _test_types(name):
|
|
rougailconfig = RougailConfig.copy()
|
|
##################################
|
|
rougailconfig['step.output'] = 'hcl'
|
|
rougailconfig["main_namespace"] = None
|
|
rougailconfig["types"] = [str((Path(__file__).parent / 'types' / name / 'types').absolute())]
|
|
rougailconfig["main_structural_directories"] = [str((Path(__file__).parent / 'types' / name / 'structures').absolute())]
|
|
##################################
|
|
rougail = Rougail(rougailconfig)
|
|
config = rougail.run()
|
|
config.information.set("description_type", "path_and_description")
|
|
config.property.read_only()
|
|
generated_output = RougailOutput(config, rougailconfig=rougailconfig).run()[1]
|
|
output_file = Path(__file__).parent / 'types' / name / 'rougail.hcl'
|
|
if not output_file.is_file():
|
|
if not output_file.parent.is_dir():
|
|
output_file.parent.mkdir()
|
|
with output_file.open('w') as outfh:
|
|
outfh.write(generated_output)
|
|
with output_file.open() as outfh:
|
|
attented_output = outfh.read()
|
|
assert generated_output == attented_output, f'filename {output_file}'
|
|
|
|
|
|
def test_types_01():
|
|
_test_types('01-types')
|
|
|
|
|
|
def test_types_02():
|
|
_test_types('02-double')
|