fix: update tests

This commit is contained in:
egarette@silique.fr 2025-11-05 21:35:11 +01:00
parent 9dad912ab3
commit f83b395f77
94 changed files with 608 additions and 2 deletions

View file

@ -0,0 +1,3 @@
---
a_family:
a_boolean: oups

View file

@ -0,0 +1,3 @@
---
a_str:
- ly

View file

@ -0,0 +1,2 @@
---
a_family: oups

View file

@ -0,0 +1,4 @@
---
a_leadership:
- a_leader: val1
a_follower: 1

View file

@ -0,0 +1,2 @@
---
a_multi: oups

View file

@ -0,0 +1,5 @@
---
a_family:
a_boolean:
- true

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"the value \"oups\" is an invalid boolean for \"a_family.a_boolean\" (A boolean), invalid value, it will be ignored when loading from the YAML file \"tests/invalid/invalid/00.yml\""
]
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"cannot set the value \"oups\" to the family \"a_family\" (A family), it will be ignored when loading from the YAML file \"tests/invalid/invalid_family/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"cannot set the value \"oups\" to the family \"a_family\" (A family), it will be ignored when loading from the YAML file \"tests/invalid/invalid_family/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"cannot set the value \"oups\" to the family \"a_family\" (A family), it will be ignored when loading from the YAML file \"tests/invalid/invalid_family/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"cannot set the value \"oups\" to the family \"a_family\" (A family), it will be ignored when loading from the YAML file \"tests/invalid/invalid_family/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"the value \"oups\" is an invalid boolean for \"a_family.a_boolean\" (A boolean), invalid value, it will be ignored when loading from the YAML file \"tests/invalid/invalid/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"the value \"oups\" is an invalid boolean for \"a_family.a_boolean\" (A boolean), invalid value, it will be ignored when loading from the YAML file \"tests/invalid/invalid/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"the value \"1\" is an invalid string for \"a_leadership.a_follower\" (A follower) at index \"0\", which is not a string, it will be ignored when loading from the YAML file \"tests/invalid/invalid_leadership/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"the value \"1\" is an invalid string for \"a_leadership.a_follower\" (A follower) at index \"0\", which is not a string, it will be ignored when loading from the YAML file \"tests/invalid/invalid_leadership/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"the value \"1\" is an invalid string for \"a_leadership.a_follower\" (A follower) at index \"0\", which is not a string, it will be ignored when loading from the YAML file \"tests/invalid/invalid_leadership/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"the value \"1\" is an invalid string for \"a_leadership.a_follower\" (A follower) at index \"0\", which is not a string, it will be ignored when loading from the YAML file \"tests/invalid/invalid_leadership/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"the value \"oups\" is an invalid string for \"a_multi\" (A multi), which must be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"the value \"[True]\" is an invalid boolean for \"a_family.a_boolean\" (A boolean), which must not be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi2/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"the value \"[True]\" is an invalid boolean for \"a_family.a_boolean\" (A boolean), which must not be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi2/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"the value \"[True]\" is an invalid boolean for \"a_family.a_boolean\" (A boolean), which must not be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi2/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"the value \"[True]\" is an invalid boolean for \"a_family.a_boolean\" (A boolean), which must not be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi2/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"the value \"oups\" is an invalid string for \"a_multi\" (A multi), which must be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"the value \"oups\" is an invalid string for \"a_multi\" (A multi), which must be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"the value \"oups\" is an invalid string for \"a_multi\" (A multi), which must be a list, it will be ignored when loading from the YAML file \"tests/invalid/invalid_multi/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"the value \"oups\" is an invalid boolean for \"a_family.a_boolean\" (A boolean), invalid value, it will be ignored when loading from the YAML file \"tests/invalid/invalid/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable or family \"a_family.unknown\" does not exist, it will be ignored when loading from the YAML file \"tests/invalid/unknown/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable or family \"an_unkown_family\" does not exist, it will be ignored when loading from the YAML file \"tests/invalid/unknown2/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable or family \"an_unkown_family\" does not exist, it will be ignored when loading from the YAML file \"tests/invalid/unknown2/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"variable or family \"an_unkown_family\" does not exist, it will be ignored when loading from the YAML file \"tests/invalid/unknown2/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"variable or family \"an_unkown_family\" does not exist, it will be ignored when loading from the YAML file \"tests/invalid/unknown2/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable or family \"a_family.unknown\" does not exist, it will be ignored when loading from the YAML file \"tests/invalid/unknown/00.yml\""
]
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"variable or family \"a_family.unknown\" does not exist, it will be ignored when loading from the YAML file \"tests/invalid/unknown/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"variable or family \"a_family.unknown\" does not exist, it will be ignored when loading from the YAML file \"tests/invalid/unknown/00.yml\""
],
"warnings": []
}

