do not valid properties when remove cache for information

This commit is contained in:
egarette@silique.fr 2023-06-27 13:28:44 +02:00
parent 460039386a
commit 3e6b90bd9c
2 changed files with 17 additions and 1 deletions

View file

@ -11,7 +11,7 @@ from tiramisu.setting import owners, groups
from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \ from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \
StrOption, OptionDescription, Leadership, Config, undefined, \ StrOption, OptionDescription, Leadership, Config, undefined, \
Calculation, Params, ParamOption, ParamValue, ParamIndex, \ Calculation, Params, ParamOption, ParamValue, ParamIndex, \
calc_value, calc_value_property_help calc_value, calc_value_property_help, ParamInformation
from tiramisu.error import PropertiesOptionError from tiramisu.error import PropertiesOptionError
import warnings import warnings
from .config import config_type, get_config from .config import config_type, get_config
@ -894,3 +894,18 @@ def test_settings_list_with_follower():
cfg = Config(OptionDescription('root', 'root', [descr])) cfg = Config(OptionDescription('root', 'root', [descr]))
cfg.property.read_write() cfg.property.read_write()
assert len(cfg.option('root').list('all')) == 2 assert len(cfg.option('root').list('all')) == 2
def return_none(*args):
return
def test_settings_disable_set_information(config_type):
opt1 = StrOption('opt1', '', ['val'], multi=True)
opt2 = StrOption('opt2', '', default_multi='test', validators=[Calculation(return_none, Params((ParamInformation('key'))))], properties=frozenset([Calculation(return_none, Params((ParamInformation('key'))))]), multi=True)
od2 = Leadership('leadership', '', [opt1, opt2])
od1 = OptionDescription('root', '', [od2])
cfg = Config(od1)
cfg.property.read_only()
cfg.information.set('key', 'val')
assert cfg.value.dict() == {'leadership.opt1': [{'leadership.opt1': 'val', 'leadership.opt2': 'test'}]}

View file

@ -599,6 +599,7 @@ class _CommonConfig(_SubConfig):
option_bag = OptionBag(option, option_bag = OptionBag(option,
None, None,
config_bag, config_bag,
properties=None,
) )
self.reset_cache(option_bag) self.reset_cache(option_bag)