recalculate forced value when config.new()
This commit is contained in:
parent
5bc81f3749
commit
e41af1fdce
|
@ -3,7 +3,7 @@ from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import groups
|
from tiramisu.setting import groups
|
||||||
from tiramisu import Config
|
from tiramisu import Config, MetaConfig
|
||||||
from tiramisu import ChoiceOption, BoolOption, IntOption, \
|
from tiramisu import ChoiceOption, BoolOption, IntOption, \
|
||||||
StrOption, OptionDescription
|
StrOption, OptionDescription
|
||||||
from .test_state import _diff_opts, _diff_conf
|
from .test_state import _diff_opts, _diff_conf
|
||||||
|
@ -72,3 +72,14 @@ def test_copy_force_store_value():
|
||||||
conf.option('creole.general.wantref').value.set(True)
|
conf.option('creole.general.wantref').value.set(True)
|
||||||
assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (True,), ('user',))
|
assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (True,), ('user',))
|
||||||
assert to_tuple(conf2.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',))
|
assert to_tuple(conf2.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',))
|
||||||
|
|
||||||
|
|
||||||
|
def test_copy_force_store_value_metaconfig():
|
||||||
|
descr = make_description()
|
||||||
|
meta = MetaConfig([], optiondescription=descr)
|
||||||
|
conf = meta.config.new(session_id='conf')
|
||||||
|
assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',))
|
||||||
|
assert to_tuple(meta.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',))
|
||||||
|
conf.option('creole.general.wantref').value.set(True)
|
||||||
|
assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (True,), ('user',))
|
||||||
|
assert to_tuple(meta.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',))
|
||||||
|
|
|
@ -997,8 +997,10 @@ class TiramisuContextConfig(TiramisuContext):
|
||||||
def _c_meta(self):
|
def _c_meta(self):
|
||||||
return Config(self.config_bag.context.cfgimpl_get_meta())
|
return Config(self.config_bag.context.cfgimpl_get_meta())
|
||||||
|
|
||||||
def _m_new(self, name):
|
def _m_new(self,
|
||||||
return Config(self.config_bag.context.new_config(name))
|
session_id,
|
||||||
|
persistent=False):
|
||||||
|
return Config(self.config_bag.context.new_config(session_id=session_id, persistent=persistent))
|
||||||
|
|
||||||
def _m_list(self):
|
def _m_list(self):
|
||||||
return self._g_list()
|
return self._g_list()
|
||||||
|
|
|
@ -770,7 +770,7 @@ class KernelConfig(_CommonConfig):
|
||||||
weakref.ref(self),
|
weakref.ref(self),
|
||||||
ConfigBag(self),
|
ConfigBag(self),
|
||||||
None)
|
None)
|
||||||
if _duplicate is False and (force_settings is None or force_values is None):
|
if None in [force_settings, force_values]:
|
||||||
self._impl_build_all_caches()
|
self._impl_build_all_caches()
|
||||||
self._impl_name = session_id
|
self._impl_name = session_id
|
||||||
|
|
||||||
|
@ -986,11 +986,13 @@ class KernelMetaConfig(KernelGroupConfig):
|
||||||
if not _duplicate:
|
if not _duplicate:
|
||||||
new_children = []
|
new_children = []
|
||||||
for child_session_id in children:
|
for child_session_id in children:
|
||||||
|
if not isinstance(child_session_id, str):
|
||||||
|
raise TypeError(_('MetaConfig with optiondescription must have '
|
||||||
|
'string has child, not {}').format(child_session_id))
|
||||||
new_children.append(KernelConfig(optiondescription,
|
new_children.append(KernelConfig(optiondescription,
|
||||||
persistent=persistent,
|
persistent=persistent,
|
||||||
session_id=child_session_id))
|
session_id=child_session_id))
|
||||||
children = new_children
|
children = new_children
|
||||||
else:
|
|
||||||
descr = optiondescription
|
descr = optiondescription
|
||||||
for child in children:
|
for child in children:
|
||||||
if not isinstance(child, _CommonConfig):
|
if not isinstance(child, _CommonConfig):
|
||||||
|
@ -1016,6 +1018,7 @@ class KernelMetaConfig(KernelGroupConfig):
|
||||||
force_values=force_values,
|
force_values=force_values,
|
||||||
storage=storage,
|
storage=storage,
|
||||||
_descr=descr)
|
_descr=descr)
|
||||||
|
self._impl_build_all_caches()
|
||||||
|
|
||||||
def set_value(self,
|
def set_value(self,
|
||||||
path,
|
path,
|
||||||
|
|
Loading…
Reference in New Issue