View file

@ -0,0 +1,23 @@
%YAML 1.2
---
version: 1.1
a_multi: [] # A multi
a_leadership:
description: A leadership
type: leadership
a_leader: # A leader
a_follower: # A follower
a_str: # A str
- val1
a_family: # A family
a_boolean: true # A boolean
a_fami{{ identifier }}: # A dynamic family
...

View file

@ -0,0 +1,3 @@
---
a_family:
unknown: oups

View file

@ -0,0 +1,3 @@
---
an_unkown_family:
unknown: oups

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,9 @@
{
"rougail": {
"var": [
1,
2,
3
]
}
}

View file

@ -0,0 +1,9 @@
{
"rougail": {
"var": [
1,
2,
3
]
}
}

View file

@ -0,0 +1,9 @@
{
"rougail": {
"var": [
1,
2,
3
]
}
}

View file

@ -0,0 +1,7 @@
{
"rougail.var": [
1,
2,
3
]
}

View file

@ -0,0 +1,7 @@
{
"rougail.var": [
1,
2,
3
]
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,6 @@
{
"rougail": {
"var1": "string1",
"var2": "string1"
}
}

View file

@ -0,0 +1,6 @@
{
"rougail": {
"var1": "string1",
"var2": "string1"
}
}

View file

@ -0,0 +1,6 @@
{
"rougail": {
"var1": "string1",
"var2": "string1"
}
}

View file

@ -0,0 +1,4 @@
{
"rougail.var1": "string1",
"rougail.var2": "string1"
}

View file

@ -0,0 +1,4 @@
{
"rougail.var1": "string1",
"rougail.var2": "string1"
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,5 @@
{
"rougail": {
"int": 1
}
}

View file

@ -0,0 +1,5 @@
{
"rougail": {
"int": 1
}
}

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,3 @@
{
"rougail.int": 1
}

View file

@ -0,0 +1,3 @@
{
"rougail.int": 1000
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,5 @@
{
"rougail": {
"int": 1
}
}

View file

@ -0,0 +1,5 @@
{
"rougail": {
"int": 1
}
}

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,3 @@
{
"rougail.int": 1
}

View file

@ -0,0 +1,3 @@
{
"rougail.int": 1000
}

View file

@ -0,0 +1,6 @@
{
"errors": [],
"warnings": [
"variable \"rougail.var\" (A suffix variable) is hidden, it will be ignored when loading from the YAML file \"tests/results/60_0family_dynamic_source_hidden/file/all.yml\""
]
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,14 @@
{
"rougail": {
"var": [
"val1",
"val2"
],
"dynval1": {
"var": "string1"
},
"dynval2": {
"var": "string1"
}
}
}

View file

@ -0,0 +1,14 @@
{
"rougail": {
"var": [
"val1",
"val2"
],
"dynval1": {
"var": "string1"
},
"dynval2": {
"var": "string1"
}
}
}

View file

@ -0,0 +1,10 @@
{
"rougail": {
"dynval1": {
"var": "string1"
},
"dynval2": {
"var": "string1"
}
}
}

View file

@ -0,0 +1,8 @@
{
"rougail.var": [
"val1",
"val2"
],
"rougail.dynval1.var": "string1",
"rougail.dynval2.var": "string1"
}

View file

@ -0,0 +1,8 @@
{
"rougail.var": [
"val1",
"val2"
],
"rougail.dynval1.var": "string1",
"rougail.dynval2.var": "string1"
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,12 @@
{
"rougail": {
"dynval1": {
"var1": "string1",
"var2": "string1"
},
"dynval2": {
"var1": "string1",
"var2": "string1"
}
}
}

View file

@ -0,0 +1,12 @@
{
"rougail": {
"dynval1": {
"var1": "string1",
"var2": "string1"
},
"dynval2": {
"var1": "string1",
"var2": "string1"
}
}
}

View file

@ -0,0 +1,12 @@
{
"rougail": {
"dynval1": {
"var1": "string1",
"var2": "string1"
},
"dynval2": {
"var1": "string1",
"var2": "string1"
}
}
}

View file

@ -0,0 +1,6 @@
{
"rougail.dynval1.var1": "string1",
"rougail.dynval1.var2": "string1",
"rougail.dynval2.var1": "string1",
"rougail.dynval2.var2": "string1"
}

View file

@ -0,0 +1,6 @@
{
"rougail.dynval1.var1": "string1",
"rougail.dynval1.var2": "string1",
"rougail.dynval2.var1": "string1",
"rougail.dynval2.var2": "string1"
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,4 @@
{
"errors": [],
"warnings": []
}

View file

@ -0,0 +1,11 @@
{
"rougail": {
"dynval1": {
"var1": "string1"
},
"dynval2": {
"var1": "string1"
},
"var2": "string1"
}
}

View file

@ -0,0 +1,11 @@
{
"rougail": {
"dynval1": {
"var1": "string1"
},
"dynval2": {
"var1": "string1"
},
"var2": "string1"
}
}

View file

@ -0,0 +1,11 @@
{
"rougail": {
"dynval1": {
"var1": "string1"
},
"dynval2": {
"var1": "string1"
},
"var2": "string1"
}
}

View file

@ -0,0 +1,5 @@
{
"rougail.dynval1.var1": "string1",
"rougail.dynval2.var1": "string1",
"rougail.var2": "string1"
}

View file

@ -0,0 +1,5 @@
{
"rougail.dynval1.var1": "string1",
"rougail.dynval2.var1": "string1",
"rougail.var2": "string1"
}

View file

@ -0,0 +1 @@
---

2
tests/secrets/secret.yml Normal file
View file

@ -0,0 +1,2 @@
---
secret1: my_password

68
tests/test_invalid.py Normal file
View file

@ -0,0 +1,68 @@
from pathlib import Path
from json import dump, load
from rougail import Rougail, RougailConfig
from rougail.user_data_yaml import RougailUserDataYaml
def _test_invalid_no_error(filename):
rougailconfig = RougailConfig.copy()
rougailconfig["main_namespace"] = None
rougailconfig["main_structural_directories"] = ["tests/invalid/structure"]
rougailconfig['step.user_data'] = ['yaml']
rougailconfig['yaml.filename'] = [f"tests/invalid/{filename}"]
rougail = Rougail(rougailconfig)
config = rougail.run()
for invalid_user_datas_error in [False, True]:
if invalid_user_datas_error:
ifilename = f"{filename}_invalid"
else:
ifilename = filename
for unknown_user_datas_error in [False, True]:
if unknown_user_datas_error:
ufilename = f"{ifilename}_unknown"
else:
ufilename = ifilename
generated_user_data = RougailUserDataYaml(config, rougailconfig=rougailconfig).run()
errors = rougail.user_datas(generated_user_data, invalid_user_datas_error=invalid_user_datas_error, unknown_user_datas_error=unknown_user_datas_error)
print(errors)
#expected output
expected_filename = Path('tests') / 'invalid' / 'results' / ufilename / "errors.json"
if not expected_filename.is_file():
expected_filename.parent.mkdir(parents=True, exist_ok=True)
with open(expected_filename, 'a') as json_file:
dump(errors, json_file, indent=4)
with open(expected_filename) as json_file:
expected_errors = load(json_file)
assert expected_errors == errors, expected_filename
def test_invalid():
_test_invalid_no_error("invalid")
def test_invalid_dyn():
_test_invalid_no_error("invalid_dyn")
def test_invalid_family():
_test_invalid_no_error("invalid_family")
def test_invalid_leadership():
_test_invalid_no_error("invalid_leadership")
def test_invalid_multi():
_test_invalid_no_error("invalid_multi")
def test_invalid_multi2():
_test_invalid_no_error("invalid_multi2")
def test_invalid_unknown():
_test_invalid_no_error("unknown")
def test_invalid_unknown2():
_test_invalid_no_error("unknown2")

View file

@ -20,7 +20,7 @@ excludes = [
]
test_ok = get_structures_list(excludes)
# test_ok = [Path('../rougail-tests/structures/60_6family_dynamic_sub_dynamic_empty2')]
# test_ok = [Path('../rougail-tests/structures/60_0family_dynamic_source_hidden')]
def idfn(fixture_value):
@ -304,4 +304,3 @@ def test_secret_last_error():
assert errors == {'errors': ['the variable "secret1" contains secrets and should not be defined in the YAML file "tests/secrets/secret.yml"'], 'warnings': []}
config_dict = dict(config_to_dict(config.value.get()))
assert config_dict == {'secret1': None, 'secret2': 'value'}