feat: can link choice variable
This commit is contained in:
parent
18df35acfe
commit
dc311466a2
24 changed files with 193 additions and 30 deletions
|
|
@ -154,6 +154,8 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
variable.type = calculated_variable.type
|
||||
if variable.params is None and calculated_variable.params is not None:
|
||||
variable.params = calculated_variable.params
|
||||
if variable.type == 'choice' and variable.choices is None:
|
||||
variable.choices = calculated_variable.choices
|
||||
# copy multi attribut
|
||||
if variable.multi is None:
|
||||
calculated_path = calculated_variable.path
|
||||
|
|
|
|||
|
|
@ -657,9 +657,10 @@ class ParserVariable:
|
|||
if comment:
|
||||
obj["description"] = comment
|
||||
if extra_attrs:
|
||||
raise Exception(
|
||||
raise DictConsistencyError(
|
||||
f'"{path}" is not a valid variable, there are additional '
|
||||
f'attributes: "{", ".join(extra_attrs)}"'
|
||||
f'attributes: "{", ".join(extra_attrs)}"',
|
||||
65, [filename]
|
||||
)
|
||||
self.parse_parameters(
|
||||
path,
|
||||
|
|
|
|||
10
tests/dictionaries/00_6choice_link/makedict/after.json
Normal file
10
tests/dictionaries/00_6choice_link/makedict/after.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"rougail.var1": {
|
||||
"owner": "default",
|
||||
"value": null
|
||||
},
|
||||
"rougail.var2": {
|
||||
"owner": "default",
|
||||
"value": null
|
||||
}
|
||||
}
|
||||
4
tests/dictionaries/00_6choice_link/makedict/base.json
Normal file
4
tests/dictionaries/00_6choice_link/makedict/base.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"rougail.var1": null,
|
||||
"rougail.var2": null
|
||||
}
|
||||
10
tests/dictionaries/00_6choice_link/makedict/before.json
Normal file
10
tests/dictionaries/00_6choice_link/makedict/before.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"rougail.var1": {
|
||||
"owner": "default",
|
||||
"value": null
|
||||
},
|
||||
"rougail.var2": {
|
||||
"owner": "default",
|
||||
"value": null
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
["rougail.var1", "rougail.var2"]
|
||||
16
tests/dictionaries/00_6choice_link/tiramisu/base.py
Normal file
16
tests/dictionaries/00_6choice_link/tiramisu/base.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
from re import compile as re_compile
|
||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||
load_functions('../rougail-tests/funcs/test.py')
|
||||
try:
|
||||
groups.namespace
|
||||
except:
|
||||
groups.addgroup('namespace')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_2 = ChoiceOption(name="var1", doc="the first variable", values=("a", "b", "c"), properties=frozenset({"basic", "mandatory"}), informations={'type': 'choice'})
|
||||
option_3 = ChoiceOption(name="var2", doc="the second variable", values=("a", "b", "c"), default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"basic"}))
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
11
tests/dictionaries/00_6choice_link/tiramisu/no_namespace.py
Normal file
11
tests/dictionaries/00_6choice_link/tiramisu/no_namespace.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
from re import compile as re_compile
|
||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||
load_functions('../rougail-tests/funcs/test.py')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_1 = ChoiceOption(name="var1", doc="the first variable", values=("a", "b", "c"), properties=frozenset({"basic", "mandatory"}), informations={'type': 'choice'})
|
||||
option_2 = ChoiceOption(name="var2", doc="the second variable", values=("a", "b", "c"), default=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"rougail.var1": {
|
||||
"owner": "default",
|
||||
"value": [
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
"rougail.var2": {
|
||||
"owner": "default",
|
||||
"value": "a"
|
||||
},
|
||||
"rougail.var3": {
|
||||
"owner": "default",
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"rougail.var1": [
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
],
|
||||
"rougail.var2": "a",
|
||||
"rougail.var3": "a"
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"rougail.var1": {
|
||||
"owner": "default",
|
||||
"value": [
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
"rougail.var2": {
|
||||
"owner": "default",
|
||||
"value": "a"
|
||||
},
|
||||
"rougail.var3": {
|
||||
"owner": "default",
|
||||
"value": "a"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
17
tests/dictionaries/00_6choice_variable_link/tiramisu/base.py
Normal file
17
tests/dictionaries/00_6choice_variable_link/tiramisu/base.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
from re import compile as re_compile
|
||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||
load_functions('../rougail-tests/funcs/test.py')
|
||||
try:
|
||||
groups.namespace
|
||||
except:
|
||||
groups.addgroup('namespace')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_2 = StrOption(name="var1", doc="a second variable", multi=True, default=["a", "b", "c"], default_multi="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||
option_3 = ChoiceOption(name="var2", doc="a first variable", values=Calculation(func['calc_value'], Params((ParamOption(option_2)))), default="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
|
||||
option_4 = ChoiceOption(name="var3", doc="a third variable", values=Calculation(func['calc_value'], Params((ParamOption(option_2)))), default=Calculation(func['calc_value'], Params((ParamOption(option_3)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, option_4], properties=frozenset({"standard"}))
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
from re import compile as re_compile
|
||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||
load_functions('../rougail-tests/funcs/test.py')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_1 = StrOption(name="var1", doc="a second variable", multi=True, default=["a", "b", "c"], default_multi="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||
option_2 = ChoiceOption(name="var2", doc="a first variable", values=Calculation(func['calc_value'], Params((ParamOption(option_1)))), default="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
|
||||
option_3 = ChoiceOption(name="var3", doc="a third variable", values=Calculation(func['calc_value'], Params((ParamOption(option_1)))), default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3])
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
from re import compile as re_compile
|
||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||
load_functions('../rougail-tests/funcs/test.py')
|
||||
try:
|
||||
groups.namespace
|
||||
except:
|
||||
groups.addgroup('namespace')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_2 = StrOption(name="var1", doc="a second variable", multi=True, default=["a", "b", "c"], default_multi="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||
option_3 = ChoiceOption(name="var2", doc="a first variable", values=Calculation(func['calc_value'], Params((ParamOption(option_2)))), default="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
|
||||
option_5 = ChoiceOption(name="var3", doc="a third variable", values=Calculation(func['calc_value'], Params((ParamOption(option_2)))), default=Calculation(func['calc_value'], Params((ParamOption(option_3)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
|
||||
optiondescription_4 = OptionDescription(name="family", doc="family", children=[option_5], properties=frozenset({"standard"}))
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, optiondescription_4], properties=frozenset({"standard"}))
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
from tiramisu import *
|
||||
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||
from re import compile as re_compile
|
||||
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||
load_functions('../rougail-tests/funcs/test.py')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_1 = StrOption(name="var1", doc="a second variable", multi=True, default=["a", "b", "c"], default_multi="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||
option_2 = ChoiceOption(name="var2", doc="a first variable", values=Calculation(func['calc_value'], Params((ParamOption(option_1)))), default="a", properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
|
||||
option_4 = ChoiceOption(name="var3", doc="a third variable", values=Calculation(func['calc_value'], Params((ParamOption(option_1)))), default=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'choice'})
|
||||
optiondescription_3 = OptionDescription(name="family", doc="family", children=[option_4], properties=frozenset({"standard"}))
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, optiondescription_3])
|
||||
|
|
@ -6,5 +6,9 @@
|
|||
"rougail.secret2": {
|
||||
"owner": "default",
|
||||
"value": "value"
|
||||
},
|
||||
"rougail.secret3": {
|
||||
"owner": "default",
|
||||
"value": "value"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"rougail.secret1": null,
|
||||
"rougail.secret2": "value"
|
||||
"rougail.secret2": "value",
|
||||
"rougail.secret3": "value"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,9 @@
|
|||
"rougail.secret2": {
|
||||
"owner": "default",
|
||||
"value": "value"
|
||||
},
|
||||
"rougail.secret3": {
|
||||
"owner": "default",
|
||||
"value": "value"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,5 +12,6 @@ ALLOWED_LEADER_PROPERTIES.add("standard")
|
|||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_2 = PasswordOption(name="secret1", doc="the first variable", min_len=10, properties=frozenset({"basic", "mandatory"}), informations={'type': 'secret'})
|
||||
option_3 = PasswordOption(name="secret2", doc="the second variable", default="value", max_len=10, forbidden_char=['$', '^'], properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'})
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"basic"}))
|
||||
option_4 = PasswordOption(name="secret3", doc="the third variable", default="value", max_len=10, forbidden_char=['$'], properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'})
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, option_4], properties=frozenset({"basic"}))
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
|
|
|
|||
|
|
@ -8,4 +8,5 @@ ALLOWED_LEADER_PROPERTIES.add("standard")
|
|||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_1 = PasswordOption(name="secret1", doc="the first variable", min_len=10, properties=frozenset({"basic", "mandatory"}), informations={'type': 'secret'})
|
||||
option_2 = PasswordOption(name="secret2", doc="the second variable", default="value", max_len=10, forbidden_char=['$', '^'], properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])
|
||||
option_3 = PasswordOption(name="secret3", doc="the third variable", default="value", max_len=10, forbidden_char=['$'], properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3])
|
||||
|
|
|
|||
0
tests/errors/20_test_unknown_variable_disabled/errno_88
Normal file
0
tests/errors/20_test_unknown_variable_disabled/errno_88
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
version: 1.1
|
||||
|
||||
variable:
|
||||
description: a variable
|
||||
disabled:
|
||||
variable: _.unknown_variable
|
||||
when: false
|
||||
|
|
@ -16,6 +16,7 @@ logger = logging.getLogger()
|
|||
logger.setLevel(logging.INFO)
|
||||
|
||||
dico_dirs = Path('../rougail-tests/structures')
|
||||
errors_dirs = Path('tests/errors')
|
||||
rougail_test_dirs = Path('tests/dictionaries')
|
||||
|
||||
|
||||
|
|
@ -35,10 +36,11 @@ def get_rougail_tests_dir(original_dir):
|
|||
|
||||
for test in dico_dirs.iterdir():
|
||||
if test.is_dir():
|
||||
if rougail_test_dirs / 'test' / 'tiramisu':
|
||||
test_ok.add(test.name)
|
||||
elif test != '__pycache__':
|
||||
test_raise.add(test.name)
|
||||
test_ok.add(test.name)
|
||||
|
||||
for test in errors_dirs.iterdir():
|
||||
if test.is_dir():
|
||||
test_raise.add(test.name)
|
||||
|
||||
excludes = set([
|
||||
'80family_several',
|
||||
|
|
@ -124,7 +126,7 @@ def save(test_dir, eolobj, multi=False, namespace=False, error=False):
|
|||
tiramisu_dir = dirname(tiramisu_file)
|
||||
if not error:
|
||||
if not isdir(tiramisu_dir):
|
||||
raise Exception(f'please creates {tiramisu_dir}')
|
||||
makedirs(tiramisu_dir)
|
||||
if not isfile(tiramisu_file) or debug:
|
||||
copyfile(tiramisu_tmp, tiramisu_file)
|
||||
with open(tiramisu_tmp, 'r') as fh:
|
||||
|
|
@ -168,30 +170,11 @@ def test_dictionary_namespace(test_dir):
|
|||
return
|
||||
save(test_dir_, eolobj, namespace=True)
|
||||
assert getcwd() == ORI_DIR
|
||||
#
|
||||
#
|
||||
#def test_dictionary_multi(test_dir):
|
||||
# if not test_multi:
|
||||
# print('MULTI!')
|
||||
# return
|
||||
# assert getcwd() == ORI_DIR
|
||||
# test_dir_ = join(dico_dirs, test_dir)
|
||||
# rougailconfig = RougailConfig.copy()
|
||||
# rougailconfig['main_namespace'] = 'Rougail'
|
||||
# if (dico_dirs / test_dir / 'force_no_namespace').is_file():
|
||||
# return
|
||||
# eolobj = load_rougail_object(test_dir_, rougailconfig, multi=True)
|
||||
# if not eolobj:
|
||||
# return
|
||||
# eolobj.add_path_prefix('1')
|
||||
# eolobj.add_path_prefix('2')
|
||||
# save(test_dir_, eolobj, multi=True)
|
||||
# assert getcwd() == ORI_DIR
|
||||
|
||||
|
||||
def test_error_dictionary(test_dir_error):
|
||||
assert getcwd() == ORI_DIR
|
||||
test_dir_ = join(dico_dirs, test_dir_error)
|
||||
test_dir_ = join(errors_dirs, test_dir_error)
|
||||
errno = []
|
||||
rougailconfig = RougailConfig.copy()
|
||||
rougailconfig['main_namespace'] = 'Rougail'
|
||||
|
|
|
|||
Loading…
Reference in a new issue