diff --git a/src/rougail/convert/object_model.py b/src/rougail/convert/object_model.py index a13030dde..797934599 100644 --- a/src/rougail/convert/object_model.py +++ b/src/rougail/convert/object_model.py @@ -37,7 +37,7 @@ from ..utils import ( ) from ..i18n import _ from ..error import DictConsistencyError, VariableCalculationDependencyError -from ..tiramisu import CONVERT_OPTION, RENAME_TYPE, display_xmlfiles +from ..tiramisu import CONVERT_OPTION, RENAME_TYPE, display_xmlfiles, convert_boolean BASETYPE = Union[StrictBool, StrictInt, StrictFloat, StrictStr, None] @@ -425,6 +425,7 @@ class _VariableCalculation(Calculation): variable: StrictStr propertyerror: bool = True allow_none: bool = False + optional: bool = False def get_variable( self, @@ -629,19 +630,41 @@ class _VariableCalculation(Calculation): ) raise DictConsistencyError(msg, 18, self.xmlfiles) + def get_default_value_optional(self, objectspace, default): + if self.attribute_name == "default": + if self.inside_list: + expected_multiple_value = False + elif self.path in objectspace.followers: + expected_multiple_value = objectspace.multis[self.path] == "submulti" + else: + expected_multiple_value = self.path in objectspace.multis + elif self.attribute_name in PROPERTY_ATTRIBUTE: + expected_multiple_value = False + else: + expected_multiple_value = True + value_is_multi = isinstance(default, list) + if expected_multiple_value != value_is_multi: + if self.attribute_name != "default" or expected_multiple_value: + msg = _('the variable "{0}" is waiting for a list as "{1}" but the attribute "default" is not a list ("{2}")') + else: + msg = _('the variable "{0}" is not waiting for a list as "{1}" but the attribute "default" is a list ("{2}")') + msg = msg.format(self.path, self.attribute_name, default) + raise DictConsistencyError(msg, 77, self.xmlfiles) + return default + class VariableCalculation(_VariableCalculation): attribute_name: Literal["default", "choices", "dynamic"] - optional: bool = False description: Optional[StrictStr] = None + default: Any = undefined def to_function( self, objectspace, ) -> dict: - if self.attribute_name != "default" and self.optional: + if self.attribute_name != "default" and self.optional and self.default is undefined: msg = _( - '"{0}" attribut shall not have an "optional" attribute for variable "{1}"' + '"{0}" attribut shall not have an "optional" attribute without the "default" attribute for variable "{1}"' ).format(self.attribute_name, self.variable) raise DictConsistencyError(msg, 33, self.xmlfiles) ( @@ -654,6 +677,8 @@ class VariableCalculation(_VariableCalculation): and self.optional or (objectspace.force_optional and self.attribute_name == "default") ): + if self.default is not undefined: + return self.get_default_value_optional(objectspace, self.default) raise VariableCalculationDependencyError() if variable_in_calculation and self.attribute_name == "default": local_variable = objectspace.paths[self.path] @@ -677,11 +702,11 @@ class VariableCalculation(_VariableCalculation): class VariablePropertyCalculation(_VariableCalculation): - # For python 3.9 attribute_name: Literal[*PROPERTY_ATTRIBUTE] - attribute_name: Literal["frozen", "hidden", "disabled", "mandatory"] + attribute_name: Literal[*PROPERTY_ATTRIBUTE] when: Any = undefined when_not: Any = undefined description: Optional[StrictStr] = None + default: bool = False def to_function( self, @@ -692,6 +717,21 @@ class VariablePropertyCalculation(_VariableCalculation): variable_in_calculation, variable_in_calculation_identifier, ) = self.get_variable(objectspace) + if ( +# self.default is not undefined and + not variable_in_calculation + and self.optional + or (objectspace.force_optional) + ): + if self.default is undefined: + default = False + else: + default = self.default + if not isinstance(default, bool): + msg = _('the variable "{0}" is waiting for a boolean as "{1}" but the attribute "default" is not a boolean ("{2}")') + msg = msg.format(self.path, self.attribute_name, default) + raise DictConsistencyError(msg, 79, self.xmlfiles) + return self.get_default_value_optional(objectspace, default) params = self.get_params( objectspace, variable_in_calculation_path, @@ -823,8 +863,7 @@ class IdentifierCalculation(_IdentifierCalculation): class IdentifierPropertyCalculation(_IdentifierCalculation): - # for python 3.9 attribute_name: Literal[*PROPERTY_ATTRIBUTE] - attribute_name: Literal["frozen", "hidden", "disabled", "mandatory"] + attribute_name: Literal[*PROPERTY_ATTRIBUTE] when: Any = undefined when_not: Any = undefined description: Optional[StrictStr] = None @@ -896,10 +935,7 @@ class NamespaceCalculation(Calculation): namespace = self.namespace if namespace: namespace = objectspace.paths[namespace].description - return { - "function": "calc_value", - "params": {None: [namespace]}, - } + return namespace CALCULATION_TYPES = { diff --git a/src/rougail/convert/tiramisureflector.py b/src/rougail/convert/tiramisureflector.py index 8f95027fe..f9f610b14 100644 --- a/src/rougail/convert/tiramisureflector.py +++ b/src/rougail/convert/tiramisureflector.py @@ -221,14 +221,28 @@ class Common: properties = [] calc_properties = [] for property_, value in values.items(): - if value is True: - properties.append(self.convert_str(property_)) - elif isinstance(value, list): - for val in value: - calc_properties.append(self.calculation_value(val)) - else: - calc_properties.append(self.calculation_value(value)) - return "frozenset({" + ", ".join(sorted(properties) + calc_properties) + "})" + if not isinstance(value, list): + value = [value] + for val in value: + ret = self.calculation_property(val) + if isinstance(ret, bool): + properties.append(self.convert_str(property_)) + elif ret is not None: + calc_properties.append(ret) + if properties or calc_properties: + return "frozenset({" + ", ".join(sorted(properties) + calc_properties) + "})" + raise Exception('ca existe alors ...') + + def calculation_property( + self, + value: Union[Calculation, bool], + ) -> Optional[bool]: + if isinstance(value, Calculation): + try: + return self.calculation_value(value) + except VariableCalculationDependencyError: + return None + return value def calc_properties( self, @@ -358,6 +372,10 @@ class Common: ) -> str: """Generate calculated value""" child = function.to_function(self.objectspace) + if isinstance(child, str): + return self.convert_str(child) + elif not isinstance(child, dict): + return child new_args = [] kwargs = [] if "params" in child: @@ -387,10 +405,10 @@ class Common: datas: Union[Calculation, str, list], return_a_tuple: bool = False, ) -> str: - if isinstance(datas, str): - return self.convert_str(datas) if isinstance(datas, Calculation): - return self.calculation_value(datas) + datas = self.calculation_value(datas) + elif isinstance(datas, str): + datas = self.convert_str(datas) if not isinstance(datas, list): return datas params = [] @@ -399,9 +417,11 @@ class Common: try: params.append(self.calculation_value(data)) except VariableCalculationDependencyError: - pass + continue elif isinstance(data, str): params.append(self.convert_str(data)) + elif isinstance(data, dict): + params.append(data) else: params.append(str(data)) if return_a_tuple: diff --git a/tests/dictionaries/00_2default_calculated_variable/makedict/after.json b/tests/dictionaries/00_2default_calculated_variable/makedict/after.json new file mode 100644 index 000000000..2c76fb1fd --- /dev/null +++ b/tests/dictionaries/00_2default_calculated_variable/makedict/after.json @@ -0,0 +1,10 @@ +{ + "rougail.var1": { + "owner": "default", + "value": [] + }, + "rougail.var2": { + "owner": "default", + "value": [] + } +} diff --git a/tests/dictionaries/00_2default_calculated_variable/makedict/base.json b/tests/dictionaries/00_2default_calculated_variable/makedict/base.json new file mode 100644 index 000000000..687890720 --- /dev/null +++ b/tests/dictionaries/00_2default_calculated_variable/makedict/base.json @@ -0,0 +1,4 @@ +{ + "rougail.var1": [], + "rougail.var2": [] +} diff --git a/tests/dictionaries/00_2default_calculated_variable/makedict/before.json b/tests/dictionaries/00_2default_calculated_variable/makedict/before.json new file mode 100644 index 000000000..2c76fb1fd --- /dev/null +++ b/tests/dictionaries/00_2default_calculated_variable/makedict/before.json @@ -0,0 +1,10 @@ +{ + "rougail.var1": { + "owner": "default", + "value": [] + }, + "rougail.var2": { + "owner": "default", + "value": [] + } +} diff --git a/tests/dictionaries/00_2default_calculated_variable/makedict/mandatory.json b/tests/dictionaries/00_2default_calculated_variable/makedict/mandatory.json new file mode 100644 index 000000000..8c67ac5f8 --- /dev/null +++ b/tests/dictionaries/00_2default_calculated_variable/makedict/mandatory.json @@ -0,0 +1 @@ +["rougail.var1", "rougail.var2"] \ No newline at end of file diff --git a/tests/dictionaries/00_2default_calculated_variable/makedict/read_write.json b/tests/dictionaries/00_2default_calculated_variable/makedict/read_write.json new file mode 100644 index 000000000..687890720 --- /dev/null +++ b/tests/dictionaries/00_2default_calculated_variable/makedict/read_write.json @@ -0,0 +1,4 @@ +{ + "rougail.var1": [], + "rougail.var2": [] +} diff --git a/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/after.json b/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/after.json new file mode 100644 index 000000000..80fb1e29c --- /dev/null +++ b/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/after.json @@ -0,0 +1,14 @@ +{ + "rougail.var1": { + "owner": "default", + "value": null + }, + "rougail.var2": { + "owner": "default", + "value": null + }, + "rougail.var3": { + "owner": "default", + "value": null + } +} diff --git a/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/base.json b/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/base.json new file mode 100644 index 000000000..4e06c64be --- /dev/null +++ b/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/base.json @@ -0,0 +1,5 @@ +{ + "rougail.var1": null, + "rougail.var2": null, + "rougail.var3": null +} diff --git a/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/before.json b/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/before.json new file mode 100644 index 000000000..80fb1e29c --- /dev/null +++ b/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/before.json @@ -0,0 +1,14 @@ +{ + "rougail.var1": { + "owner": "default", + "value": null + }, + "rougail.var2": { + "owner": "default", + "value": null + }, + "rougail.var3": { + "owner": "default", + "value": null + } +} diff --git a/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/mandatory.json b/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/mandatory.json new file mode 100644 index 000000000..bb8f7d275 --- /dev/null +++ b/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/mandatory.json @@ -0,0 +1 @@ +["rougail.var1", "rougail.var2", "rougail.var3"] \ No newline at end of file diff --git a/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/read_write.json b/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/read_write.json new file mode 100644 index 000000000..4e06c64be --- /dev/null +++ b/tests/dictionaries/00_2default_calculated_variable_description_multi_line/makedict/read_write.json @@ -0,0 +1,5 @@ +{ + "rougail.var1": null, + "rougail.var2": null, + "rougail.var3": null +} diff --git a/tests/dictionaries/00_6integer/makedict/after.json b/tests/dictionaries/00_6integer/makedict/after.json new file mode 100644 index 000000000..a74971f3d --- /dev/null +++ b/tests/dictionaries/00_6integer/makedict/after.json @@ -0,0 +1,26 @@ +{ + "rougail.var1": { + "owner": "default", + "value": 0 + }, + "rougail.var2": { + "owner": "default", + "value": 0 + }, + "rougail.var3": { + "owner": "default", + "value": 0 + }, + "rougail.var4": { + "owner": "default", + "value": 10 + }, + "rougail.var5": { + "owner": "default", + "value": 10 + }, + "rougail.var6": { + "owner": "default", + "value": 10 + } +} diff --git a/tests/dictionaries/00_6integer/makedict/base.json b/tests/dictionaries/00_6integer/makedict/base.json new file mode 100644 index 000000000..20006db5d --- /dev/null +++ b/tests/dictionaries/00_6integer/makedict/base.json @@ -0,0 +1,8 @@ +{ + "rougail.var1": 0, + "rougail.var2": 0, + "rougail.var3": 0, + "rougail.var4": 10, + "rougail.var5": 10, + "rougail.var6": 10 +} diff --git a/tests/dictionaries/00_6integer/makedict/before.json b/tests/dictionaries/00_6integer/makedict/before.json new file mode 100644 index 000000000..a74971f3d --- /dev/null +++ b/tests/dictionaries/00_6integer/makedict/before.json @@ -0,0 +1,26 @@ +{ + "rougail.var1": { + "owner": "default", + "value": 0 + }, + "rougail.var2": { + "owner": "default", + "value": 0 + }, + "rougail.var3": { + "owner": "default", + "value": 0 + }, + "rougail.var4": { + "owner": "default", + "value": 10 + }, + "rougail.var5": { + "owner": "default", + "value": 10 + }, + "rougail.var6": { + "owner": "default", + "value": 10 + } +} diff --git a/tests/dictionaries/00_6integer/makedict/mandatory.json b/tests/dictionaries/00_6integer/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/00_6integer/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/00_6integer/makedict/read_write.json b/tests/dictionaries/00_6integer/makedict/read_write.json new file mode 100644 index 000000000..20006db5d --- /dev/null +++ b/tests/dictionaries/00_6integer/makedict/read_write.json @@ -0,0 +1,8 @@ +{ + "rougail.var1": 0, + "rougail.var2": 0, + "rougail.var3": 0, + "rougail.var4": 10, + "rougail.var5": 10, + "rougail.var6": 10 +} diff --git a/tests/dictionaries/00_6ip/makedict/after.json b/tests/dictionaries/00_6ip/makedict/after.json new file mode 100644 index 000000000..2edab99bb --- /dev/null +++ b/tests/dictionaries/00_6ip/makedict/after.json @@ -0,0 +1,14 @@ +{ + "rougail.var1": { + "owner": "default", + "value": "1.1.1.1" + }, + "rougail.var2": { + "owner": "default", + "value": "1.1.1.1/24" + }, + "rougail.var3": { + "owner": "default", + "value": "1.1.1.1/24" + } +} diff --git a/tests/dictionaries/00_6ip/makedict/base.json b/tests/dictionaries/00_6ip/makedict/base.json new file mode 100644 index 000000000..7a572ad59 --- /dev/null +++ b/tests/dictionaries/00_6ip/makedict/base.json @@ -0,0 +1,5 @@ +{ + "rougail.var1": "1.1.1.1", + "rougail.var2": "1.1.1.1/24", + "rougail.var3": "1.1.1.1/24" +} diff --git a/tests/dictionaries/00_6ip/makedict/before.json b/tests/dictionaries/00_6ip/makedict/before.json new file mode 100644 index 000000000..2edab99bb --- /dev/null +++ b/tests/dictionaries/00_6ip/makedict/before.json @@ -0,0 +1,14 @@ +{ + "rougail.var1": { + "owner": "default", + "value": "1.1.1.1" + }, + "rougail.var2": { + "owner": "default", + "value": "1.1.1.1/24" + }, + "rougail.var3": { + "owner": "default", + "value": "1.1.1.1/24" + } +} diff --git a/tests/dictionaries/00_6ip/makedict/mandatory.json b/tests/dictionaries/00_6ip/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/00_6ip/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/00_6ip/makedict/read_write.json b/tests/dictionaries/00_6ip/makedict/read_write.json new file mode 100644 index 000000000..7a572ad59 --- /dev/null +++ b/tests/dictionaries/00_6ip/makedict/read_write.json @@ -0,0 +1,5 @@ +{ + "rougail.var1": "1.1.1.1", + "rougail.var2": "1.1.1.1/24", + "rougail.var3": "1.1.1.1/24" +} diff --git a/tests/dictionaries/00_6network/makedict/after.json b/tests/dictionaries/00_6network/makedict/after.json new file mode 100644 index 000000000..613511fb4 --- /dev/null +++ b/tests/dictionaries/00_6network/makedict/after.json @@ -0,0 +1,14 @@ +{ + "rougail.var1": { + "owner": "default", + "value": "1.1.1.0" + }, + "rougail.var2": { + "owner": "default", + "value": "1.1.1.0/24" + }, + "rougail.var3": { + "owner": "default", + "value": "1.1.1.0/24" + } +} diff --git a/tests/dictionaries/00_6network/makedict/base.json b/tests/dictionaries/00_6network/makedict/base.json new file mode 100644 index 000000000..891a6f92b --- /dev/null +++ b/tests/dictionaries/00_6network/makedict/base.json @@ -0,0 +1,5 @@ +{ + "rougail.var1": "1.1.1.0", + "rougail.var2": "1.1.1.0/24", + "rougail.var3": "1.1.1.0/24" +} diff --git a/tests/dictionaries/00_6network/makedict/before.json b/tests/dictionaries/00_6network/makedict/before.json new file mode 100644 index 000000000..613511fb4 --- /dev/null +++ b/tests/dictionaries/00_6network/makedict/before.json @@ -0,0 +1,14 @@ +{ + "rougail.var1": { + "owner": "default", + "value": "1.1.1.0" + }, + "rougail.var2": { + "owner": "default", + "value": "1.1.1.0/24" + }, + "rougail.var3": { + "owner": "default", + "value": "1.1.1.0/24" + } +} diff --git a/tests/dictionaries/00_6network/makedict/mandatory.json b/tests/dictionaries/00_6network/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/00_6network/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/00_6network/makedict/read_write.json b/tests/dictionaries/00_6network/makedict/read_write.json new file mode 100644 index 000000000..891a6f92b --- /dev/null +++ b/tests/dictionaries/00_6network/makedict/read_write.json @@ -0,0 +1,5 @@ +{ + "rougail.var1": "1.1.1.0", + "rougail.var2": "1.1.1.0/24", + "rougail.var3": "1.1.1.0/24" +} diff --git a/tests/dictionaries/00_8calculation_namespace/tiramisu/base.py b/tests/dictionaries/00_8calculation_namespace/tiramisu/base.py index 9bdb77d31..d8c394eca 100644 --- a/tests/dictionaries/00_8calculation_namespace/tiramisu/base.py +++ b/tests/dictionaries/00_8calculation_namespace/tiramisu/base.py @@ -10,6 +10,6 @@ except: ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("advanced") -option_2 = StrOption(name="variable", doc="a variable", default=Calculation(func['calc_value'], Params((ParamValue("Rougail")))), properties=frozenset({"standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_8calculation_namespace/rougail/00-base.yml'], 'type': 'string'}) +option_2 = StrOption(name="variable", doc="a variable", default="Rougail", properties=frozenset({"standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_8calculation_namespace/rougail/00-base.yml'], 'type': 'string'}) optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2], properties=frozenset({"standard"}), informations={'ymlfiles': ['']}) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/after.json b/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/after.json new file mode 100644 index 000000000..925cafb64 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/after.json @@ -0,0 +1,13 @@ +{ + "rougail.my_variable": { + "owner": "default", + "value": "val1" + }, + "rougail.my_calculated_variable": { + "owner": "default", + "value": [ + "val1", + "value" + ] + } +} diff --git a/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/base.json b/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/base.json new file mode 100644 index 000000000..d22eb01d7 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/base.json @@ -0,0 +1,7 @@ +{ + "rougail.my_variable": "val1", + "rougail.my_calculated_variable": [ + "val1", + "value" + ] +} diff --git a/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/before.json b/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/before.json new file mode 100644 index 000000000..925cafb64 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/before.json @@ -0,0 +1,13 @@ +{ + "rougail.my_variable": { + "owner": "default", + "value": "val1" + }, + "rougail.my_calculated_variable": { + "owner": "default", + "value": [ + "val1", + "value" + ] + } +} diff --git a/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/mandatory.json b/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/read_write.json b/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/read_write.json new file mode 100644 index 000000000..d22eb01d7 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional_default/makedict/read_write.json @@ -0,0 +1,7 @@ +{ + "rougail.my_variable": "val1", + "rougail.my_calculated_variable": [ + "val1", + "value" + ] +} diff --git a/tests/dictionaries/00_9default_calculation_multi_optional_default/tiramisu/base.py b/tests/dictionaries/00_9default_calculation_multi_optional_default/tiramisu/base.py new file mode 100644 index 000000000..468730175 --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional_default/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 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_9default_calculation_multi_optional_default/rougail/00-base.yml'], 'type': 'string'}) +option_3 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_2)))), "value"], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_2)))), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_9default_calculation_multi_optional_default/rougail/00-base.yml'], 'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"}), informations={'ymlfiles': ['']}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/00_9default_calculation_multi_optional_default/tiramisu/no_namespace.py b/tests/dictionaries/00_9default_calculation_multi_optional_default/tiramisu/no_namespace.py new file mode 100644 index 000000000..b296005fa --- /dev/null +++ b/tests/dictionaries/00_9default_calculation_multi_optional_default/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 = StrOption(name="my_variable", doc="my_variable", default="val1", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_9default_calculation_multi_optional_default/rougail/00-base.yml'], 'type': 'string'}) +option_2 = StrOption(name="my_calculated_variable", doc="my_calculated_variable", multi=True, default=[Calculation(func['calc_value'], Params((ParamOption(option_1)))), "value"], default_multi=Calculation(func['calc_value'], Params((ParamOption(option_1)))), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_9default_calculation_multi_optional_default/rougail/00-base.yml'], 'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2]) diff --git a/tests/dictionaries/00_9default_number/makedict/after.json b/tests/dictionaries/00_9default_number/makedict/after.json new file mode 100644 index 000000000..679cb186d --- /dev/null +++ b/tests/dictionaries/00_9default_number/makedict/after.json @@ -0,0 +1,6 @@ +{ + "rougail.var": { + "owner": "default", + "value": 9 + } +} diff --git a/tests/dictionaries/00_9default_number/makedict/base.json b/tests/dictionaries/00_9default_number/makedict/base.json new file mode 100644 index 000000000..e03ee5a69 --- /dev/null +++ b/tests/dictionaries/00_9default_number/makedict/base.json @@ -0,0 +1,3 @@ +{ + "rougail.var": 9 +} diff --git a/tests/dictionaries/00_9default_number/makedict/before.json b/tests/dictionaries/00_9default_number/makedict/before.json new file mode 100644 index 000000000..679cb186d --- /dev/null +++ b/tests/dictionaries/00_9default_number/makedict/before.json @@ -0,0 +1,6 @@ +{ + "rougail.var": { + "owner": "default", + "value": 9 + } +} diff --git a/tests/dictionaries/00_9default_number/makedict/mandatory.json b/tests/dictionaries/00_9default_number/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/00_9default_number/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/00_9default_number/makedict/read_write.json b/tests/dictionaries/00_9default_number/makedict/read_write.json new file mode 100644 index 000000000..e03ee5a69 --- /dev/null +++ b/tests/dictionaries/00_9default_number/makedict/read_write.json @@ -0,0 +1,3 @@ +{ + "rougail.var": 9 +} diff --git a/tests/dictionaries/01_6integer_multi/makedict/after.json b/tests/dictionaries/01_6integer_multi/makedict/after.json new file mode 100644 index 000000000..359100c38 --- /dev/null +++ b/tests/dictionaries/01_6integer_multi/makedict/after.json @@ -0,0 +1,50 @@ +{ + "rougail.var1": { + "owner": "default", + "value": [ + 0 + ] + }, + "rougail.var2": { + "owner": "default", + "value": [ + 0 + ] + }, + "rougail.var3": { + "owner": "default", + "value": [ + 0 + ] + }, + "rougail.var4": { + "owner": "default", + "value": [ + 10 + ] + }, + "rougail.var5": { + "owner": "default", + "value": [ + 10 + ] + }, + "rougail.var6": { + "owner": "default", + "value": [ + 10 + ] + }, + "rougail.var7": { + "owner": "default", + "value": [ + 0 + ] + }, + "rougail.var8": { + "owner": "default", + "value": [ + 0 + ] + } +} diff --git a/tests/dictionaries/01_6integer_multi/makedict/base.json b/tests/dictionaries/01_6integer_multi/makedict/base.json new file mode 100644 index 000000000..dc357dcbc --- /dev/null +++ b/tests/dictionaries/01_6integer_multi/makedict/base.json @@ -0,0 +1,26 @@ +{ + "rougail.var1": [ + 0 + ], + "rougail.var2": [ + 0 + ], + "rougail.var3": [ + 0 + ], + "rougail.var4": [ + 10 + ], + "rougail.var5": [ + 10 + ], + "rougail.var6": [ + 10 + ], + "rougail.var7": [ + 0 + ], + "rougail.var8": [ + 0 + ] +} diff --git a/tests/dictionaries/01_6integer_multi/makedict/before.json b/tests/dictionaries/01_6integer_multi/makedict/before.json new file mode 100644 index 000000000..359100c38 --- /dev/null +++ b/tests/dictionaries/01_6integer_multi/makedict/before.json @@ -0,0 +1,50 @@ +{ + "rougail.var1": { + "owner": "default", + "value": [ + 0 + ] + }, + "rougail.var2": { + "owner": "default", + "value": [ + 0 + ] + }, + "rougail.var3": { + "owner": "default", + "value": [ + 0 + ] + }, + "rougail.var4": { + "owner": "default", + "value": [ + 10 + ] + }, + "rougail.var5": { + "owner": "default", + "value": [ + 10 + ] + }, + "rougail.var6": { + "owner": "default", + "value": [ + 10 + ] + }, + "rougail.var7": { + "owner": "default", + "value": [ + 0 + ] + }, + "rougail.var8": { + "owner": "default", + "value": [ + 0 + ] + } +} diff --git a/tests/dictionaries/01_6integer_multi/makedict/mandatory.json b/tests/dictionaries/01_6integer_multi/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/01_6integer_multi/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/01_6integer_multi/makedict/read_write.json b/tests/dictionaries/01_6integer_multi/makedict/read_write.json new file mode 100644 index 000000000..dc357dcbc --- /dev/null +++ b/tests/dictionaries/01_6integer_multi/makedict/read_write.json @@ -0,0 +1,26 @@ +{ + "rougail.var1": [ + 0 + ], + "rougail.var2": [ + 0 + ], + "rougail.var3": [ + 0 + ], + "rougail.var4": [ + 10 + ], + "rougail.var5": [ + 10 + ], + "rougail.var6": [ + 10 + ], + "rougail.var7": [ + 0 + ], + "rougail.var8": [ + 0 + ] +} diff --git a/tests/dictionaries/01_9choice_variable_optional/makedict/after.json b/tests/dictionaries/01_9choice_variable_optional/makedict/after.json new file mode 100644 index 000000000..7cd8555d6 --- /dev/null +++ b/tests/dictionaries/01_9choice_variable_optional/makedict/after.json @@ -0,0 +1,6 @@ +{ + "rougail.variable": { + "owner": "default", + "value": "c" + } +} diff --git a/tests/dictionaries/01_9choice_variable_optional/makedict/base.json b/tests/dictionaries/01_9choice_variable_optional/makedict/base.json new file mode 100644 index 000000000..6f3783e62 --- /dev/null +++ b/tests/dictionaries/01_9choice_variable_optional/makedict/base.json @@ -0,0 +1,3 @@ +{ + "rougail.variable": "c" +} diff --git a/tests/dictionaries/01_9choice_variable_optional/makedict/before.json b/tests/dictionaries/01_9choice_variable_optional/makedict/before.json new file mode 100644 index 000000000..7cd8555d6 --- /dev/null +++ b/tests/dictionaries/01_9choice_variable_optional/makedict/before.json @@ -0,0 +1,6 @@ +{ + "rougail.variable": { + "owner": "default", + "value": "c" + } +} diff --git a/tests/dictionaries/01_9choice_variable_optional/makedict/mandatory.json b/tests/dictionaries/01_9choice_variable_optional/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/01_9choice_variable_optional/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/01_9choice_variable_optional/makedict/read_write.json b/tests/dictionaries/01_9choice_variable_optional/makedict/read_write.json new file mode 100644 index 000000000..6f3783e62 --- /dev/null +++ b/tests/dictionaries/01_9choice_variable_optional/makedict/read_write.json @@ -0,0 +1,3 @@ +{ + "rougail.variable": "c" +} diff --git a/tests/dictionaries/01_9choice_variable_optional/tiramisu/base.py b/tests/dictionaries/01_9choice_variable_optional/tiramisu/base.py new file mode 100644 index 000000000..8772fec0c --- /dev/null +++ b/tests/dictionaries/01_9choice_variable_optional/tiramisu/base.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') +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="variable", doc="a variable", values=("a", "b", "c"), default="c", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/01_9choice_variable_optional/rougail/00-base.yml'], 'type': 'choice'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2], properties=frozenset({"standard"}), informations={'ymlfiles': ['']}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/01_9choice_variable_optional/tiramisu/no_namespace.py b/tests/dictionaries/01_9choice_variable_optional/tiramisu/no_namespace.py new file mode 100644 index 000000000..e6f39c71e --- /dev/null +++ b/tests/dictionaries/01_9choice_variable_optional/tiramisu/no_namespace.py @@ -0,0 +1,10 @@ +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="variable", doc="a variable", values=("a", "b", "c"), default="c", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/01_9choice_variable_optional/rougail/00-base.yml'], 'type': 'choice'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) diff --git a/tests/dictionaries/04_0type_param_integer/makedict/after.json b/tests/dictionaries/04_0type_param_integer/makedict/after.json new file mode 100644 index 000000000..cc1f4e879 --- /dev/null +++ b/tests/dictionaries/04_0type_param_integer/makedict/after.json @@ -0,0 +1,6 @@ +{ + "rougail.int": { + "owner": "default", + "value": 10 + } +} diff --git a/tests/dictionaries/04_0type_param_integer/makedict/base.json b/tests/dictionaries/04_0type_param_integer/makedict/base.json new file mode 100644 index 000000000..5c61db99c --- /dev/null +++ b/tests/dictionaries/04_0type_param_integer/makedict/base.json @@ -0,0 +1,3 @@ +{ + "rougail.int": 10 +} diff --git a/tests/dictionaries/04_0type_param_integer/makedict/before.json b/tests/dictionaries/04_0type_param_integer/makedict/before.json new file mode 100644 index 000000000..cc1f4e879 --- /dev/null +++ b/tests/dictionaries/04_0type_param_integer/makedict/before.json @@ -0,0 +1,6 @@ +{ + "rougail.int": { + "owner": "default", + "value": 10 + } +} diff --git a/tests/dictionaries/04_0type_param_integer/makedict/mandatory.json b/tests/dictionaries/04_0type_param_integer/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/04_0type_param_integer/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/04_0type_param_integer/makedict/read_write.json b/tests/dictionaries/04_0type_param_integer/makedict/read_write.json new file mode 100644 index 000000000..5c61db99c --- /dev/null +++ b/tests/dictionaries/04_0type_param_integer/makedict/read_write.json @@ -0,0 +1,3 @@ +{ + "rougail.int": 10 +} diff --git a/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/after.json b/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/after.json new file mode 100644 index 000000000..6cf711958 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/after.json @@ -0,0 +1,22 @@ +{ + "rougail.condition": { + "owner": "default", + "value": false + }, + "rougail.var1": { + "owner": "default", + "value": null + }, + "rougail.var2": { + "owner": "default", + "value": null + }, + "rougail.var3": { + "owner": "default", + "value": null + }, + "rougail.var4": { + "owner": "default", + "value": null + } +} diff --git a/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/base.json b/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/base.json new file mode 100644 index 000000000..b24f695b9 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/base.json @@ -0,0 +1,7 @@ +{ + "rougail.condition": false, + "rougail.var1": null, + "rougail.var2": null, + "rougail.var3": null, + "rougail.var4": null +} diff --git a/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/before.json b/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/before.json new file mode 100644 index 000000000..6cf711958 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/before.json @@ -0,0 +1,22 @@ +{ + "rougail.condition": { + "owner": "default", + "value": false + }, + "rougail.var1": { + "owner": "default", + "value": null + }, + "rougail.var2": { + "owner": "default", + "value": null + }, + "rougail.var3": { + "owner": "default", + "value": null + }, + "rougail.var4": { + "owner": "default", + "value": null + } +} diff --git a/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/mandatory.json b/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/read_write.json b/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/read_write.json new file mode 100644 index 000000000..15d4f0105 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_optional_default/makedict/read_write.json @@ -0,0 +1,5 @@ +{ + "rougail.condition": false, + "rougail.var3": null, + "rougail.var4": null +} diff --git a/tests/dictionaries/04_5disabled_calculation_optional_default/tiramisu/base.py b/tests/dictionaries/04_5disabled_calculation_optional_default/tiramisu/base.py new file mode 100644 index 000000000..75ba2e3e8 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_optional_default/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_2 = BoolOption(name="condition", doc="a condition", default=False, properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'boolean'}) +option_3 = StrOption(name="var1", doc="a first variable", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'}) +option_4 = StrOption(name="var2", doc="a first variable", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'}) +option_5 = StrOption(name="var3", doc="a second variable", properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['variable_to_property'], Params((ParamValue("hidden"), ParamOption(option_2)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property']), Calculation(func['variable_to_property'], Params((ParamValue("frozen"), ParamOption(option_2)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'}) +option_6 = StrOption(name="var4", doc="a forth variable", properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['variable_to_property'], Params((ParamValue("hidden"), ParamOption(option_2)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property']), Calculation(func['variable_to_property'], Params((ParamValue("frozen"), ParamOption(option_2)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3, option_4, option_5, option_6], properties=frozenset({"standard"}), informations={'ymlfiles': ['']}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/04_5disabled_calculation_optional_default/tiramisu/no_namespace.py b/tests/dictionaries/04_5disabled_calculation_optional_default/tiramisu/no_namespace.py new file mode 100644 index 000000000..b1138d4b4 --- /dev/null +++ b/tests/dictionaries/04_5disabled_calculation_optional_default/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_1 = BoolOption(name="condition", doc="a condition", default=False, properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'boolean'}) +option_2 = StrOption(name="var1", doc="a first variable", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'}) +option_3 = StrOption(name="var2", doc="a first variable", properties=frozenset({"force_default_on_freeze", "frozen", "hidden", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'}) +option_4 = StrOption(name="var3", doc="a second variable", properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['variable_to_property'], Params((ParamValue("hidden"), ParamOption(option_1)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property']), Calculation(func['variable_to_property'], Params((ParamValue("frozen"), ParamOption(option_1)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'}) +option_5 = StrOption(name="var4", doc="a forth variable", properties=frozenset({"force_default_on_freeze", "standard", Calculation(func['variable_to_property'], Params((ParamValue("hidden"), ParamOption(option_1)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property']), Calculation(func['variable_to_property'], Params((ParamValue("frozen"), ParamOption(option_1)), kwargs={'when': ParamValue(True), 'inverse': ParamValue(False)}), help_function=func['variable_to_property'])}), informations={'ymlfiles': ['../rougail-tests/structures/04_5disabled_calculation_optional_default/rougail/00-base.yml'], 'type': 'string'}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2, option_3, option_4, option_5]) diff --git a/tests/dictionaries/40_2leadership_calculation_index_2/makedict/after.json b/tests/dictionaries/40_2leadership_calculation_index_2/makedict/after.json new file mode 100644 index 000000000..153afde05 --- /dev/null +++ b/tests/dictionaries/40_2leadership_calculation_index_2/makedict/after.json @@ -0,0 +1,22 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "a", + "b", + "c" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default", + "default" + ], + "value": [ + 0, + 1, + 2 + ] + } +} diff --git a/tests/dictionaries/40_2leadership_calculation_index_2/makedict/base.json b/tests/dictionaries/40_2leadership_calculation_index_2/makedict/base.json new file mode 100644 index 000000000..33b6cf4f7 --- /dev/null +++ b/tests/dictionaries/40_2leadership_calculation_index_2/makedict/base.json @@ -0,0 +1,16 @@ +{ + "rougail.leader.leader": [ + { + "rougail.leader.leader": "a", + "rougail.leader.follower1": 0 + }, + { + "rougail.leader.leader": "b", + "rougail.leader.follower1": 1 + }, + { + "rougail.leader.leader": "c", + "rougail.leader.follower1": 2 + } + ] +} diff --git a/tests/dictionaries/40_2leadership_calculation_index_2/makedict/before.json b/tests/dictionaries/40_2leadership_calculation_index_2/makedict/before.json new file mode 100644 index 000000000..153afde05 --- /dev/null +++ b/tests/dictionaries/40_2leadership_calculation_index_2/makedict/before.json @@ -0,0 +1,22 @@ +{ + "rougail.leader.leader": { + "owner": "default", + "value": [ + "a", + "b", + "c" + ] + }, + "rougail.leader.follower1": { + "owner": [ + "default", + "default", + "default" + ], + "value": [ + 0, + 1, + 2 + ] + } +} diff --git a/tests/dictionaries/40_2leadership_calculation_index_2/makedict/mandatory.json b/tests/dictionaries/40_2leadership_calculation_index_2/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/40_2leadership_calculation_index_2/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/40_2leadership_calculation_index_2/makedict/read_write.json b/tests/dictionaries/40_2leadership_calculation_index_2/makedict/read_write.json new file mode 100644 index 000000000..33b6cf4f7 --- /dev/null +++ b/tests/dictionaries/40_2leadership_calculation_index_2/makedict/read_write.json @@ -0,0 +1,16 @@ +{ + "rougail.leader.leader": [ + { + "rougail.leader.leader": "a", + "rougail.leader.follower1": 0 + }, + { + "rougail.leader.leader": "b", + "rougail.leader.follower1": 1 + }, + { + "rougail.leader.leader": "c", + "rougail.leader.follower1": 2 + } + ] +} diff --git a/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/after.json b/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/after.json new file mode 100644 index 000000000..4a6ebf2c2 --- /dev/null +++ b/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/after.json @@ -0,0 +1,19 @@ +{ + "rougail.leadership.leader": { + "owner": "default", + "value": [ + "a", + "b" + ] + }, + "rougail.leadership.follower": { + "owner": [ + "error", + "default" + ], + "value": [ + "cannot access to option \"a follower\" at index \"0\" because has property \"disabled\" (the first follower)", + "value" + ] + } +} diff --git a/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/base.json b/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/base.json new file mode 100644 index 000000000..19cc323ff --- /dev/null +++ b/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/base.json @@ -0,0 +1,11 @@ +{ + "rougail.leadership.leader": [ + { + "rougail.leadership.leader": "a" + }, + { + "rougail.leadership.leader": "b", + "rougail.leadership.follower": "value" + } + ] +} diff --git a/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/before.json b/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/before.json new file mode 100644 index 000000000..4a6ebf2c2 --- /dev/null +++ b/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/before.json @@ -0,0 +1,19 @@ +{ + "rougail.leadership.leader": { + "owner": "default", + "value": [ + "a", + "b" + ] + }, + "rougail.leadership.follower": { + "owner": [ + "error", + "default" + ], + "value": [ + "cannot access to option \"a follower\" at index \"0\" because has property \"disabled\" (the first follower)", + "value" + ] + } +} diff --git a/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/mandatory.json b/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/read_write.json b/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/read_write.json new file mode 100644 index 000000000..19cc323ff --- /dev/null +++ b/tests/dictionaries/44_4disabled_calcultion_follower_index/makedict/read_write.json @@ -0,0 +1,11 @@ +{ + "rougail.leadership.leader": [ + { + "rougail.leadership.leader": "a" + }, + { + "rougail.leadership.leader": "b", + "rougail.leadership.follower": "value" + } + ] +} diff --git a/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/after.json b/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/after.json new file mode 100644 index 000000000..6c7e003ca --- /dev/null +++ b/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/after.json @@ -0,0 +1,10 @@ +{ + "rougail.dyna.var": { + "owner": "default", + "value": "val" + }, + "rougail.dynb.var": { + "owner": "default", + "value": "val" + } +} diff --git a/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/base.json b/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/base.json new file mode 100644 index 000000000..4a69e98bb --- /dev/null +++ b/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/base.json @@ -0,0 +1,4 @@ +{ + "rougail.dyna.var": "val", + "rougail.dynb.var": "val" +} diff --git a/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/before.json b/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/before.json new file mode 100644 index 000000000..6c7e003ca --- /dev/null +++ b/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/before.json @@ -0,0 +1,10 @@ +{ + "rougail.dyna.var": { + "owner": "default", + "value": "val" + }, + "rougail.dynb.var": { + "owner": "default", + "value": "val" + } +} diff --git a/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/mandatory.json b/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/mandatory.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/mandatory.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/read_write.json b/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/read_write.json new file mode 100644 index 000000000..4a69e98bb --- /dev/null +++ b/tests/dictionaries/60_0family_dynamic_variable_optional/makedict/read_write.json @@ -0,0 +1,4 @@ +{ + "rougail.dyna.var": "val", + "rougail.dynb.var": "val" +} diff --git a/tests/dictionaries/60_0family_dynamic_variable_optional/tiramisu/base.py b/tests/dictionaries/60_0family_dynamic_variable_optional/tiramisu/base.py new file mode 100644 index 000000000..73dac043c --- /dev/null +++ b/tests/dictionaries/60_0family_dynamic_variable_optional/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_3 = StrOption(name="var", doc="a variable inside dynamic family", default="val", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/60_0family_dynamic_variable_optional/rougail/00-base.yml'], 'type': 'string'}) +optiondescription_2 = ConvertDynOptionDescription(name="dyn{{ identifier }}", doc="a dynamic family", identifiers=["a", "b"], children=[option_3], properties=frozenset({"standard"}), informations={'dynamic_variable': 'rougail.unknown_var', 'ymlfiles': ['../rougail-tests/structures/60_0family_dynamic_variable_optional/rougail/00-base.yml']}) +optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2], properties=frozenset({"standard"}), informations={'ymlfiles': ['']}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/dictionaries/60_0family_dynamic_variable_optional/tiramisu/no_namespace.py b/tests/dictionaries/60_0family_dynamic_variable_optional/tiramisu/no_namespace.py new file mode 100644 index 000000000..16825ea13 --- /dev/null +++ b/tests/dictionaries/60_0family_dynamic_variable_optional/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_2 = StrOption(name="var", doc="a variable inside dynamic family", default="val", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/60_0family_dynamic_variable_optional/rougail/00-base.yml'], 'type': 'string'}) +optiondescription_1 = ConvertDynOptionDescription(name="dyn{{ identifier }}", doc="a dynamic family", identifiers=["a", "b"], children=[option_2], properties=frozenset({"standard"}), informations={'dynamic_variable': 'unknown_var', 'ymlfiles': ['../rougail-tests/structures/60_0family_dynamic_variable_optional/rougail/00-base.yml']}) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) diff --git a/tests/errors/00_9default_calculation_multi_optional_default_not_list/errno_77 b/tests/errors/00_9default_calculation_multi_optional_default_not_list/errno_77 new file mode 100644 index 000000000..e69de29bb diff --git a/tests/errors/00_9default_calculation_multi_optional_default_not_list/rougail/00-base.yml b/tests/errors/00_9default_calculation_multi_optional_default_not_list/rougail/00-base.yml new file mode 100644 index 000000000..117f8181d --- /dev/null +++ b/tests/errors/00_9default_calculation_multi_optional_default_not_list/rougail/00-base.yml @@ -0,0 +1,10 @@ +--- +version: 1.1 +my_variable: + default: val1 +my_calculated_variable: + multi: true + default: + variable: _.my_variable_unexists + optional: true + default: value diff --git a/tests/errors/00_9default_calculation_not_multi_optional_default_list/errno_77 b/tests/errors/00_9default_calculation_not_multi_optional_default_list/errno_77 new file mode 100644 index 000000000..e69de29bb diff --git a/tests/errors/00_9default_calculation_not_multi_optional_default_list/rougail/00-base.yml b/tests/errors/00_9default_calculation_not_multi_optional_default_list/rougail/00-base.yml new file mode 100644 index 000000000..b66660244 --- /dev/null +++ b/tests/errors/00_9default_calculation_not_multi_optional_default_list/rougail/00-base.yml @@ -0,0 +1,10 @@ +--- +version: 1.1 +my_variable: + default: val1 +my_calculated_variable: + default: + variable: _.my_variable_unexists + optional: true + default: + - value diff --git a/tests/errors/01_9choice_variable_optional_not_list/errno_77 b/tests/errors/01_9choice_variable_optional_not_list/errno_77 new file mode 100644 index 000000000..e69de29bb diff --git a/tests/errors/01_9choice_variable_optional_not_list/rougail/00-base.yml b/tests/errors/01_9choice_variable_optional_not_list/rougail/00-base.yml new file mode 100644 index 000000000..8f5c0b4e2 --- /dev/null +++ b/tests/errors/01_9choice_variable_optional_not_list/rougail/00-base.yml @@ -0,0 +1,9 @@ +--- +version: 1.1 + +variable: + description: a variable + choices: + variable: _.unknown_variable + optional: true + default: c diff --git a/tests/errors/60_0family_dynamic_variable_optional_not_list/errno_77 b/tests/errors/60_0family_dynamic_variable_optional_not_list/errno_77 new file mode 100644 index 000000000..e69de29bb diff --git a/tests/errors/60_0family_dynamic_variable_optional_not_list/rougail/00-base.yml b/tests/errors/60_0family_dynamic_variable_optional_not_list/rougail/00-base.yml new file mode 100644 index 000000000..bfeecd22d --- /dev/null +++ b/tests/errors/60_0family_dynamic_variable_optional_not_list/rougail/00-base.yml @@ -0,0 +1,13 @@ +%YAML 1.2 +--- +version: 1.1 + +"dyn{{ identifier }}": + description: a dynamic family + dynamic: + variable: _.unknown_var + optional: true + default: a + + var: val # a variable inside dynamic family +... diff --git a/tests/test_1_flattener.py b/tests/test_1_flattener.py index ebbc143a5..23dc1d8db 100644 --- a/tests/test_1_flattener.py +++ b/tests/test_1_flattener.py @@ -47,7 +47,7 @@ excludes = set([ ]) test_ok -= excludes test_raise -= excludes -# test_ok = ['04_5validators_multi3'] +# test_ok = ['01_9choice_variable_optional'] #test_ok = [] # test_raise = ['80unknown_default_variable_inside_dynamic_family'] #test_raise = [] diff --git a/tests/test_2_makedict.py b/tests/test_2_makedict.py index 1d453eb79..3d5b60749 100644 --- a/tests/test_2_makedict.py +++ b/tests/test_2_makedict.py @@ -31,7 +31,7 @@ excludes = set([]) # excludes = set(['60_5family_dynamic_variable_outside_sub_suffix']) test_ok -= excludes -test_ok = ['44_9calculated_default_leadership_leader'] +# test_ok = ['04_5disabled_calculation_optional_default'] test_ok = list(test_ok)