From e14a83c5cd8eb3172b6713217d52ab0d597b9296 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 22 Sep 2025 14:29:45 +0200 Subject: [PATCH] fix: dictionary => structure --- ..._4disabled_calcultion_follower_index.json} | 65 +++++----- ...4_4disabled_calcultion_follower_index.json | 119 ++++++++++++++++++ ..._4disabled_calcultion_follower_index.json} | 65 +++++----- ...4_4disabled_calcultion_follower_index.json | 119 ++++++++++++++++++ .../60_8family_dynamic_same_name_1.json | 94 -------------- ..._4disabled_calcultion_follower_index.json} | 65 +++++----- .../60_8family_dynamic_same_name_1.json | 19 --- tests/test_load.py | 40 +++--- 8 files changed, 363 insertions(+), 223 deletions(-) rename tests/results/{test_namespace_read_write/60_8family_dynamic_same_name_1.json => test_namespace/44_4disabled_calcultion_follower_index.json} (55%) create mode 100644 tests/results/test_namespace_mandatory/44_4disabled_calcultion_follower_index.json rename tests/results/{test_namespace/60_8family_dynamic_same_name_1.json => test_namespace_read_write/44_4disabled_calcultion_follower_index.json} (54%) create mode 100644 tests/results/test_namespace_read_write_mandatory/44_4disabled_calcultion_follower_index.json delete mode 100644 tests/results/test_namespace_read_write_mandatory/60_8family_dynamic_same_name_1.json rename tests/results/{test_namespace_mandatory/60_8family_dynamic_same_name_1.json => test_namespace_read_write_mandatory_errors/44_4disabled_calcultion_follower_index.json} (54%) delete mode 100644 tests/results/test_namespace_read_write_mandatory_errors/60_8family_dynamic_same_name_1.json diff --git a/tests/results/test_namespace_read_write/60_8family_dynamic_same_name_1.json b/tests/results/test_namespace/44_4disabled_calcultion_follower_index.json similarity index 55% rename from tests/results/test_namespace_read_write/60_8family_dynamic_same_name_1.json rename to tests/results/test_namespace/44_4disabled_calcultion_follower_index.json index 8594f12..96cc282 100644 --- a/tests/results/test_namespace_read_write/60_8family_dynamic_same_name_1.json +++ b/tests/results/test_namespace/44_4disabled_calcultion_follower_index.json @@ -4,66 +4,71 @@ "GROUP1_01": { "ansible_host": "group1.net", "rougail": { - "manual": { - "https_proxy": { - "address": null + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": null + { + "leader": "b", + "follower": "value" } - } + ] } }, "GROUP2_01": { "ansible_host": "group2.net", "rougail": { - "manual": { - "https_proxy": { - "address": null + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": null + { + "leader": "b", + "follower": "value" } - } + ] } }, "GROUP2_02": { "ansible_host": "group3.net", "rougail": { - "manual": { - "https_proxy": { - "address": null + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": null + { + "leader": "b", + "follower": "value" } - } + ] } }, "group4.net": { "ansible_host": "group4.net", "rougail": { - "manual": { - "https_proxy": { - "address": null + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": null + { + "leader": "b", + "follower": "value" } - } + ] } }, "group5.net": { "ansible_host": "group5.net", "rougail": { - "manual": { - "https_proxy": { - "address": null + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": null + { + "leader": "b", + "follower": "value" } - } + ] } } } diff --git a/tests/results/test_namespace_mandatory/44_4disabled_calcultion_follower_index.json b/tests/results/test_namespace_mandatory/44_4disabled_calcultion_follower_index.json new file mode 100644 index 0000000..49c5528 --- /dev/null +++ b/tests/results/test_namespace_mandatory/44_4disabled_calcultion_follower_index.json @@ -0,0 +1,119 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "leadership": [ + { + "leader": "string1" + }, + { + "leader": "string2", + "follower": "string2" + }, + { + "leader": "string3", + "follower": "string3" + } + ] + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "leadership": [ + { + "leader": "string1" + }, + { + "leader": "string2", + "follower": "string2" + }, + { + "leader": "string3", + "follower": "string3" + } + ] + } + }, + "GROUP2_02": { + "ansible_host": "group3.net", + "rougail": { + "leadership": [ + { + "leader": "string1" + }, + { + "leader": "string2", + "follower": "string2" + }, + { + "leader": "string3", + "follower": "string3" + } + ] + } + }, + "group4.net": { + "ansible_host": "group4.net", + "rougail": { + "leadership": [ + { + "leader": "string1" + }, + { + "leader": "string2", + "follower": "string2" + }, + { + "leader": "string3", + "follower": "string3" + } + ] + } + }, + "group5.net": { + "ansible_host": "group5.net", + "rougail": { + "leadership": [ + { + "leader": "string1" + }, + { + "leader": "string2", + "follower": "string2" + }, + { + "leader": "string3", + "follower": "string3" + } + ] + } + } + } + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01", + "GROUP2_02" + ] + }, + "group3": { + "hosts": [ + "group4.net", + "group5.net" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} \ No newline at end of file diff --git a/tests/results/test_namespace/60_8family_dynamic_same_name_1.json b/tests/results/test_namespace_read_write/44_4disabled_calcultion_follower_index.json similarity index 54% rename from tests/results/test_namespace/60_8family_dynamic_same_name_1.json rename to tests/results/test_namespace_read_write/44_4disabled_calcultion_follower_index.json index c495cc9..96cc282 100644 --- a/tests/results/test_namespace/60_8family_dynamic_same_name_1.json +++ b/tests/results/test_namespace_read_write/44_4disabled_calcultion_follower_index.json @@ -4,66 +4,71 @@ "GROUP1_01": { "ansible_host": "group1.net", "rougail": { - "manual": { - "https_proxy": { - "address": "string1" + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": "string1" + { + "leader": "b", + "follower": "value" } - } + ] } }, "GROUP2_01": { "ansible_host": "group2.net", "rougail": { - "manual": { - "https_proxy": { - "address": "string1" + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": "string1" + { + "leader": "b", + "follower": "value" } - } + ] } }, "GROUP2_02": { "ansible_host": "group3.net", "rougail": { - "manual": { - "https_proxy": { - "address": "string1" + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": "string1" + { + "leader": "b", + "follower": "value" } - } + ] } }, "group4.net": { "ansible_host": "group4.net", "rougail": { - "manual": { - "https_proxy": { - "address": "string1" + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": "string1" + { + "leader": "b", + "follower": "value" } - } + ] } }, "group5.net": { "ansible_host": "group5.net", "rougail": { - "manual": { - "https_proxy": { - "address": "string1" + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": "string1" + { + "leader": "b", + "follower": "value" } - } + ] } } } diff --git a/tests/results/test_namespace_read_write_mandatory/44_4disabled_calcultion_follower_index.json b/tests/results/test_namespace_read_write_mandatory/44_4disabled_calcultion_follower_index.json new file mode 100644 index 0000000..49c5528 --- /dev/null +++ b/tests/results/test_namespace_read_write_mandatory/44_4disabled_calcultion_follower_index.json @@ -0,0 +1,119 @@ +{ + "_meta": { + "hostvars": { + "GROUP1_01": { + "ansible_host": "group1.net", + "rougail": { + "leadership": [ + { + "leader": "string1" + }, + { + "leader": "string2", + "follower": "string2" + }, + { + "leader": "string3", + "follower": "string3" + } + ] + } + }, + "GROUP2_01": { + "ansible_host": "group2.net", + "rougail": { + "leadership": [ + { + "leader": "string1" + }, + { + "leader": "string2", + "follower": "string2" + }, + { + "leader": "string3", + "follower": "string3" + } + ] + } + }, + "GROUP2_02": { + "ansible_host": "group3.net", + "rougail": { + "leadership": [ + { + "leader": "string1" + }, + { + "leader": "string2", + "follower": "string2" + }, + { + "leader": "string3", + "follower": "string3" + } + ] + } + }, + "group4.net": { + "ansible_host": "group4.net", + "rougail": { + "leadership": [ + { + "leader": "string1" + }, + { + "leader": "string2", + "follower": "string2" + }, + { + "leader": "string3", + "follower": "string3" + } + ] + } + }, + "group5.net": { + "ansible_host": "group5.net", + "rougail": { + "leadership": [ + { + "leader": "string1" + }, + { + "leader": "string2", + "follower": "string2" + }, + { + "leader": "string3", + "follower": "string3" + } + ] + } + } + } + }, + "group1": { + "hosts": [ + "GROUP1_01" + ] + }, + "group2": { + "hosts": [ + "GROUP2_01", + "GROUP2_02" + ] + }, + "group3": { + "hosts": [ + "group4.net", + "group5.net" + ] + }, + "groups": { + "children": [ + "group1", + "group2" + ] + } +} \ No newline at end of file diff --git a/tests/results/test_namespace_read_write_mandatory/60_8family_dynamic_same_name_1.json b/tests/results/test_namespace_read_write_mandatory/60_8family_dynamic_same_name_1.json deleted file mode 100644 index c495cc9..0000000 --- a/tests/results/test_namespace_read_write_mandatory/60_8family_dynamic_same_name_1.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "_meta": { - "hostvars": { - "GROUP1_01": { - "ansible_host": "group1.net", - "rougail": { - "manual": { - "https_proxy": { - "address": "string1" - }, - "socks_proxy": { - "address": "string1" - } - } - } - }, - "GROUP2_01": { - "ansible_host": "group2.net", - "rougail": { - "manual": { - "https_proxy": { - "address": "string1" - }, - "socks_proxy": { - "address": "string1" - } - } - } - }, - "GROUP2_02": { - "ansible_host": "group3.net", - "rougail": { - "manual": { - "https_proxy": { - "address": "string1" - }, - "socks_proxy": { - "address": "string1" - } - } - } - }, - "group4.net": { - "ansible_host": "group4.net", - "rougail": { - "manual": { - "https_proxy": { - "address": "string1" - }, - "socks_proxy": { - "address": "string1" - } - } - } - }, - "group5.net": { - "ansible_host": "group5.net", - "rougail": { - "manual": { - "https_proxy": { - "address": "string1" - }, - "socks_proxy": { - "address": "string1" - } - } - } - } - } - }, - "group1": { - "hosts": [ - "GROUP1_01" - ] - }, - "group2": { - "hosts": [ - "GROUP2_01", - "GROUP2_02" - ] - }, - "group3": { - "hosts": [ - "group4.net", - "group5.net" - ] - }, - "groups": { - "children": [ - "group1", - "group2" - ] - } -} \ No newline at end of file diff --git a/tests/results/test_namespace_mandatory/60_8family_dynamic_same_name_1.json b/tests/results/test_namespace_read_write_mandatory_errors/44_4disabled_calcultion_follower_index.json similarity index 54% rename from tests/results/test_namespace_mandatory/60_8family_dynamic_same_name_1.json rename to tests/results/test_namespace_read_write_mandatory_errors/44_4disabled_calcultion_follower_index.json index c495cc9..96cc282 100644 --- a/tests/results/test_namespace_mandatory/60_8family_dynamic_same_name_1.json +++ b/tests/results/test_namespace_read_write_mandatory_errors/44_4disabled_calcultion_follower_index.json @@ -4,66 +4,71 @@ "GROUP1_01": { "ansible_host": "group1.net", "rougail": { - "manual": { - "https_proxy": { - "address": "string1" + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": "string1" + { + "leader": "b", + "follower": "value" } - } + ] } }, "GROUP2_01": { "ansible_host": "group2.net", "rougail": { - "manual": { - "https_proxy": { - "address": "string1" + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": "string1" + { + "leader": "b", + "follower": "value" } - } + ] } }, "GROUP2_02": { "ansible_host": "group3.net", "rougail": { - "manual": { - "https_proxy": { - "address": "string1" + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": "string1" + { + "leader": "b", + "follower": "value" } - } + ] } }, "group4.net": { "ansible_host": "group4.net", "rougail": { - "manual": { - "https_proxy": { - "address": "string1" + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": "string1" + { + "leader": "b", + "follower": "value" } - } + ] } }, "group5.net": { "ansible_host": "group5.net", "rougail": { - "manual": { - "https_proxy": { - "address": "string1" + "leadership": [ + { + "leader": "a" }, - "socks_proxy": { - "address": "string1" + { + "leader": "b", + "follower": "value" } - } + ] } } } diff --git a/tests/results/test_namespace_read_write_mandatory_errors/60_8family_dynamic_same_name_1.json b/tests/results/test_namespace_read_write_mandatory_errors/60_8family_dynamic_same_name_1.json deleted file mode 100644 index dbfc8f5..0000000 --- a/tests/results/test_namespace_read_write_mandatory_errors/60_8family_dynamic_same_name_1.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "_meta": { - "hostvars": { - "localhost": { - "_errors": [ - "The following variables are mandatory but have no value:", - " - rougail.manual.https_proxy.address ({{ identifier }} address)", - " - rougail.manual.https_proxy.address (HTTPS address)", - " - rougail.manual.socks_proxy.address (SOCKS address)" - ] - } - } - }, - "ungrouped": { - "hosts": [ - "localhost" - ] - } -} \ No newline at end of file diff --git a/tests/test_load.py b/tests/test_load.py index 122ccf4..5bf3923 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -31,7 +31,7 @@ def test_dir(request): return request.param -def _test_dictionaries(test_dir, namespace, ext, *, read_write=True, mandatory=False, do_calc=True): +def _test_structural_files(test_dir, namespace, ext, *, read_write=True, mandatory=False, do_calc=True): rougailconfig = get_rougail_config(test_dir, namespace) if not rougailconfig: return @@ -39,9 +39,9 @@ def _test_dictionaries(test_dir, namespace, ext, *, read_write=True, mandatory=F rougailconfig['step.output'] = 'ansible' rougailconfig["json.read_write"] = read_write rougailconfig["json.mandatory"] = mandatory - extra_dictionaries = rougailconfig["extra_dictionaries"] - extra_dictionaries["hosts"] = [str(Path(__file__).parent / "hosts")] - rougailconfig['extra_dictionaries'] = extra_dictionaries + extra_namespaces = rougailconfig["extra_namespaces"] + extra_namespaces["hosts"] = [str(Path(__file__).parent / "hosts")] + rougailconfig['extra_namespaces'] = extra_namespaces ################################## dir_name = 'test' if namespace: @@ -79,24 +79,24 @@ def _test_dictionaries(test_dir, namespace, ext, *, read_write=True, mandatory=F # do not test without namespace, ansible needs namespaces -def test_dictionaries_ansible_namespace(test_dir): - _test_dictionaries(test_dir, True, EXT) +def test_structural_files_ansible_namespace(test_dir): + _test_structural_files(test_dir, True, EXT) -def test_dictionaries_ansible_namespace_errors(test_dir): - _test_dictionaries(test_dir, True, EXT, do_calc=False, mandatory=True) +def test_structural_files_ansible_namespace_errors(test_dir): + _test_structural_files(test_dir, True, EXT, do_calc=False, mandatory=True) -def test_dictionaries_ansible_namespace_read_only(test_dir): - _test_dictionaries(test_dir, True, EXT, read_write=False) +def test_structural_files_ansible_namespace_read_only(test_dir): + _test_structural_files(test_dir, True, EXT, read_write=False) -def test_dictionaries_ansible_namespace_mandatory(test_dir): - _test_dictionaries(test_dir, True, EXT, mandatory=True) +def test_structural_files_ansible_namespace_mandatory(test_dir): + _test_structural_files(test_dir, True, EXT, mandatory=True) -def test_dictionaries_ansible_namespace_mandatory_read_only(test_dir): - _test_dictionaries(test_dir, True, EXT, read_write=False, mandatory=True) +def test_structural_files_ansible_namespace_mandatory_read_only(test_dir): + _test_structural_files(test_dir, True, EXT, read_write=False, mandatory=True) def test_warnings(): @@ -105,9 +105,9 @@ def test_warnings(): rougailconfig['step.output'] = 'ansible' rougailconfig['step.user_data'] = ['yaml'] rougailconfig['yaml.filename'] = ['tests/warnings/yaml/config.yml'] - extra_dictionaries = rougailconfig["extra_dictionaries"] - extra_dictionaries["hosts"] = [str(Path(__file__).parent / "hosts")] - rougailconfig['extra_dictionaries'] = extra_dictionaries + extra_namespaces = rougailconfig["extra_namespaces"] + extra_namespaces["hosts"] = [str(Path(__file__).parent / "hosts")] + rougailconfig['extra_namespaces'] = extra_namespaces ################################## rougail = Rougail(rougailconfig) config = rougail.run() @@ -201,9 +201,9 @@ def test_no_warnings(): rougailconfig['ansible.export_warnings'] = False rougailconfig['step.user_data'] = ['yaml'] rougailconfig['yaml.filename'] = ['tests/warnings/yaml/config.yml'] - extra_dictionaries = rougailconfig["extra_dictionaries"] - extra_dictionaries["hosts"] = [str(Path(__file__).parent / "hosts")] - rougailconfig['extra_dictionaries'] = extra_dictionaries + extra_namespaces = rougailconfig["extra_namespaces"] + extra_namespaces["hosts"] = [str(Path(__file__).parent / "hosts")] + rougailconfig['extra_namespaces'] = extra_namespaces ################################## rougail = Rougail(rougailconfig) config = rougail.run()