diff --git a/src/rougail/structural_commandline/annotator.py b/src/rougail/structural_commandline/annotator.py index 4e2fbaed4..6e5c3942b 100644 --- a/src/rougail/structural_commandline/annotator.py +++ b/src/rougail/structural_commandline/annotator.py @@ -1,7 +1,7 @@ """Annotate to add specify attribute for tiramisu-cmdline Silique (https://www.silique.fr) -Copyright (C) 2024 +Copyright (C) 2024-2025 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the @@ -91,15 +91,17 @@ class Annotator(Walk): def manage_negative_description(self, variable) -> None: if not variable.negative_description: if variable.type == "boolean" and not self.objectspace.add_extra_options: - raise DictConsistencyError( - _( - 'negative_description is mandatory for boolean variable, but "{0}" hasn\'t' - ).format(variable.path), - 200, - variable.xmlfiles, - ) - return - if variable.type != "boolean": + if variable.name == variable.description: + variable.negative_description = variable.name + else: + raise DictConsistencyError( + _( + 'negative_description is mandatory for boolean variable, but "{0}" hasn\'t' + ).format(variable.path), + 200, + variable.xmlfiles, + ) + elif variable.type != "boolean": raise DictConsistencyError( _( 'negative_description is only available for boolean variable, but "{0}" is "{1}"' @@ -107,6 +109,7 @@ class Annotator(Walk): 201, variable.xmlfiles, ) - self.objectspace.informations.add( - variable.path, "negative_description", variable.negative_description - ) + if variable.negative_description: + self.objectspace.informations.add( + variable.path, "negative_description", variable.negative_description + ) diff --git a/tests/default_option_params/structure/00-test.yml b/tests/default_option_params/structure/00-test.yml new file mode 100644 index 000000000..78c976dfa --- /dev/null +++ b/tests/default_option_params/structure/00-test.yml @@ -0,0 +1,8 @@ +version: 1.1 + +file: + type: unix_filename + params: + allow_relative: true + default: + test/unknown_file diff --git a/tests/dictionaries/00_6secret/makedict/after.json b/tests/dictionaries/00_6secret/makedict/after.json new file mode 100644 index 000000000..ecb67a4b6 --- /dev/null +++ b/tests/dictionaries/00_6secret/makedict/after.json @@ -0,0 +1,10 @@ +{ + "rougail.secret1": { + "owner": "default", + "value": null + }, + "rougail.secret2": { + "owner": "default", + "value": "value" + } +} diff --git a/tests/dictionaries/00_6secret/makedict/base.json b/tests/dictionaries/00_6secret/makedict/base.json new file mode 100644 index 000000000..1ae37c88a --- /dev/null +++ b/tests/dictionaries/00_6secret/makedict/base.json @@ -0,0 +1,4 @@ +{ + "rougail.secret1": null, + "rougail.secret2": "value" +} diff --git a/tests/dictionaries/00_6secret/makedict/before.json b/tests/dictionaries/00_6secret/makedict/before.json new file mode 100644 index 000000000..ecb67a4b6 --- /dev/null +++ b/tests/dictionaries/00_6secret/makedict/before.json @@ -0,0 +1,10 @@ +{ + "rougail.secret1": { + "owner": "default", + "value": null + }, + "rougail.secret2": { + "owner": "default", + "value": "value" + } +} diff --git a/tests/dictionaries/00_6secret/makedict/mandatory.json b/tests/dictionaries/00_6secret/makedict/mandatory.json new file mode 100644 index 000000000..23ac0af58 --- /dev/null +++ b/tests/dictionaries/00_6secret/makedict/mandatory.json @@ -0,0 +1 @@ +["rougail.secret1"] \ No newline at end of file diff --git a/tests/dictionaries/00_6secret/tiramisu/base.py b/tests/dictionaries/00_6secret/tiramisu/base.py new file mode 100644 index 000000000..2eab62dc6 --- /dev/null +++ b/tests/dictionaries/00_6secret/tiramisu/base.py @@ -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 = PasswordOption(name="secret1", doc="the first variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'secret'}) +option_3 = PasswordOption(name="secret2", doc="the second variable", default="value", 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_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/00_6secret/tiramisu/no_namespace.py b/tests/dictionaries/00_6secret/tiramisu/no_namespace.py new file mode 100644 index 000000000..d6a0b95d2 --- /dev/null +++ b/tests/dictionaries/00_6secret/tiramisu/no_namespace.py @@ -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 = PasswordOption(name="secret1", doc="the first variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'secret'}) +option_2 = PasswordOption(name="secret2", doc="the second variable", default="value", properties=frozenset({"mandatory", "standard"}), informations={'type': 'secret'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2]) diff --git a/tests/dictionaries/04_5disabled_calculation_multi/makedict/after.json b/tests/dictionaries/04_5disabled_calculation_multi/makedict/after.json new file mode 100644 index 000000000..b5431602e --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_multi/makedict/after.json @@ -0,0 +1,14 @@ +{ + "rougail.condition": { + "owner": "default", + "value": "no" + }, + "rougail.variable1": { + "owner": "default", + "value": [] + }, + "rougail.variable2": { + "owner": "default", + "value": [] + } +} diff --git a/tests/dictionaries/04_5disabled_calculation_multi/makedict/base.json b/tests/dictionaries/04_5disabled_calculation_multi/makedict/base.json new file mode 100644 index 000000000..6efda8c76 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_multi/makedict/base.json @@ -0,0 +1,5 @@ +{ + "rougail.condition": "no", + "rougail.variable1": [], + "rougail.variable2": [] +} diff --git a/tests/dictionaries/04_5disabled_calculation_multi/makedict/before.json b/tests/dictionaries/04_5disabled_calculation_multi/makedict/before.json new file mode 100644 index 000000000..b5431602e --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_multi/makedict/before.json @@ -0,0 +1,14 @@ +{ + "rougail.condition": { + "owner": "default", + "value": "no" + }, + "rougail.variable1": { + "owner": "default", + "value": [] + }, + "rougail.variable2": { + "owner": "default", + "value": [] + } +} diff --git a/tests/dictionaries/04_5disabled_calculation_multi/makedict/mandatory.json b/tests/dictionaries/04_5disabled_calculation_multi/makedict/mandatory.json new file mode 100644 index 000000000..62552d034 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_multi/makedict/mandatory.json @@ -0,0 +1 @@ +["rougail.variable1", "rougail.variable2"] \ No newline at end of file diff --git a/tests/dictionaries/04_5disabled_calculation_multi/tiramisu/base.py b/tests/dictionaries/04_5disabled_calculation_multi/tiramisu/base.py new file mode 100644 index 000000000..cdbfaf5a1 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_multi/tiramisu/base.py @@ -0,0 +1,19 @@ +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") +dict_env['disabled_rougail.variable1'] = "{% if _.condition == \"yes\" %}\ncondition is yes\n{% endif %}\n" +dict_env['disabled_rougail.variable2'] = "{% if _.condition == \"yes\" %}\ncondition is yes\n{% endif %}\n" +option_2 = StrOption(name="condition", doc="a conditional variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_3 = StrOption(name="variable1", doc="a first variable", multi=True, properties=frozenset({"basic", "mandatory", Calculation(func['jinja_to_property'], Params((ParamValue("disabled")), kwargs={'__internal_jinja': ParamValue("disabled_rougail.variable1"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/04_5disabled_calculation_multi/rougail/00-base.yml']), '__internal_attribute': ParamValue("disabled"), '__internal_variable': ParamValue("rougail.variable1"), 'when': ParamValue(True), 'inverse': ParamValue(False), '_.condition': ParamOption(option_2, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'type': 'string'}) +option_4 = StrOption(name="variable2", doc="a second variable", multi=True, properties=frozenset({"basic", "mandatory", Calculation(func['jinja_to_property'], Params((ParamValue("disabled")), kwargs={'__internal_jinja': ParamValue("disabled_rougail.variable2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/04_5disabled_calculation_multi/rougail/00-base.yml']), '__internal_attribute': ParamValue("disabled"), '__internal_variable': ParamValue("rougail.variable2"), 'when': ParamValue(True), 'inverse': ParamValue(False), '_.condition': ParamOption(option_2, notraisepropertyerror=True)}), help_function=func['jinja_to_property_help'])}), informations={'type': 'string'}) +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]) diff --git a/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/after.json b/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/after.json new file mode 100644 index 000000000..1540714f4 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/after.json @@ -0,0 +1,10 @@ +{ + "rougail.condition": { + "owner": "default", + "value": false + }, + "rougail.variable": { + "owner": "default", + "value": [] + } +} diff --git a/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/base.json b/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/base.json new file mode 100644 index 000000000..4832715d9 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/base.json @@ -0,0 +1,4 @@ +{ + "rougail.condition": false, + "rougail.variable": [] +} diff --git a/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/before.json b/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/before.json new file mode 100644 index 000000000..1540714f4 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/before.json @@ -0,0 +1,10 @@ +{ + "rougail.condition": { + "owner": "default", + "value": false + }, + "rougail.variable": { + "owner": "default", + "value": [] + } +} diff --git a/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/mandatory.json b/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/mandatory.json new file mode 100644 index 000000000..bdc34fddd --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_variable_multi/makedict/mandatory.json @@ -0,0 +1 @@ +["rougail.variable"] \ No newline at end of file diff --git a/tests/dictionaries/04_5disabled_calculation_variable_multi/tiramisu/base.py b/tests/dictionaries/04_5disabled_calculation_variable_multi/tiramisu/base.py new file mode 100644 index 000000000..a4c0fbc57 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_variable_multi/tiramisu/base.py @@ -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 = BoolOption(name="condition", doc="a condition", default=False, properties=frozenset({"mandatory", "standard"}), informations={'type': 'boolean'}) +option_3 = StrOption(name="variable", doc="a variable", multi=True, properties=frozenset({"basic", "mandatory", Calculation(func['variable_to_property'], Params((ParamValue("disabled"), ParamOption(option_2)), kwargs={'__internal_multi': ParamValue(True), 'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'type': 'string'}) +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]) diff --git a/tests/dictionaries/04_5disabled_calculation_variable_multi/tiramisu/no_namespace.py b/tests/dictionaries/04_5disabled_calculation_variable_multi/tiramisu/no_namespace.py new file mode 100644 index 000000000..41c6b861e --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_variable_multi/tiramisu/no_namespace.py @@ -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 = BoolOption(name="condition", doc="a condition", default=False, properties=frozenset({"mandatory", "standard"}), informations={'type': 'boolean'}) +option_2 = StrOption(name="variable", doc="a variable", multi=True, properties=frozenset({"basic", "mandatory", Calculation(func['variable_to_property'], Params((ParamValue("disabled"), ParamOption(option_1)), kwargs={'__internal_multi': ParamValue(True), 'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/after.json b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/after.json new file mode 100644 index 000000000..6aa82d39f --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/after.json @@ -0,0 +1,35 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": [ + "val11" + ] + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/base.json b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/base.json new file mode 100644 index 000000000..ad3b74016 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/base.json @@ -0,0 +1,17 @@ +{ + "rougail.leader.leader": [ + { + "rougail.leader.leader": "value1", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + }, + { + "rougail.leader.leader": "value2", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + } + ], + "rougail.calculate": [ + "val11" + ] +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/before.json b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/before.json new file mode 100644 index 000000000..6aa82d39f --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/before.json @@ -0,0 +1,35 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": [ + "val11" + ] + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/mandatory.json b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-first/tiramisu/base.py b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/tiramisu/base.py new file mode 100644 index 000000000..2c05c3607 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/tiramisu/base.py @@ -0,0 +1,20 @@ +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") +dict_env['default_rougail.calculate'] = "{{ _.leader.follower1[0] }}" +option_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"})) +option_6 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-follower-first/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.calculate"), '_.leader.follower1': ParamOption(option_4, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-first/tiramisu/no_namespace.py b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/tiramisu/no_namespace.py new file mode 100644 index 000000000..52f037771 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-first/tiramisu/no_namespace.py @@ -0,0 +1,15 @@ +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") +dict_env['default_calculate'] = "{{ _.leader.follower1[0] }}" +option_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"})) +option_5 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-follower-first/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("calculate"), '_.leader.follower1': ParamOption(option_3, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/after.json b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/after.json new file mode 100644 index 000000000..6aa82d39f --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/after.json @@ -0,0 +1,35 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": [ + "val11" + ] + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/base.json b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/base.json new file mode 100644 index 000000000..ad3b74016 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/base.json @@ -0,0 +1,17 @@ +{ + "rougail.leader.leader": [ + { + "rougail.leader.leader": "value1", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + }, + { + "rougail.leader.leader": "value2", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + } + ], + "rougail.calculate": [ + "val11" + ] +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/before.json b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/before.json new file mode 100644 index 000000000..6aa82d39f --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/before.json @@ -0,0 +1,35 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": [ + "val11" + ] + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/mandatory.json b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-last/tiramisu/base.py b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/tiramisu/base.py new file mode 100644 index 000000000..abf385f89 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/tiramisu/base.py @@ -0,0 +1,20 @@ +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") +dict_env['default_rougail.calculate'] = "{{ _.leader.follower1[-1] }}" +option_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"})) +option_6 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-follower-last/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.calculate"), '_.leader.follower1': ParamOption(option_4, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower-last/tiramisu/no_namespace.py b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/tiramisu/no_namespace.py new file mode 100644 index 000000000..c3f588179 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower-last/tiramisu/no_namespace.py @@ -0,0 +1,15 @@ +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") +dict_env['default_calculate'] = "{{ _.leader.follower1[-1] }}" +option_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"})) +option_5 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-follower-last/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("calculate"), '_.leader.follower1': ParamOption(option_3, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/after.json b/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/after.json new file mode 100644 index 000000000..a71fe60a0 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/after.json @@ -0,0 +1,36 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": [ + "val11", + "val11" + ] + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/base.json b/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/base.json new file mode 100644 index 000000000..56db42ba7 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/base.json @@ -0,0 +1,18 @@ +{ + "rougail.leader.leader": [ + { + "rougail.leader.leader": "value1", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + }, + { + "rougail.leader.leader": "value2", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + } + ], + "rougail.calculate": [ + "val11", + "val11" + ] +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/before.json b/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/before.json new file mode 100644 index 000000000..a71fe60a0 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/before.json @@ -0,0 +1,36 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": [ + "val11", + "val11" + ] + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/mandatory.json b/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower/tiramisu/base.py b/tests/dictionaries/40_9leadership-calculation-outside-follower/tiramisu/base.py new file mode 100644 index 000000000..ceb5f2614 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower/tiramisu/base.py @@ -0,0 +1,19 @@ +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_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"})) +option_6 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_4)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-follower/tiramisu/no_namespace.py b/tests/dictionaries/40_9leadership-calculation-outside-follower/tiramisu/no_namespace.py new file mode 100644 index 000000000..0264599a8 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-follower/tiramisu/no_namespace.py @@ -0,0 +1,14 @@ +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_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"})) +option_5 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_3)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "notunique", "standard"}), informations={'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/after.json b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/after.json new file mode 100644 index 000000000..21f177e27 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/after.json @@ -0,0 +1,33 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": "value1" + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/base.json b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/base.json new file mode 100644 index 000000000..8ee5037b3 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/base.json @@ -0,0 +1,15 @@ +{ + "rougail.leader.leader": [ + { + "rougail.leader.leader": "value1", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + }, + { + "rougail.leader.leader": "value2", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + } + ], + "rougail.calculate": "value1" +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/before.json b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/before.json new file mode 100644 index 000000000..21f177e27 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/before.json @@ -0,0 +1,33 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": "value1" + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/mandatory.json b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-first/tiramisu/base.py b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/tiramisu/base.py new file mode 100644 index 000000000..eb54be80e --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/tiramisu/base.py @@ -0,0 +1,20 @@ +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") +dict_env['default_rougail.calculate'] = "{{ _.leader.leader[0] }}" +option_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"})) +option_6 = StrOption(name="calculate", doc="a calculated variable", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-leader-first/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.calculate"), '_.leader.leader': ParamOption(option_3, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-first/tiramisu/no_namespace.py b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/tiramisu/no_namespace.py new file mode 100644 index 000000000..5fb5402d3 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-first/tiramisu/no_namespace.py @@ -0,0 +1,15 @@ +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") +dict_env['default_calculate'] = "{{ _.leader.leader[0] }}" +option_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"})) +option_5 = StrOption(name="calculate", doc="a calculated variable", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-leader-first/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("calculate"), '_.leader.leader': ParamOption(option_2, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/after.json b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/after.json new file mode 100644 index 000000000..3ed930a63 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/after.json @@ -0,0 +1,33 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": "value2" + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/base.json b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/base.json new file mode 100644 index 000000000..877ce5165 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/base.json @@ -0,0 +1,15 @@ +{ + "rougail.leader.leader": [ + { + "rougail.leader.leader": "value1", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + }, + { + "rougail.leader.leader": "value2", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + } + ], + "rougail.calculate": "value2" +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/before.json b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/before.json new file mode 100644 index 000000000..3ed930a63 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/before.json @@ -0,0 +1,33 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": "value2" + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/mandatory.json b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-last/tiramisu/base.py b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/tiramisu/base.py new file mode 100644 index 000000000..0a1c4bee4 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/tiramisu/base.py @@ -0,0 +1,20 @@ +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") +dict_env['default_rougail.calculate'] = "{{ _.leader.leader[-1] }}" +option_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"})) +option_6 = StrOption(name="calculate", doc="a calculated variable", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-leader-last/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.calculate"), '_.leader.leader': ParamOption(option_3, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader-last/tiramisu/no_namespace.py b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/tiramisu/no_namespace.py new file mode 100644 index 000000000..975fed645 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader-last/tiramisu/no_namespace.py @@ -0,0 +1,15 @@ +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") +dict_env['default_calculate'] = "{{ _.leader.leader[-1] }}" +option_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"})) +option_5 = StrOption(name="calculate", doc="a calculated variable", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_calculate"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/40_9leadership-calculation-outside-leader-last/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("calculate"), '_.leader.leader': ParamOption(option_2, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/after.json b/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/after.json new file mode 100644 index 000000000..f55e6a53b --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/after.json @@ -0,0 +1,36 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/base.json b/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/base.json new file mode 100644 index 000000000..909f30d62 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/base.json @@ -0,0 +1,18 @@ +{ + "rougail.leader.leader": [ + { + "rougail.leader.leader": "value1", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + }, + { + "rougail.leader.leader": "value2", + "rougail.leader.follower1": "val11", + "rougail.leader.follower2": "val21" + } + ], + "rougail.calculate": [ + "value1", + "value2" + ] +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/before.json b/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/before.json new file mode 100644 index 000000000..f55e6a53b --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/before.json @@ -0,0 +1,36 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default" + ], + "value": [ + "val11", + "val11" + ] + }, + "rougail.leader.follower2": { + "owner": [ + "default", + "default" + ], + "value": [ + "val21", + "val21" + ] + }, + "rougail.calculate": { + "owner": "default", + "value": [ + "value1", + "value2" + ] + } +} diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/mandatory.json b/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader/tiramisu/base.py b/tests/dictionaries/40_9leadership-calculation-outside-leader/tiramisu/base.py new file mode 100644 index 000000000..9de6a0d94 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader/tiramisu/base.py @@ -0,0 +1,19 @@ +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_3 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_5 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_2 = Leadership(name="leader", doc="a leadership", children=[option_3, option_4, option_5], properties=frozenset({"standard"})) +option_6 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_3)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_6], properties=frozenset({"standard"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/40_9leadership-calculation-outside-leader/tiramisu/no_namespace.py b/tests/dictionaries/40_9leadership-calculation-outside-leader/tiramisu/no_namespace.py new file mode 100644 index 000000000..43ff3a146 --- /dev/null +++ b/tests/dictionaries/40_9leadership-calculation-outside-leader/tiramisu/no_namespace.py @@ -0,0 +1,14 @@ +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_2 = StrOption(name="leader", doc="a leader", multi=True, default=["value1", "value2"], properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_3 = StrOption(name="follower1", doc="a follower", multi=True, default_multi="val11", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_4 = StrOption(name="follower2", doc="an other follower", multi=True, default_multi="val21", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +optiondescription_1 = Leadership(name="leader", doc="a leadership", children=[option_2, option_3, option_4], properties=frozenset({"standard"})) +option_5 = StrOption(name="calculate", doc="a calculated variable", multi=True, default=Calculation(func['calc_value'], Params((ParamOption(option_2)), kwargs={'__internal_multi': ParamValue(True)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_5]) diff --git a/tests/test_others.py b/tests/test_others.py index 8c1d60cd3..e7bb96de5 100644 --- a/tests/test_others.py +++ b/tests/test_others.py @@ -56,3 +56,17 @@ def test_personalize_annotate_twice(): with raises(DictConsistencyError) as err: eolobj.converted.annotate() assert err.value.errno == 85 + + +def test_option_params(): + RougailConfig['dictionaries_dir'] = ['tests/default_option_params/structure'] + RougailConfig["default_params.unix_filename.test_existence"] = True + eolobj = Rougail() + with raises(ValueError): + eolobj.get_config() + eolobj = Rougail() + with raises(ValueError): + eolobj.get_config() + RougailConfig["default_params.unix_filename.test_existence"] = False + eolobj = Rougail() + eolobj.get_config()