diff --git a/tests/makedict/00_6string/output.json b/tests/makedict/00_6string/output.json deleted file mode 100644 index a97f88d..0000000 --- a/tests/makedict/00_6string/output.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rougail.var1": "string1", - "rougail.var2": "string1", - "rougail.var3": "string1", - "rougail.var4": "string1", - "rougail.var5": "string1", - "rougail.var6": "string1" -} diff --git a/tests/test_load.py b/tests/test_load.py index be6d8eb..62629f9 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -18,20 +18,22 @@ dico_dirs = Path('../rougail/tests/dictionaries') #env_test_folder = '00_6string' # path configuration -_here = Path(__file__).resolve().parent -envtest = _here / 'tests' / 'envvars' +#_here = Path(__file__).resolve().parent +#envtest = _here / 'tests' / 'envvars' +#test_ok = [dico_dirs / env_test_folder] test_ok = set() -test_raise = set() -for test in listdir(dico_dirs): - test_ok.add(test) - if test != '__pycache__': - test_raise.add(test) - -#test_ok = [dico_dirs / env_test_folder] excludes = set() test_ok -= excludes +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() + + @fixture(scope="module", params=test_ok) def test_dir(request): return request.param @@ -42,7 +44,7 @@ def _test_dictionaries(test_dir): rougailconfig = RougailConfig.copy() rougailconfig['step.user_data'] = ['environment'] rougailconfig['main_namespace'] = None - dirs = [str(test_dir + '/dictionaries/rougail')] + dirs = [str(test_dir / 'dictionaries' / 'rougail')] rougailconfig['custom_types']['custom'] = CustomOption rougailconfig['main_dictionaries'] = dirs return rougailconfig @@ -50,6 +52,7 @@ def _test_dictionaries(test_dir): def test_dictionaries_warning(test_dir): "tests the '00_6string' folder" + current_dirname = test_dir.name rougailconfig = _test_dictionaries(test_dir) # populate tests if not already exists dest_dir = Path('tests') / 'envvars' / test_dir.name @@ -72,7 +75,7 @@ def test_dictionaries_warning(test_dir): 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: + with open(Path('tests') / 'envvars' / current_dirname / 'makedict' / 'all.env') as json_file: expected = json.load(json_file) # here is the effective test for key, value in new_config_dict.items(): @@ -83,6 +86,8 @@ def populate(dest_dir, rougailconfig): for level in ['all', 'mandatories']: environment_file = dest_dir / 'env' / f'{level}.env' makedict_file = dest_dir / 'makedict' / f'{level}.env' + environment_file.parent.mkdir(parents=True, exist_ok=True) + makedict_file.parent.mkdir(parents=True, exist_ok=True) if not environment_file.is_file() or not makedict_file.is_file(): config = Rougail(rougailconfig).run() if level == 'all': @@ -94,8 +99,11 @@ def populate(dest_dir, rougailconfig): with environment_file.open('w') as envfh: envfh.write('\n'.join(values) + '\n') if not makedict_file.is_file(): - with environment_file.open('w') as envfh: - envfh.write('\n'.join(values) + '\n') + with makedict_file.open('w') as envfh: + #envfh.write('\n'.join(values) + '\n') + config_dict = dict(option_value(config.value.get())) + dump(config_dict, fh, indent=4) + envfh.write('\n') def get_value(variable):