test works
This commit is contained in:
parent
763788858a
commit
ca6b933453
4 changed files with 31 additions and 32 deletions
|
@ -1,8 +0,0 @@
|
||||||
ROUGAIL_VARNAME2="tata"
|
|
||||||
ROUGAIL_VARNAME1="titi"
|
|
||||||
ROUGAIL_VARNAME23=" 18, 25 "
|
|
||||||
ROUGAIL_VARINT="5"
|
|
||||||
ROUGAIL_VARNAME34=" 58, 22 "
|
|
||||||
ROUGAIL_IDONTEXIST="blah"
|
|
||||||
ROUGAIL_IDONTEXIST2="hum"
|
|
||||||
ROUGAIL_myfamily.varname3='spam'
|
|
8
tests/envvars/00_6string/env
Normal file
8
tests/envvars/00_6string/env
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
ROUGAIL_VAR1="spam"
|
||||||
|
ROUGAIL_VAR2="egg"
|
||||||
|
ROUGAIL_VAR3="hugh"
|
||||||
|
ROUGAIL_VAR4="some"
|
||||||
|
ROUGAIL_VAR5="part"
|
||||||
|
ROUGAIL_VAR6="ming"
|
||||||
|
ROUGAIL_IDONTEXIST="blah"
|
||||||
|
ROUGAIL_IDONTEXIST2="hum"
|
8
tests/makedict/00_6string/output.json
Normal file
8
tests/makedict/00_6string/output.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"rougail.var1": "spam",
|
||||||
|
"rougail.var2": "egg",
|
||||||
|
"rougail.var3": "hugh",
|
||||||
|
"rougail.var4": "some",
|
||||||
|
"rougail.var5": "part",
|
||||||
|
"rougail.var6": "ming"
|
||||||
|
}
|
|
@ -2,27 +2,19 @@ from .custom import CustomOption
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
from pytest import fixture # , raises
|
from pytest import fixture
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
from rougail import RougailConfig, Rougail
|
from rougail import RougailConfig, Rougail
|
||||||
#from tiramisu import Config
|
|
||||||
from rougail.user_data_environment.data import RougailUserDataEnvironment
|
from rougail.user_data_environment.data import RougailUserDataEnvironment
|
||||||
|
|
||||||
|
|
||||||
dico_dirs = Path('../rougail/tests/dictionaries')
|
dico_dirs = Path('../rougail/tests/dictionaries')
|
||||||
#test_ok = set()
|
env_test_folder = '00_6string'
|
||||||
|
test_ok = [dico_dirs / env_test_folder]
|
||||||
#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)
|
@fixture(scope="module", params=test_ok)
|
||||||
|
@ -31,6 +23,7 @@ def test_dir(request):
|
||||||
|
|
||||||
|
|
||||||
def _test_dictionaries(test_dir):
|
def _test_dictionaries(test_dir):
|
||||||
|
"rougail config settings"
|
||||||
rougailconfig = RougailConfig.copy()
|
rougailconfig = RougailConfig.copy()
|
||||||
rougailconfig['step.user_data'] = ['environment']
|
rougailconfig['step.user_data'] = ['environment']
|
||||||
rougailconfig['main_namespace'] = None
|
rougailconfig['main_namespace'] = None
|
||||||
|
@ -41,30 +34,28 @@ def _test_dictionaries(test_dir):
|
||||||
|
|
||||||
|
|
||||||
def test_dictionaries_warning(test_dir):
|
def test_dictionaries_warning(test_dir):
|
||||||
|
"tests the '00_6string' folder"
|
||||||
rougailconfig = _test_dictionaries(test_dir)
|
rougailconfig = _test_dictionaries(test_dir)
|
||||||
# loads the config in the tiramisu's meaning
|
# loads the config in the tiramisu's meaning
|
||||||
config = Rougail(rougailconfig).run() #Config(optiondescription["option_0"])
|
config = Rougail(rougailconfig).run() #Config(optiondescription["option_0"])
|
||||||
config_dict = dict(config.value.get())
|
config_dict = dict(config.value.get())
|
||||||
#print(config_dict)
|
|
||||||
user_datas = {'errors': [],
|
user_datas = {'errors': [],
|
||||||
'warnings': [],
|
'warnings': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
# loading the env file
|
# loading the env file
|
||||||
envfile = Path('tests') / 'envvars' / '00_10_env_var' / 'env'
|
envfile = Path('tests') / 'envvars' / env_test_folder / 'env'
|
||||||
load_dotenv(envfile)
|
load_dotenv(envfile)
|
||||||
|
# loads the environment variables in the tiramisu config
|
||||||
environment = RougailUserDataEnvironment(config,
|
environment = RougailUserDataEnvironment(config,
|
||||||
rougailconfig=rougailconfig,
|
rougailconfig=rougailconfig,
|
||||||
user_datas=user_datas,
|
user_datas=user_datas,
|
||||||
)
|
)
|
||||||
environment.run()
|
environment.run()
|
||||||
new_config = environment.config
|
new_config = environment.config
|
||||||
#print(user_datas)
|
|
||||||
#print(os.getenv("ROUGAIL_VARNAME23"))
|
|
||||||
new_config_dict = dict(new_config.value.get())
|
new_config_dict = dict(new_config.value.get())
|
||||||
# print(new_config_dict)
|
# expected output
|
||||||
assert str(new_config_dict) == """{<TiramisuOption path="varname23">: ['18', '25'], <TiramisuOption path="varname34">: [58, 22], <TiramisuOption path="varname1">: 'titi', <TiramisuOption path="varint">: 2, <TiramisuOption path="varname2">: 'tata', <TiramisuOption path="myfamily">: {<TiramisuOption path="myfamily.varname3">: 'egg'}}"""
|
with open(Path('tests') / 'makedict' / env_test_folder / 'output.json') as json_file:
|
||||||
|
expected = json.load(json_file)
|
||||||
#def test_dictionaries_asciidoc(test_dir):
|
# here is the effective test
|
||||||
# _test_dictionaries(test_dir, 'asciidoc', True)
|
for key, value in new_config_dict.items():
|
||||||
|
assert expected["rougail."+key.name()] == value
|
||||||
|
|
Loading…
Reference in a new issue