61 lines
2.1 KiB
Python
61 lines
2.1 KiB
Python
from .custom import CustomOption
|
||
|
||
from pathlib import Path
|
||
import os
|
||
import json
|
||
|
||
from pytest import fixture
|
||
from ruamel.yaml import YAML
|
||
from dotenv import load_dotenv
|
||
|
||
from rougail import RougailConfig, Rougail
|
||
from rougail.user_data_environment.data import RougailUserDataEnvironment
|
||
|
||
|
||
dico_dirs = Path('../rougail/tests/dictionaries')
|
||
env_test_folder = '00_6string'
|
||
test_ok = [dico_dirs / env_test_folder]
|
||
|
||
|
||
@fixture(scope="module", params=test_ok)
|
||
def test_dir(request):
|
||
return request.param
|
||
|
||
|
||
def _test_dictionaries(test_dir):
|
||
"rougail config settings"
|
||
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):
|
||
"tests the '00_6string' folder"
|
||
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())
|
||
user_datas = {'errors': [],
|
||
'warnings': [],
|
||
}
|
||
# loading the env file
|
||
envfile = Path('tests') / 'envvars' / env_test_folder / 'env'
|
||
load_dotenv(envfile)
|
||
# loads the environment variables in the tiramisu config
|
||
environment = RougailUserDataEnvironment(config,
|
||
rougailconfig=rougailconfig,
|
||
user_datas=user_datas,
|
||
)
|
||
environment.run()
|
||
new_config = environment.config
|
||
new_config_dict = dict(new_config.value.get())
|
||
# expected output
|
||
with open(Path('tests') / 'makedict' / env_test_folder / 'output.json') as json_file:
|
||
expected = json.load(json_file)
|
||
# here is the effective test
|
||
for key, value in new_config_dict.items():
|
||
assert expected["rougail."+key.name()] == value
|