rougail-user-data-environment/tests/test_load.py
2024-09-23 14:34:15 +02:00

81 lines
2.5 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from .custom import CustomOption
from pathlib import Path
from pytest import fixture # , raises
from ruamel.yaml import YAML
from rougail import RougailConfig, Rougail
#from tiramisu import Config
#from rougail.output_doc import RougailOutputDoc
dico_dirs = Path('../rougail/tests/dictionaries')
#test_ok = set()
#excludes = set([
# '60_5family_dynamic_unknown_suffix',
# '60_5family_dynamic_variable_outside_sub_suffix',
#])
#for test in dico_dirs.iterdir():
# if (test / 'tiramisu').is_dir() and test.name not in excludes:
# test_ok.add(test)
#test_ok = list(test_ok)
#test_ok.sort()
test_ok = [dico_dirs / '60_0family_dynamic_variable_suffix']
@fixture(scope="module", params=test_ok)
def test_dir(request):
return request.param
def _test_dictionaries(test_dir):
rougailconfig = RougailConfig.copy()
# rougailconfig['step.output'] = 'environment'
dirs = [str(test_dir / 'dictionaries' / 'rougail')]
rougailconfig['custom_types']['custom'] = CustomOption
rougailconfig['main_dictionaries'] = dirs
return rougailconfig
#def option_value(parent, key_is_option=False):
# for option, value in parent.items():
# if option.isoptiondescription():
# if not key_is_option and option.isleadership():
# ret = []
# for idx, datas in enumerate(option_value(value, key_is_option=True)):
# sub_option, sub_value = datas
# if not idx:
# sub_option = sub_option.path()
# key = sub_option
# for val in sub_value:
# ret.append({sub_option: val})
# else:
# index = sub_option.index()
# sub_option = sub_option.path()
# ret[index][sub_option] = sub_value
# yield key, ret
# else:
# yield from option_value(value, key_is_option)
# elif key_is_option:
# yield option, value
# else:
# yield option.path(), value
def test_dictionaries_warning(test_dir):
rougailconfig = _test_dictionaries(test_dir)
# loads the config in the tiramisu's meaning
config = Rougail(rougailconfig).run() #Config(optiondescription["option_0"])
print(type(config))
# config_dict = dict(option_value(config.value.get()))
# print(config_dict)
#def test_dictionaries_asciidoc(test_dir):
# _test_dictionaries(test_dir, 'asciidoc', True)