43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
from pytest import fixture, raises
|
|
from pathlib import Path
|
|
from rougail import Rougail, RougailConfig
|
|
from rougail.output_hcl import RougailOutputHcl as RougailOutput
|
|
from rougail.error import DictConsistencyError
|
|
|
|
|
|
EXT = 'hcl'
|
|
|
|
|
|
structures = list((Path(__file__).parent / 'errors').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()
|
|
with Path(str(test_file.absolute()) + ".errno").open() as fh:
|
|
error_no = int(fh.read().strip())
|
|
with raises(DictConsistencyError) as err:
|
|
generated_output = RougailOutput(config, rougailconfig=rougailconfig).run()[1]
|
|
assert err.value.errno == error_no, f'expected errno: {error_no}, errno: {err.value.errno}, msg: {err}'
|
|
|
|
|
|
def test_structural_files_hcl(test_file):
|
|
_test_structural_files(test_file, EXT)
|