48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
from pytest import fixture # , raises
|
|
from pathlib import Path
|
|
from rougail import Rougail, RougailConfig
|
|
from rougail.output_hcl import RougailOutputHcl as RougailOutput
|
|
|
|
|
|
|
|
EXT = 'hcl'
|
|
|
|
|
|
structures = list((Path(__file__).parent / 'structures').glob("*.yaml"))
|
|
structures.sort()
|
|
|
|
|
|
def idfn(fixture_value):
|
|
return fixture_value.name
|
|
|
|
|
|
@fixture(scope="module", params=structures, ids=idfn)
|
|
def test_file(request):
|
|
return request.param
|
|
|
|
|
|
def _test_structural_files(test_file, ext):
|
|
rougailconfig = RougailConfig.copy()
|
|
##################################
|
|
rougailconfig['step.output'] = 'hcl'
|
|
rougailconfig["main_namespace"] = None
|
|
rougailconfig["main_structural_directories"] = [str(test_file.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 / 'results' / (test_file.name + "." + ext)
|
|
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_structural_files_hcl(test_file):
|
|
_test_structural_files(test_file, EXT)
|