from .custom import CustomOption from pathlib import Path import os from pytest import fixture # , raises from ruamel.yaml import YAML from dotenv import load_dotenv from rougail import RougailConfig, Rougail #from tiramisu import Config from rougail.user_data_environment.data import RougailUserDataEnvironment dico_dirs = Path('../rougail/tests/dictionaries') #test_ok = set() #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 / '00_10_env_var'] @fixture(scope="module", params=test_ok) def test_dir(request): return request.param def _test_dictionaries(test_dir): rougailconfig = RougailConfig.copy() rougailconfig['step.user_data'] = ['environment'] rougailconfig['main_namespace'] = None dirs = [str(test_dir / 'dictionaries' / 'rougail')] rougailconfig['custom_types']['custom'] = CustomOption rougailconfig['main_dictionaries'] = dirs return rougailconfig 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"]) config_dict = dict(config.value.get()) #print(config_dict) user_datas = {'errors': [], 'warnings': [], } # loading the env file envfile = Path('tests') / 'envvars' / '00_10_env_var' / 'env' load_dotenv(envfile) environment = RougailUserDataEnvironment(config, rougailconfig=rougailconfig, user_datas=user_datas, ) environment.run() new_config = environment.config #print(user_datas) #print(os.getenv("ROUGAIL_VARNAME23")) new_config_dict = dict(new_config.value.get()) # print(new_config_dict) assert str(new_config_dict) == """{: ['18', '25'], : [58, 22], : 'titi', : 2, : 'tata', : {: 'egg'}}""" #def test_dictionaries_asciidoc(test_dir): # _test_dictionaries(test_dir, 'asciidoc', True)