diff --git a/src/rougail/annotator/constrainte.py b/src/rougail/annotator/constrainte.py index c047ab44..921918b5 100644 --- a/src/rougail/annotator/constrainte.py +++ b/src/rougail/annotator/constrainte.py @@ -452,19 +452,15 @@ class ConstrainteAnnotator: main_action = actions[0] if getattr(leader_or_variable, main_action, False) is True: continue - if isinstance(leader_or_variable, self.objectspace.variable) and \ - (leader_or_variable.auto_save or leader_or_variable.auto_freeze) and \ - 'force_default_on_freeze' in actions: - xmlfiles = self.objectspace.display_xmlfiles(leader_or_variable.xmlfiles) - msg = _(f'cannot have auto_freeze or auto_store with the hidden_if_in or ' - f'hidden_if_not_in variable "{leader_or_variable.name}" ' - f'in {xmlfiles}') - raise DictConsistencyError(msg, 51) self.build_property(leader_or_variable, text, condition, main_action, ) + if isinstance(leader_or_variable, self.objectspace.variable) and \ + (leader_or_variable.auto_save or leader_or_variable.auto_freeze) and \ + 'force_default_on_freeze' in actions: + continue for action in actions[1:]: # other actions are set to the variable or children of family for variable in variables: diff --git a/tests/dictionaries/01hidden_if_in_autofreeze/00-base.xml b/tests/dictionaries/01hidden_if_in_autofreeze/00-base.xml new file mode 100644 index 00000000..6d9be17d --- /dev/null +++ b/tests/dictionaries/01hidden_if_in_autofreeze/00-base.xml @@ -0,0 +1,25 @@ + + + + + + non + + + non + + + + + + + oui + + + oui + mode_conteneur_actif + + + + diff --git a/tests/dictionaries/80autosave_hidden_frozenifin/__init__.py b/tests/dictionaries/01hidden_if_in_autofreeze/__init__.py similarity index 100% rename from tests/dictionaries/80autosave_hidden_frozenifin/__init__.py rename to tests/dictionaries/01hidden_if_in_autofreeze/__init__.py diff --git a/tests/dictionaries/01hidden_if_in_autofreeze/makedict/base.json b/tests/dictionaries/01hidden_if_in_autofreeze/makedict/base.json new file mode 100644 index 00000000..8b4451f4 --- /dev/null +++ b/tests/dictionaries/01hidden_if_in_autofreeze/makedict/base.json @@ -0,0 +1 @@ +{"rougail.general.module_instancie": "non", "rougail.general.mode_conteneur_actif": "oui"} diff --git a/tests/dictionaries/01hidden_if_in_autofreeze/tiramisu/base.py b/tests/dictionaries/01hidden_if_in_autofreeze/tiramisu/base.py new file mode 100644 index 00000000..bb1661e4 --- /dev/null +++ b/tests/dictionaries/01hidden_if_in_autofreeze/tiramisu/base.py @@ -0,0 +1,15 @@ +from importlib.machinery import SourceFileLoader +func = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py').load_module() +for key, value in dict(locals()).items(): + if key != ['SourceFileLoader', 'func']: + setattr(func, key, value) +try: + from tiramisu3 import * +except: + from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +option_3 = ChoiceOption(properties=frozenset({'mandatory', 'normal'}), name='module_instancie', doc='No change', multi=False, default='non', values=('oui', 'non')) +option_4 = ChoiceOption(properties=frozenset({'auto_freeze', 'basic', 'force_store_value', 'mandatory', Calculation(calc_value, Params(ParamValue('hidden'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')})), Calculation(calc_value, Params(ParamValue('auto_frozen'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui'), 'reverse_condition': ParamValue(True)}))}), name='mode_conteneur_actif', doc='No change', multi=False, default=Calculation(func.calc_val, Params((ParamValue("oui")), kwargs={})), values=('oui', 'non')) +option_2 = OptionDescription(name='general', doc='general', properties=frozenset({'basic'}), children=[option_3, option_4]) +option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1]) diff --git a/tests/dictionaries/80autosave_hidden_frozenifin/00-base.xml b/tests/dictionaries/02autosave_hidden_frozenifin/00-base.xml similarity index 100% rename from tests/dictionaries/80autosave_hidden_frozenifin/00-base.xml rename to tests/dictionaries/02autosave_hidden_frozenifin/00-base.xml diff --git a/tests/dictionaries/80autosave_hidden_frozenifin/errno_51 b/tests/dictionaries/02autosave_hidden_frozenifin/__init__.py similarity index 100% rename from tests/dictionaries/80autosave_hidden_frozenifin/errno_51 rename to tests/dictionaries/02autosave_hidden_frozenifin/__init__.py diff --git a/tests/dictionaries/02autosave_hidden_frozenifin/errno_51 b/tests/dictionaries/02autosave_hidden_frozenifin/errno_51 new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/02autosave_hidden_frozenifin/makedict/base.json b/tests/dictionaries/02autosave_hidden_frozenifin/makedict/base.json new file mode 100644 index 00000000..2a8f28f8 --- /dev/null +++ b/tests/dictionaries/02autosave_hidden_frozenifin/makedict/base.json @@ -0,0 +1 @@ +{"rougail.general.mode_conteneur_actif": "non", "rougail.general.autosavevar": "oui"} diff --git a/tests/dictionaries/02autosave_hidden_frozenifin/tiramisu/base.py b/tests/dictionaries/02autosave_hidden_frozenifin/tiramisu/base.py new file mode 100644 index 00000000..60047cec --- /dev/null +++ b/tests/dictionaries/02autosave_hidden_frozenifin/tiramisu/base.py @@ -0,0 +1,15 @@ +from importlib.machinery import SourceFileLoader +func = SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py').load_module() +for key, value in dict(locals()).items(): + if key != ['SourceFileLoader', 'func']: + setattr(func, key, value) +try: + from tiramisu3 import * +except: + from tiramisu import * +from rougail.tiramisu import ConvertDynOptionDescription +option_3 = ChoiceOption(properties=frozenset({'force_default_on_freeze', 'frozen', 'hidden', 'mandatory', 'normal'}), name='mode_conteneur_actif', doc='No change', multi=False, default='non', values=('oui', 'non')) +option_4 = StrOption(properties=frozenset({'basic', 'force_store_value', Calculation(calc_value, Params(ParamValue('hidden'), kwargs={'condition': ParamOption(option_3, todict=True), 'expected': ParamValue('oui')}))}), name='autosavevar', doc='autosave variable', multi=False, default=Calculation(func.calc_val, Params((ParamValue("oui")), kwargs={}))) +option_2 = OptionDescription(name='general', doc='général', properties=frozenset({'basic'}), children=[option_3, option_4]) +option_1 = OptionDescription(name='rougail', doc='rougail', children=[option_2]) +option_0 = OptionDescription(name='baseoption', doc='baseoption', children=[option_1])