feature(api) cfg.option(xxxx).option.yyy() => cfg.option(xxxx).yyy()
This commit is contained in:
parent
fe2b6fb6a2
commit
0a4e1445db
16 changed files with 268 additions and 263 deletions
|
@ -74,9 +74,9 @@ def _autocheck_default_value(cfg, path, conf, **kwargs):
|
|||
"""set and get values
|
||||
"""
|
||||
# check if is a multi, a leader or a follower
|
||||
multi = cfg.unrestraint.option(path).option.ismulti()
|
||||
submulti_ = cfg.unrestraint.option(path).option.issubmulti()
|
||||
isfollower = cfg.unrestraint.option(path).option.isfollower()
|
||||
multi = cfg.unrestraint.option(path).ismulti()
|
||||
submulti_ = cfg.unrestraint.option(path).issubmulti()
|
||||
isfollower = cfg.unrestraint.option(path).isfollower()
|
||||
|
||||
# set default value (different if value is multi or not)
|
||||
empty_value = kwargs['default']
|
||||
|
@ -121,10 +121,10 @@ def _autocheck_default_value(cfg, path, conf, **kwargs):
|
|||
|
||||
def _set_value(cfg, pathwrite, conf, **kwargs):
|
||||
set_permissive = kwargs.get('set_permissive', True)
|
||||
multi = cfg.unrestraint.option(pathwrite).option.ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathwrite).option.issubmulti()
|
||||
isleader = cfg.unrestraint.option(pathwrite).option.isleader()
|
||||
isfollower = cfg.unrestraint.option(pathwrite).option.isfollower()
|
||||
multi = cfg.unrestraint.option(pathwrite).ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathwrite).issubmulti()
|
||||
isleader = cfg.unrestraint.option(pathwrite).isleader()
|
||||
isfollower = cfg.unrestraint.option(pathwrite).isfollower()
|
||||
if not multi:
|
||||
first_value = FIRST_VALUE
|
||||
elif submulti_ is False:
|
||||
|
@ -226,7 +226,7 @@ def _check_properties(cfg, mcfg, pathread, conf, kwargs, props_permissive, props
|
|||
cfg_ = cfg.config(conf)
|
||||
else:
|
||||
cfg_ = cfg
|
||||
if not cfg.unrestraint.option(pathread).option.isfollower():
|
||||
if not cfg.unrestraint.option(pathread).isfollower():
|
||||
if not kwargs.get('permissive_od', False):
|
||||
assert set(cfg_.option(pathread).property.get()) == set(props_permissive)
|
||||
assert set(cfg_.option(pathread).property.get()) == set(props)
|
||||
|
@ -267,8 +267,8 @@ def _check_properties(cfg, mcfg, pathread, conf, kwargs, props_permissive, props
|
|||
|
||||
def _property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
# check if is a multi or a follower
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
multi = cfg.unrestraint.option(pathread).ismulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
|
||||
# define properties
|
||||
properties = copy(PROPERTIES_LIST)
|
||||
|
@ -309,9 +309,9 @@ def _property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **
|
|||
|
||||
def _autocheck_get_value(cfg, pathread, conf, **kwargs):
|
||||
set_permissive = kwargs.get('set_permissive', True)
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
multi = cfg.unrestraint.option(pathread).ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathread).issubmulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
empty_value = kwargs['default']
|
||||
if not multi:
|
||||
first_value = FIRST_VALUE
|
||||
|
@ -371,7 +371,7 @@ def _autocheck_get_value(cfg, pathread, conf, **kwargs):
|
|||
|
||||
|
||||
def _check_owner(cfg, pathread, conf, kwargs, owner, permissive_owner):
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
if conf is not None:
|
||||
cfg_ = cfg.config(conf)
|
||||
else:
|
||||
|
@ -415,24 +415,24 @@ def autocheck_option_multi(cfg, mcfg, pathread, pathwrite, confread, confwrite,
|
|||
if pathwrite in ['subod.subsubod.first', 'subod.subsubod.second', 'subod.subsubodval1.firstval1', 'subod.subsubod.third', 'subod.subsubodval1.secondval1', 'subod.subsubodval1.thirdval1', 'subod.subsubodval2.firstval2', 'subod.subsubodval2.secondval2', 'subod.subsubodval2.thirdval2']:
|
||||
return
|
||||
if not kwargs.get('permissive_od', False):
|
||||
cfg.option(pathread).option.ismulti()
|
||||
cfg.option(pathread).option.issubmulti()
|
||||
cfg.option(pathread).option.isleader()
|
||||
cfg.option(pathread).option.isfollower()
|
||||
cfg.option(pathread).ismulti()
|
||||
cfg.option(pathread).issubmulti()
|
||||
cfg.option(pathread).isleader()
|
||||
cfg.option(pathread).isfollower()
|
||||
else:
|
||||
with raises(PropertiesOptionError):
|
||||
cfg.option(pathread).option.ismulti()
|
||||
cfg.option(pathread).ismulti()
|
||||
with raises(PropertiesOptionError):
|
||||
cfg.option(pathread).option.issubmulti()
|
||||
cfg.option(pathread).issubmulti()
|
||||
with raises(PropertiesOptionError):
|
||||
cfg.option(pathread).option.isleader()
|
||||
cfg.option(pathread).isleader()
|
||||
with raises(PropertiesOptionError):
|
||||
cfg.option(pathread).option.isfollower()
|
||||
cfg.option(pathread).isfollower()
|
||||
|
||||
cfg.forcepermissive.option(pathread).option.ismulti()
|
||||
cfg.forcepermissive.option(pathread).option.issubmulti()
|
||||
cfg.forcepermissive.option(pathread).option.isleader()
|
||||
cfg.forcepermissive.option(pathread).option.isfollower()
|
||||
cfg.forcepermissive.option(pathread).ismulti()
|
||||
cfg.forcepermissive.option(pathread).issubmulti()
|
||||
cfg.forcepermissive.option(pathread).isleader()
|
||||
cfg.forcepermissive.option(pathread).isfollower()
|
||||
|
||||
|
||||
|
||||
|
@ -442,7 +442,7 @@ def autocheck_default_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite,
|
|||
"""
|
||||
if pathwrite in ['subod.subsubod.first', 'subod.subsubod.second', 'subod.subsubod.third', 'subod.subsubodval1.firstval1', 'subod.subsubodval1.secondval1', 'subod.subsubodval1.thirdval1', 'subod.subsubodval2.firstval2', 'subod.subsubodval2.secondval2', 'subod.subsubodval2.thirdval2']:
|
||||
return
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
# check if owner is a string "default" and 'isdefault'
|
||||
def do(conf):
|
||||
if conf is not None:
|
||||
|
@ -524,9 +524,9 @@ def autocheck_set_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k
|
|||
|
||||
@autocheck
|
||||
def autocheck_get_value_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
multi = cfg.unrestraint.option(pathread).ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathread).issubmulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
empty_value = kwargs['default']
|
||||
if not multi:
|
||||
|
@ -609,13 +609,13 @@ def autocheck_value_follower(cfg, mcfg, pathread, pathwrite, confread, confwrite
|
|||
#FIXME
|
||||
if pathwrite in ['odleader.third', 'subodval1.subsubodval1.thirdval1', 'subodval2.subsubodval2.thirdval2']:
|
||||
return
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
if not isfollower:
|
||||
return
|
||||
if kwargs.get('propertyerror', False):
|
||||
return
|
||||
|
||||
submulti_ = cfg.forcepermissive.option(pathread).option.issubmulti()
|
||||
submulti_ = cfg.forcepermissive.option(pathread).issubmulti()
|
||||
empty_value = kwargs['default']
|
||||
|
||||
def do(conf):
|
||||
|
@ -656,9 +656,9 @@ def autocheck_value_follower(cfg, mcfg, pathread, pathwrite, confread, confwrite
|
|||
@autocheck
|
||||
def autocheck_reset_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
# check if is a multi, a leader or a follower
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
multi = cfg.unrestraint.option(pathread).ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathread).issubmulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
|
||||
# set default value (different if value is multi or not)
|
||||
if not multi:
|
||||
|
@ -720,8 +720,8 @@ def autocheck_reset_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, *
|
|||
|
||||
@autocheck
|
||||
def autocheck_append_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
isleader = cfg.unrestraint.option(pathread).option.isleader()
|
||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||
isleader = cfg.unrestraint.option(pathread).isleader()
|
||||
submulti_ = cfg.unrestraint.option(pathread).issubmulti()
|
||||
if not isleader:
|
||||
return
|
||||
if confread is not None:
|
||||
|
@ -766,8 +766,8 @@ def autocheck_append_value(cfg, mcfg, pathread, pathwrite, confread, confwrite,
|
|||
|
||||
@autocheck
|
||||
def autocheck_pop_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
isleader = cfg.unrestraint.option(pathread).option.isleader()
|
||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||
isleader = cfg.unrestraint.option(pathread).isleader()
|
||||
submulti_ = cfg.unrestraint.option(pathread).issubmulti()
|
||||
if not isleader:
|
||||
return
|
||||
|
||||
|
@ -826,7 +826,7 @@ def autocheck_pop_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k
|
|||
@autocheck
|
||||
def autocheck_reset_value_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
# check if is a multi, a leader or a follower
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
# reset value with permissive
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
|
@ -891,8 +891,8 @@ def autocheck_property(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kw
|
|||
if pathwrite in ['odleader.first', 'subod.subsubod.first', 'subod.subsubod.second', 'subod.subsubod.third', 'subod.subsubodval1.firstval1', 'subod.subsubodval1.secondval1', 'subod.subsubodval1.thirdval1', 'subod.subsubodval2.firstval2', 'subod.subsubodval2.secondval2', 'subod.subsubodval2.thirdval2', 'subodval1.subsubodval1.firstval1', 'subodval1.subsubodval1.secondval1', 'subodval1.subsubodval1.thirdval1', 'subodval2.subsubodval2.firstval2', 'subodval2.subsubodval2.secondval2', 'subodval2.subsubodval2.thirdval2']:
|
||||
return
|
||||
# check if is a multi or a follower
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
multi = cfg.unrestraint.option(pathread).ismulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
|
||||
default_props, properties = _getproperties(multi, isfollower, kwargs)
|
||||
|
||||
|
@ -931,8 +931,8 @@ def autocheck_reset_property(cfg, mcfg, pathread, pathwrite, confread, confwrite
|
|||
if pathwrite in ['odleader.first', 'subod.subsubod.first', 'subod.subsubod.second', 'subod.subsubod.third', 'subod.subsubodval1.firstval1', 'subod.subsubodval1.secondval1', 'subod.subsubodval1.thirdval1', 'subod.subsubodval2.firstval2', 'subod.subsubodval2.secondval2', 'subod.subsubodval2.thirdval2', 'subodval1.subsubodval1.firstval1', 'subodval1.subsubodval1.secondval1', 'subodval1.subsubodval1.thirdval1', 'subodval2.subsubodval2.firstval2', 'subodval2.subsubodval2.secondval2', 'subodval2.subsubodval2.thirdval2']:
|
||||
return
|
||||
# check if is a multi or a follower
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
multi = cfg.unrestraint.option(pathread).ismulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
default_props, properties = _getproperties(multi, isfollower, kwargs)
|
||||
|
||||
_property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||
|
@ -956,8 +956,8 @@ def autocheck_reset_property_permissive(cfg, mcfg, pathread, pathwrite, confread
|
|||
#FIXME
|
||||
if pathwrite in ['odleader.first', 'subod.subsubod.first', 'subod.subsubod.second', 'subod.subsubod.third', 'subod.subsubodval1.firstval1', 'subod.subsubodval1.secondval1', 'subod.subsubodval1.thirdval1', 'subod.subsubodval2.firstval2', 'subod.subsubodval2.secondval2', 'subod.subsubodval2.thirdval2', 'subodval1.subsubodval1.firstval1', 'subodval1.subsubodval1.secondval1', 'subodval1.subsubodval1.thirdval1', 'subodval2.subsubodval2.firstval2', 'subodval2.subsubodval2.secondval2', 'subodval2.subsubodval2.thirdval2']:
|
||||
return
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
multi = cfg.unrestraint.option(pathread).ismulti()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
default_props, properties = _getproperties(multi, isfollower, kwargs)
|
||||
|
||||
_property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||
|
@ -989,7 +989,7 @@ def autocheck_owner_with_value(cfg, mcfg, pathread, pathwrite, confread, confwri
|
|||
|
||||
@autocheck
|
||||
def autocheck_default_owner_with_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
|
||||
if confwrite is not None:
|
||||
|
@ -1022,7 +1022,7 @@ def autocheck_default_owner_with_value(cfg, mcfg, pathread, pathwrite, confread,
|
|||
@autocheck
|
||||
def autocheck_default_owner_with_value_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
# check if is a isfollower
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
|
||||
|
@ -1045,7 +1045,7 @@ def autocheck_default_owner_with_value_permissive(cfg, mcfg, pathread, pathwrite
|
|||
|
||||
@autocheck
|
||||
def autocheck_set_owner_no_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
if confwrite is not None:
|
||||
cfg_ = cfg.forcepermissive.config(confwrite)
|
||||
else:
|
||||
|
@ -1064,7 +1064,7 @@ def autocheck_set_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k
|
|||
# test set owner without permissive
|
||||
if pathwrite in ['subod.subsubod.first', 'subod.subsubod.second', 'subod.subsubod.third', 'subod.subsubodval1.firstval1', 'subod.subsubodval1.secondval1', 'subod.subsubodval1.thirdval1', 'subod.subsubodval2.firstval2', 'subod.subsubodval2.secondval2', 'subod.subsubodval2.thirdval2']:
|
||||
return
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
if confwrite is not None:
|
||||
|
@ -1097,7 +1097,7 @@ def autocheck_set_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k
|
|||
def autocheck_set_owner_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
if pathwrite in ['subod.subsubod.first', 'subod.subsubod.second', 'subod.subsubod.third', 'subod.subsubodval1.firstval1', 'subod.subsubodval1.secondval1', 'subod.subsubodval1.thirdval1', 'subod.subsubodval2.firstval2', 'subod.subsubodval2.secondval2', 'subod.subsubodval2.thirdval2']:
|
||||
return
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
isfollower = cfg.unrestraint.option(pathread).isfollower()
|
||||
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
if confwrite is not None:
|
||||
|
@ -1131,32 +1131,32 @@ def autocheck_option(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwar
|
|||
return
|
||||
expected_name = pathread.split('.')[-1]
|
||||
if not kwargs.get('permissive_od', False):
|
||||
current_name = cfg.option(pathread).option.name()
|
||||
assert current_name == cfg.forcepermissive.option(pathread).option.name()
|
||||
assert current_name == cfg.unrestraint.option(pathread).option.name()
|
||||
doc = cfg.option(pathread).option.doc()
|
||||
assert doc == cfg.forcepermissive.option(pathread).option.doc()
|
||||
assert doc == cfg.unrestraint.option(pathread).option.doc()
|
||||
current_name = cfg.option(pathread).name()
|
||||
assert current_name == cfg.forcepermissive.option(pathread).name()
|
||||
assert current_name == cfg.unrestraint.option(pathread).name()
|
||||
doc = cfg.option(pathread).doc()
|
||||
assert doc == cfg.forcepermissive.option(pathread).doc()
|
||||
assert doc == cfg.unrestraint.option(pathread).doc()
|
||||
elif not kwargs.get('propertyerror', False):
|
||||
with raises(PropertiesOptionError):
|
||||
cfg.option(pathread).option.name()
|
||||
current_name = cfg.forcepermissive.option(pathread).option.name()
|
||||
assert current_name == cfg.unrestraint.option(pathread).option.name()
|
||||
cfg.option(pathread).name()
|
||||
current_name = cfg.forcepermissive.option(pathread).name()
|
||||
assert current_name == cfg.unrestraint.option(pathread).name()
|
||||
with raises(PropertiesOptionError):
|
||||
cfg.option(pathread).option.doc()
|
||||
doc = cfg.forcepermissive.option(pathread).option.doc()
|
||||
assert doc == cfg.unrestraint.option(pathread).option.doc()
|
||||
cfg.option(pathread).doc()
|
||||
doc = cfg.forcepermissive.option(pathread).doc()
|
||||
assert doc == cfg.unrestraint.option(pathread).doc()
|
||||
else:
|
||||
with raises(PropertiesOptionError):
|
||||
cfg.option(pathread).option.name()
|
||||
cfg.option(pathread).name()
|
||||
with raises(PropertiesOptionError):
|
||||
cfg.forcepermissive.option(pathread).option.name()
|
||||
current_name = cfg.unrestraint.option(pathread).option.name()
|
||||
cfg.forcepermissive.option(pathread).name()
|
||||
current_name = cfg.unrestraint.option(pathread).name()
|
||||
with raises(PropertiesOptionError):
|
||||
cfg.option(pathread).option.doc()
|
||||
cfg.option(pathread).doc()
|
||||
with raises(PropertiesOptionError):
|
||||
cfg.forcepermissive.option(pathread).option.doc()
|
||||
doc = cfg.unrestraint.option(pathread).option.doc()
|
||||
cfg.forcepermissive.option(pathread).doc()
|
||||
doc = cfg.unrestraint.option(pathread).doc()
|
||||
assert current_name == expected_name
|
||||
if expected_name.endswith('val1') or expected_name.endswith('val2'):
|
||||
expected_name = expected_name[:-4]
|
||||
|
@ -1180,7 +1180,7 @@ def autocheck_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **
|
|||
else:
|
||||
cfg2_ = cfg.unrestraint
|
||||
|
||||
if not cfg_.option(pathread).option.isfollower():
|
||||
if not cfg_.option(pathread).isfollower():
|
||||
assert cfg_.option(pathread).permissive.get() == frozenset()
|
||||
else:
|
||||
assert cfg_.option(pathread, 0).permissive.get() == frozenset()
|
||||
|
@ -1204,7 +1204,7 @@ def autocheck_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **
|
|||
cfg_.option(call_path).permissive.set(frozenset(['disabled']))
|
||||
|
||||
# have permissive?
|
||||
if not cfg_.option(pathread).option.isfollower():
|
||||
if not cfg_.option(pathread).isfollower():
|
||||
assert cfg_.option(pathread).permissive.get() == frozenset(['disabled'])
|
||||
else:
|
||||
assert cfg_.option(pathread, 0).permissive.get() == frozenset(['disabled'])
|
||||
|
@ -1261,13 +1261,13 @@ def autocheck_option_get(cfg, mcfg, pathread, pathwrite, confread, confwrite, **
|
|||
name = pathread.rsplit('.', 1)[1]
|
||||
else:
|
||||
name = pathread
|
||||
assert cfg.unrestraint.option(pathread).option.name() == name
|
||||
assert cfg.unrestraint.option(pathread).name() == name
|
||||
|
||||
|
||||
@autocheck
|
||||
def autocheck_find(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
def _getoption(opt):
|
||||
opt = opt.option.get()
|
||||
opt = opt.get()
|
||||
if opt.impl_is_dynsymlinkoption():
|
||||
opt = opt.opt
|
||||
return opt
|
||||
|
@ -1493,7 +1493,7 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
|||
else:
|
||||
ckwargs['owner'] = OWNER
|
||||
|
||||
if mcfg.unrestraint.option(path).option.isfollower():
|
||||
if mcfg.unrestraint.option(path).isfollower():
|
||||
dirname = path.rsplit('.', 1)[0]
|
||||
leader_path = dirname + '.first'
|
||||
leader_path_2 = None
|
||||
|
|
|
@ -258,8 +258,8 @@ def test_get_modified_values():
|
|||
od1 = OptionDescription('root', '', [d1])
|
||||
cfg = Config(od1)
|
||||
compare(cfg.value.exportation(), {})
|
||||
assert not cfg.option('od.g5').option.ismulti()
|
||||
assert not cfg.option('od.g5').option.issubmulti()
|
||||
assert not cfg.option('od.g5').ismulti()
|
||||
assert not cfg.option('od.g5').issubmulti()
|
||||
cfg.option('od.g5').value.set('yes')
|
||||
compare(cfg.value.exportation(), {'od.g5': {None: ['yes', 'user']}})
|
||||
cfg.option('od.g4').value.set(False)
|
||||
|
@ -268,7 +268,7 @@ def test_get_modified_values():
|
|||
compare(cfg.value.exportation(), {'od.g5': {None: ['yes', 'user']}, 'od.g4': {None: [True, 'user']}})
|
||||
cfg.option('od.g4').value.reset()
|
||||
compare(cfg.value.exportation(), {'od.g5': {None: ['yes', 'user']}})
|
||||
assert cfg.option('od.g6').option.ismulti()
|
||||
assert cfg.option('od.g6').ismulti()
|
||||
cfg.option('od.g6').value.set([undefined])
|
||||
compare(cfg.value.exportation(), {'od.g5': {None: ['yes', 'user']}, 'od.g6': {None: [[None], 'user']}})
|
||||
cfg.option('od.g6').value.set([])
|
||||
|
@ -410,10 +410,10 @@ def test_config_od_name(config_type):
|
|||
o2 = OptionDescription('val', '', [o])
|
||||
cfg = Config(o2)
|
||||
cfg = get_config(cfg, config_type)
|
||||
assert cfg.option('val.i').option.name() == 'i'
|
||||
assert cfg.option('val.s').option.name() == 's'
|
||||
assert cfg.option('val.s').option.type() == _('integer')
|
||||
assert cfg.option('val').option.type() == 'optiondescription'
|
||||
assert cfg.option('val.i').name() == 'i'
|
||||
assert cfg.option('val.s').name() == 's'
|
||||
assert cfg.option('val.s').type() == _('integer')
|
||||
assert cfg.option('val').type() == 'optiondescription'
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
@ -423,8 +423,8 @@ def test_config_od_type(config_type):
|
|||
o2 = OptionDescription('val', '', [o])
|
||||
cfg = Config(o2)
|
||||
cfg = get_config(cfg, config_type)
|
||||
assert cfg.option('val').option.type() == 'optiondescription'
|
||||
assert cfg.option('val.i').option.type() == _('integer')
|
||||
assert cfg.option('val').type() == 'optiondescription'
|
||||
assert cfg.option('val.i').type() == _('integer')
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
|
|
@ -179,95 +179,95 @@ def test_find_in_config():
|
|||
cfg.permissive.add('hidden')
|
||||
ret = list(cfg.option.find('dummy'))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), cfg.option('gc.dummy').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.option('gc.dummy').get())
|
||||
#
|
||||
ret_find = cfg.option.find('dummy', first=True)
|
||||
ret = ret_find.option.get()
|
||||
_is_same_opt(ret, cfg.option('gc.dummy').option.get())
|
||||
ret = ret_find.get()
|
||||
_is_same_opt(ret, cfg.option('gc.dummy').get())
|
||||
#
|
||||
ret = list(cfg.option.find('float'))
|
||||
assert len(ret) == 2
|
||||
_is_same_opt(ret[0].option.get(), cfg.option('gc.float').option.get())
|
||||
_is_same_opt(ret[1].option.get(), cfg.option('float').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.option('gc.float').get())
|
||||
_is_same_opt(ret[1].get(), cfg.option('float').get())
|
||||
#
|
||||
ret = cfg.option.find('bool', first=True)
|
||||
_is_same_opt(ret.option.get(), cfg.option('gc.gc2.bool').option.get())
|
||||
_is_same_opt(ret.get(), cfg.option('gc.gc2.bool').get())
|
||||
ret = cfg.option.find('bool', value=True, first=True)
|
||||
_is_same_opt(ret.option.get(), cfg.option('bool').option.get())
|
||||
_is_same_opt(ret.get(), cfg.option('bool').get())
|
||||
ret = cfg.option.find('dummy', first=True)
|
||||
_is_same_opt(ret.option.get(), cfg.option('gc.dummy').option.get())
|
||||
_is_same_opt(ret.get(), cfg.option('gc.dummy').get())
|
||||
ret = cfg.option.find('float', first=True)
|
||||
_is_same_opt(ret.option.get(), cfg.option('gc.float').option.get())
|
||||
_is_same_opt(ret.get(), cfg.option('gc.float').get())
|
||||
ret = list(cfg.option.find('prop'))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), cfg.option('gc.prop').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.option('gc.prop').get())
|
||||
#
|
||||
ret = list(cfg.option.find('prop', value=None))
|
||||
assert len(ret) == 1
|
||||
ret = list(cfg.option.find('prop'))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), cfg.option('gc.prop').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.option('gc.prop').get())
|
||||
#
|
||||
cfg.property.read_write()
|
||||
with raises(AttributeError):
|
||||
ret = cfg.option.find('prop')
|
||||
assert ret.option.get()
|
||||
assert ret.get()
|
||||
ret = list(cfg.unrestraint.option.find(name='prop'))
|
||||
assert len(ret) == 2
|
||||
_is_same_opt(ret[0].option.get(), cfg.unrestraint.option('gc.gc2.prop').option.get())
|
||||
_is_same_opt(ret[1].option.get(), cfg.forcepermissive.option('gc.prop').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.unrestraint.option('gc.gc2.prop').get())
|
||||
_is_same_opt(ret[1].get(), cfg.forcepermissive.option('gc.prop').get())
|
||||
#
|
||||
ret = list(cfg.forcepermissive.option.find('prop'))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), cfg.forcepermissive.option('gc.prop').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.forcepermissive.option('gc.prop').get())
|
||||
#
|
||||
ret = cfg.forcepermissive.option.find('prop', first=True)
|
||||
_is_same_opt(ret.option.get(), cfg.forcepermissive.option('gc.prop').option.get())
|
||||
_is_same_opt(ret.get(), cfg.forcepermissive.option('gc.prop').get())
|
||||
# combinaison of filters
|
||||
ret = list(cfg.unrestraint.option.find('prop', type=BoolOption))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), cfg.unrestraint.option('gc.gc2.prop').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.unrestraint.option('gc.gc2.prop').get())
|
||||
ret = cfg.unrestraint.option.find('prop', type=BoolOption, first=True)
|
||||
_is_same_opt(ret.option.get(), cfg.unrestraint.option('gc.gc2.prop').option.get())
|
||||
_is_same_opt(ret.get(), cfg.unrestraint.option('gc.gc2.prop').get())
|
||||
#
|
||||
ret = list(cfg.option.find('dummy', value=False))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), cfg.option('gc.dummy').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.option('gc.dummy').get())
|
||||
#
|
||||
ret = cfg.option.find('dummy', value=False, first=True)
|
||||
_is_same_opt(ret.option.get(), cfg.option('gc.dummy').option.get())
|
||||
_is_same_opt(ret.get(), cfg.option('gc.dummy').get())
|
||||
#subcfgig
|
||||
ret = list(cfg.option('gc').find('dummy'))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), cfg.option('gc.dummy').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.option('gc.dummy').get())
|
||||
#
|
||||
ret = list(cfg.option('gc').find('float'))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), cfg.option('gc.float').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.option('gc.float').get())
|
||||
#
|
||||
ret = list(cfg.option('gc.gc2').find('bool'))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), cfg.option('gc.gc2.bool').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.option('gc.gc2.bool').get())
|
||||
ret = cfg.option('gc').find('bool', value=False, first=True)
|
||||
_is_same_opt(ret.option.get(), cfg.option('gc.gc2.bool').option.get())
|
||||
_is_same_opt(ret.get(), cfg.option('gc.gc2.bool').get())
|
||||
#
|
||||
with raises(AttributeError):
|
||||
ret = cfg.option('gc').find('bool', value=True, first=True)
|
||||
assert ret.option.get()
|
||||
assert ret.get()
|
||||
#
|
||||
with raises(AttributeError):
|
||||
ret = cfg.option('gc').find('wantref')
|
||||
ret.option.get()
|
||||
ret.get()
|
||||
#
|
||||
ret = list(cfg.unrestraint.option('gc').find('prop'))
|
||||
assert len(ret) == 2
|
||||
_is_same_opt(ret[0].option.get(), cfg.unrestraint.option('gc.gc2.prop').option.get())
|
||||
_is_same_opt(ret[1].option.get(), cfg.forcepermissive.option('gc.prop').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.unrestraint.option('gc.gc2.prop').get())
|
||||
_is_same_opt(ret[1].get(), cfg.forcepermissive.option('gc.prop').get())
|
||||
#
|
||||
cfg.property.read_only()
|
||||
ret = list(cfg.option('gc').find('prop'))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), cfg.option('gc.prop').option.get())
|
||||
_is_same_opt(ret[0].get(), cfg.option('gc.prop').get())
|
||||
# not OptionDescription
|
||||
with raises(AttributeError):
|
||||
cfg.option.find('gc', first=True)
|
||||
|
@ -298,9 +298,9 @@ def test_find_multi():
|
|||
cfg.option('bool').value.set([False, False, True])
|
||||
ret = list(cfg.option.find('bool', value=True))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), b)
|
||||
_is_same_opt(ret[0].get(), b)
|
||||
ret = cfg.option.find('bool', value=True, first=True)
|
||||
_is_same_opt(ret.option.get(), b)
|
||||
_is_same_opt(ret.get(), b)
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
|
|
@ -68,8 +68,8 @@ def test_build_dyndescription():
|
|||
od1 = OptionDescription('od', '', [dod])
|
||||
cfg = Config(od1)
|
||||
assert cfg.value.dict() == {'dodval1.stval1': None, 'dodval2.stval2': None}
|
||||
assert cfg.option('dodval1').option.isdynamic()
|
||||
assert cfg.option('dodval1.stval1').option.isdynamic()
|
||||
assert cfg.option('dodval1').isdynamic()
|
||||
assert cfg.option('dodval1.stval1').isdynamic()
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
@ -155,14 +155,14 @@ def test_getdoc_dyndescription():
|
|||
od1 = OptionDescription('od', '', [dod])
|
||||
od2 = OptionDescription('od', '', [od1])
|
||||
cfg = Config(od2)
|
||||
assert cfg.option('od.dodval1.stval1').option.name() == 'stval1'
|
||||
assert cfg.option('od.dodval2.stval2').option.name() == 'stval2'
|
||||
assert cfg.option('od.dodval1').option.name() == 'dodval1'
|
||||
assert cfg.option('od.dodval2').option.name() == 'dodval2'
|
||||
assert cfg.option('od.dodval1.stval1').option.doc() == 'doc1val1'
|
||||
assert cfg.option('od.dodval2.stval2').option.doc() == 'doc1val2'
|
||||
assert cfg.option('od.dodval1').option.doc() == 'doc2val1'
|
||||
assert cfg.option('od.dodval2').option.doc() == 'doc2val2'
|
||||
assert cfg.option('od.dodval1.stval1').name() == 'stval1'
|
||||
assert cfg.option('od.dodval2.stval2').name() == 'stval2'
|
||||
assert cfg.option('od.dodval1').name() == 'dodval1'
|
||||
assert cfg.option('od.dodval2').name() == 'dodval2'
|
||||
assert cfg.option('od.dodval1.stval1').doc() == 'doc1val1'
|
||||
assert cfg.option('od.dodval2.stval2').doc() == 'doc1val2'
|
||||
assert cfg.option('od.dodval1').doc() == 'doc2val1'
|
||||
assert cfg.option('od.dodval2').doc() == 'doc2val2'
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
@ -964,7 +964,7 @@ def test_find_dyndescription_context():
|
|||
ret = cfg.option.find('stval1', first=True)
|
||||
assert ret.value.get() == "yes"
|
||||
ret = cfg.option.find('stval1', first=True)
|
||||
assert isinstance(ret.option.get(), SynDynOption)
|
||||
assert isinstance(ret.get(), SynDynOption)
|
||||
#assert cfg.option.find(bytype=StrOption, type='path') == ['od.dodval1.stval1', 'od.dodval2.stval2', 'od.val1']
|
||||
#opts = cfg.option.find(byvalue='yes')
|
||||
#assert len(opts) == 1
|
||||
|
@ -1859,8 +1859,8 @@ def test_dyn_symlink():
|
|||
od1 = OptionDescription(name="accounts", doc="accounts.remote_.remote_ip_", children=[remotes, dyn_remote, name])
|
||||
cfg = Config(od1)
|
||||
assert cfg.option('name').value.get() == ['a', 'b', 'c']
|
||||
assert cfg.option('name').option.ismulti() == True
|
||||
assert cfg.option('name').option.issubmulti() == False
|
||||
assert cfg.option('name').ismulti() == True
|
||||
assert cfg.option('name').issubmulti() == False
|
||||
assert cfg.value.dict() == {'remotes': ['a', 'b', 'c'], 'remote_a.remote_ip_a': 'a', 'remote_b.remote_ip_b': 'b', 'remote_c.remote_ip_c': 'c', 'name': ['a', 'b', 'c']}
|
||||
# assert not list_sessions()
|
||||
|
||||
|
@ -1873,7 +1873,7 @@ def test_dyn_callback_with_not_dyn():
|
|||
od1 = OptionDescription(name="accounts", doc="accounts.remote_.remote_ip_", children=[remotes, dyn_remote, names])
|
||||
cfg = Config(od1)
|
||||
assert cfg.option('names').value.get() == ['a', 'b', 'c']
|
||||
assert cfg.option('names').option.ismulti() == True
|
||||
assert cfg.option('names').option.issubmulti() == False
|
||||
assert cfg.option('names').ismulti() == True
|
||||
assert cfg.option('names').issubmulti() == False
|
||||
assert cfg.value.dict() == {'remotes': ['a', 'b', 'c'], 'remote_a.remote_ip_a': 'a', 'remote_b.remote_ip_b': 'b', 'remote_c.remote_ip_c': 'c', 'names': ['a', 'b', 'c']}
|
||||
# assert not list_sessions()
|
||||
|
|
|
@ -86,7 +86,7 @@ def test_iter_on_groups():
|
|||
result = cfg.option('creole').list('optiondescription',
|
||||
group_type=groups.family,
|
||||
)
|
||||
group_names = [res.option.name() for res in result]
|
||||
group_names = [res.name() for res in result]
|
||||
assert group_names == ['general', 'interface1']
|
||||
for i in cfg.option('creole').list('optiondescription',
|
||||
group_type=groups.family,
|
||||
|
@ -108,17 +108,17 @@ def test_list_recursive():
|
|||
cfg = Config(od1)
|
||||
cfg.property.read_write()
|
||||
result = cfg.option('creole').list('all')
|
||||
group_names = [res.option.name() for res in result]
|
||||
group_names = [res.name() for res in result]
|
||||
assert group_names == ['general', 'interface1']
|
||||
#
|
||||
result = cfg.option.list(recursive=True)
|
||||
group_names = [res.option.name() for res in result]
|
||||
group_names = [res.name() for res in result]
|
||||
assert group_names == ['numero_etab', 'nom_machine', 'nombre_interfaces',
|
||||
'activer_proxy_client', 'mode_conteneur_actif',
|
||||
'serveur_ntp', 'time_zone', 'ip_admin_eth0',
|
||||
'netmask_admin_eth0']
|
||||
result = list(cfg.option.list(recursive=True, type='optiondescription'))
|
||||
group_names = [res.option.name() for res in result]
|
||||
group_names = [res.name() for res in result]
|
||||
assert group_names == ['creole', 'general', 'interface1', 'ip_admin_eth0']
|
||||
# assert not list_sessions()
|
||||
|
||||
|
@ -129,14 +129,14 @@ def test_iter_on_groups_force_permissive():
|
|||
cfg.property.read_write()
|
||||
cfg.permissive.add('hidden')
|
||||
result = cfg.forcepermissive.option('creole.general').list()
|
||||
group_names = [res.option.name() for res in result]
|
||||
group_names = [res.name() for res in result]
|
||||
ass = ['numero_etab', 'nom_machine', 'nombre_interfaces',
|
||||
'activer_proxy_client', 'mode_conteneur_actif',
|
||||
'mode_conteneur_actif2', 'serveur_ntp', 'time_zone']
|
||||
assert group_names == ass
|
||||
# mode_conteneur_actif2 is not visible is not forcepermissive
|
||||
result = cfg.option('creole.general').list()
|
||||
group_names = [res.option.name() for res in result]
|
||||
group_names = [res.name() for res in result]
|
||||
ass.remove('mode_conteneur_actif2')
|
||||
assert group_names == ass
|
||||
# assert not list_sessions()
|
||||
|
@ -149,7 +149,7 @@ def test_iter_group_on_groups_force_permissive():
|
|||
cfg.permissive.add('hidden')
|
||||
result = cfg.forcepermissive.option('creole').list(type='optiondescription',
|
||||
group_type=groups.family)
|
||||
group_names = [res.option.name() for res in result]
|
||||
group_names = [res.name() for res in result]
|
||||
assert group_names == ['general', 'interface1', 'new']
|
||||
# assert not list_sessions()
|
||||
|
||||
|
@ -161,7 +161,7 @@ def test_iter_on_groups_props():
|
|||
cfg.option('creole.interface1').property.add('disabled')
|
||||
result = cfg.option('creole').list(type='optiondescription',
|
||||
group_type=groups.family)
|
||||
group_names = [res.option.name() for res in result]
|
||||
group_names = [res.name() for res in result]
|
||||
assert group_names == ['general']
|
||||
# assert not list_sessions()
|
||||
|
||||
|
@ -201,20 +201,20 @@ def test_groups_is_leader(config_type):
|
|||
od1 = OptionDescription('od', '', [interface1, od2])
|
||||
cfg = Config(od1)
|
||||
cfg = get_config(cfg, config_type)
|
||||
assert not cfg.option('od2').option.isleadership()
|
||||
assert cfg.option('leadership').option.isleadership()
|
||||
assert not cfg.option('od2.var').option.isleader()
|
||||
assert not cfg.option('od2.var').option.isfollower()
|
||||
assert cfg.option('leadership.ip_admin_eth0').option.ismulti()
|
||||
assert cfg.option('leadership.netmask_admin_eth0').option.ismulti()
|
||||
assert not cfg.option('leadership.ip_admin_eth0').option.issubmulti()
|
||||
assert not cfg.option('leadership.netmask_admin_eth0').option.issubmulti()
|
||||
assert cfg.option('leadership.ip_admin_eth0').option.isleader()
|
||||
assert not cfg.option('leadership.ip_admin_eth0').option.isfollower()
|
||||
assert not cfg.option('leadership.netmask_admin_eth0').option.isleader()
|
||||
assert cfg.option('leadership.netmask_admin_eth0').option.isfollower()
|
||||
assert cfg.option('leadership.netmask_admin_eth0').option.path() == 'leadership.netmask_admin_eth0'
|
||||
assert cfg.option('leadership.netmask_admin_eth0').option.defaultmulti() == 'value'
|
||||
assert not cfg.option('od2').isleadership()
|
||||
assert cfg.option('leadership').isleadership()
|
||||
assert not cfg.option('od2.var').isleader()
|
||||
assert not cfg.option('od2.var').isfollower()
|
||||
assert cfg.option('leadership.ip_admin_eth0').ismulti()
|
||||
assert cfg.option('leadership.netmask_admin_eth0').ismulti()
|
||||
assert not cfg.option('leadership.ip_admin_eth0').issubmulti()
|
||||
assert not cfg.option('leadership.netmask_admin_eth0').issubmulti()
|
||||
assert cfg.option('leadership.ip_admin_eth0').isleader()
|
||||
assert not cfg.option('leadership.ip_admin_eth0').isfollower()
|
||||
assert not cfg.option('leadership.netmask_admin_eth0').isleader()
|
||||
assert cfg.option('leadership.netmask_admin_eth0').isfollower()
|
||||
assert cfg.option('leadership.netmask_admin_eth0').path() == 'leadership.netmask_admin_eth0'
|
||||
assert cfg.option('leadership.netmask_admin_eth0').defaultmulti() == 'value'
|
||||
if config_type == 'tiramisu-api':
|
||||
cfg.send()
|
||||
# assert not list_sessions()
|
||||
|
@ -229,18 +229,18 @@ def test_leader_list(config_type):
|
|||
cfg = get_config(cfg, config_type)
|
||||
ret = cfg.option.list('all')
|
||||
assert len(ret) == 1
|
||||
assert ret[0].option.name() == 'leadership'
|
||||
assert ret[0].name() == 'leadership'
|
||||
#
|
||||
ret = cfg.option('leadership').list('all')
|
||||
assert len(ret) == 1
|
||||
assert ret[0].option.name() == 'ip_admin_eth0'
|
||||
assert ret[0].name() == 'ip_admin_eth0'
|
||||
#
|
||||
cfg.option('leadership.ip_admin_eth0').value.set(['a', 'b'])
|
||||
cfg.option('leadership.netmask_admin_eth0', 0).value.set('c')
|
||||
cfg.option('leadership.netmask_admin_eth0', 1).value.set('d')
|
||||
ret = cfg.option('leadership').list('all')
|
||||
assert ret[0].option.name() == 'ip_admin_eth0'
|
||||
assert ret[1].option.name() == 'netmask_admin_eth0'
|
||||
assert ret[0].name() == 'ip_admin_eth0'
|
||||
assert ret[1].name() == 'netmask_admin_eth0'
|
||||
# assert ret[1].option.index() == 0
|
||||
# assert ret[2].option.name() == 'netmask_admin_eth0'
|
||||
# assert ret[2].option.index() == 1
|
||||
|
@ -259,7 +259,7 @@ def test_groups_is_multi_with_index(config_type):
|
|||
od1 = OptionDescription('od', '', [interface1, od2])
|
||||
cfg = Config(od1)
|
||||
cfg = get_config(cfg, config_type)
|
||||
assert cfg.option('leadership.netmask_admin_eth0', 0).option.ismulti()
|
||||
assert cfg.option('leadership.netmask_admin_eth0', 0).ismulti()
|
||||
|
||||
|
||||
def test_groups_is_information_with_index(config_type):
|
||||
|
@ -964,16 +964,16 @@ def test_wrong_index():
|
|||
od1 = OptionDescription('toto', '', [od2])
|
||||
cfg = Config(od1)
|
||||
cfg.property.read_write()
|
||||
assert cfg.option('od.ip_admin_eth0.ip_admin_eth0').option.get()
|
||||
assert cfg.option('od.ip_admin_eth0.ip_admin_eth0').get()
|
||||
with pytest.raises(ConfigError):
|
||||
cfg.option('od.ip_admin_eth0.ip_admin_eth0', 0).option.get()
|
||||
assert cfg.option('od.ip_admin_eth0.netmask_admin_eth0').option.get()
|
||||
assert cfg.option('od.ip_admin_eth0').option.get()
|
||||
cfg.option('od.ip_admin_eth0.ip_admin_eth0', 0).get()
|
||||
assert cfg.option('od.ip_admin_eth0.netmask_admin_eth0').get()
|
||||
assert cfg.option('od.ip_admin_eth0').get()
|
||||
with pytest.raises(ConfigError):
|
||||
cfg.option('od.ip_admin_eth0', 0).option.get()
|
||||
assert cfg.option('od').option.get()
|
||||
cfg.option('od.ip_admin_eth0', 0).get()
|
||||
assert cfg.option('od').get()
|
||||
with pytest.raises(ConfigError):
|
||||
cfg.option('od', 0).option.get()
|
||||
cfg.option('od', 0).get()
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
@ -1090,8 +1090,8 @@ def test_api_get_leader(config_type):
|
|||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od1 = OptionDescription('conf', '', [interface1])
|
||||
cfg = Config(od1)
|
||||
option = cfg.option('ip_admin_eth0.netmask_admin_eth0').option.leader()
|
||||
assert option.option.get() == ip_admin_eth0
|
||||
option = cfg.option('ip_admin_eth0.netmask_admin_eth0').leader()
|
||||
assert option.get() == ip_admin_eth0
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
|
|
@ -324,11 +324,11 @@ def compare(ret, expected):
|
|||
for index, opt in enumerate(ret):
|
||||
exp = expected[index]
|
||||
if isinstance(exp, list):
|
||||
assert opt.option.path() == exp[0]
|
||||
assert opt.option.index() == exp[1]
|
||||
assert opt.path() == exp[0]
|
||||
assert opt.index() == exp[1]
|
||||
else:
|
||||
assert opt.option.path() == exp
|
||||
assert opt.option.index() == None
|
||||
assert opt.path() == exp
|
||||
assert opt.index() == None
|
||||
|
||||
|
||||
def test_mandatory_warnings_ro():
|
||||
|
|
|
@ -86,8 +86,8 @@ def test_option_description():
|
|||
od = OptionDescription('od', 'od', [i])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
assert cfg.option('od').option.description() == 'od'
|
||||
assert cfg.option('od.test').option.description() == description
|
||||
assert cfg.option('od').description() == 'od'
|
||||
assert cfg.option('od.test').description() == description
|
||||
|
||||
|
||||
def test_option_get_information_default():
|
||||
|
@ -142,8 +142,8 @@ def test_option_isoptiondescription():
|
|||
od = OptionDescription('od', '', [i])
|
||||
od = OptionDescription('od', '', [od])
|
||||
cfg = Config(od)
|
||||
assert cfg.option('od').option.isoptiondescription()
|
||||
assert not cfg.option('od.test').option.isoptiondescription()
|
||||
assert cfg.option('od').isoptiondescription()
|
||||
assert not cfg.option('od.test').isoptiondescription()
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
@ -350,5 +350,5 @@ def test_option_display_name():
|
|||
cfg = Config(od,
|
||||
display_name=display_name,
|
||||
)
|
||||
assert cfg.option('test1').option.name() == 'test1'
|
||||
assert cfg.option('test1').option.doc() == 'display_name'
|
||||
assert cfg.option('test1').name() == 'test1'
|
||||
assert cfg.option('test1').doc() == 'display_name'
|
||||
|
|
|
@ -293,7 +293,7 @@ def test_callback(config_type):
|
|||
cfg.option('val1').value.set('new-val')
|
||||
assert cfg.option('val1').value.get() == 'new-val'
|
||||
with pytest.raises(ConfigError):
|
||||
assert cfg.option('val1').option.defaultmulti() == None
|
||||
assert cfg.option('val1').defaultmulti() == None
|
||||
cfg.option('val1').value.reset()
|
||||
assert cfg.option('val1').value.get() == 'val'
|
||||
# assert not list_sessions()
|
||||
|
@ -519,7 +519,7 @@ def test_callback_multi(config_type):
|
|||
cfg = get_config(cfg, config_type)
|
||||
assert cfg.option('val1').value.get() == ['val']
|
||||
cfg.option('val1').value.set(['new-val'])
|
||||
assert cfg.option('val1').option.defaultmulti() == None
|
||||
assert cfg.option('val1').defaultmulti() == None
|
||||
assert cfg.option('val1').value.get() == ['new-val']
|
||||
cfg.option('val1').value.set(['new-val', 'new-val2'])
|
||||
assert cfg.option('val1').value.get() == ['new-val', 'new-val2']
|
||||
|
@ -1559,15 +1559,15 @@ def test_calc_dependencies(config_type):
|
|||
od1 = OptionDescription('root', '', [val1, val2, val3])
|
||||
cfg = Config(od1)
|
||||
cfg = get_config(cfg, config_type)
|
||||
dep = cfg.option('val1').option.dependencies()
|
||||
dep = cfg.option('val1').dependencies()
|
||||
assert len(dep) == 1
|
||||
assert dep[0].option.get() == val3
|
||||
assert dep[0].get() == val3
|
||||
#
|
||||
dep = cfg.option('val2').option.dependencies()
|
||||
dep = cfg.option('val2').dependencies()
|
||||
assert len(dep) == 1
|
||||
assert dep[0].option.get() == val3
|
||||
assert dep[0].get() == val3
|
||||
#
|
||||
assert cfg.option('val3').option.dependencies() == []
|
||||
assert cfg.option('val3').dependencies() == []
|
||||
|
||||
|
||||
def test_callback__kwargs_wrong(config_type):
|
||||
|
|
|
@ -361,8 +361,8 @@ def test_apply_requires_from_config():
|
|||
with pytest.raises(PropertiesOptionError):
|
||||
cfg.option('opt.str').value.get()
|
||||
assert 'hidden' in cfg.forcepermissive.option('opt.str').property.get()
|
||||
assert 'hidden' not in cfg.forcepermissive.option('opt.str').option.properties()
|
||||
assert 'hidden' not in cfg.forcepermissive.option('opt.str').option.properties(only_raises=True)
|
||||
assert 'hidden' not in cfg.forcepermissive.option('opt.str').properties()
|
||||
assert 'hidden' not in cfg.forcepermissive.option('opt.str').properties(only_raises=True)
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
@ -382,8 +382,8 @@ def test_apply_requires_with_disabled():
|
|||
cfg.option('int').value.set(1)
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
cfg.option('opt.str').value.get()
|
||||
assert 'disabled' not in cfg.unrestraint.option('opt.str').option.properties()
|
||||
assert 'disabled' not in cfg.unrestraint.option('opt.str').option.properties(only_raises=True)
|
||||
assert 'disabled' not in cfg.unrestraint.option('opt.str').properties()
|
||||
assert 'disabled' not in cfg.unrestraint.option('opt.str').properties(only_raises=True)
|
||||
assert 'disabled' in cfg.unrestraint.option('opt.str').property.get()
|
||||
# assert not list_sessions()
|
||||
|
||||
|
@ -499,10 +499,10 @@ def test_accepts_multiple_changes_from_option():
|
|||
od1 = OptionDescription("options", "", [s])
|
||||
cfg = Config(od1)
|
||||
cfg.option('string').value.set("egg")
|
||||
assert cfg.option('string').option.default() == "string"
|
||||
assert cfg.option('string').default() == "string"
|
||||
assert cfg.option('string').value.get() == "egg"
|
||||
cfg.option('string').value.set('blah')
|
||||
assert cfg.option('string').option.default() == "string"
|
||||
assert cfg.option('string').default() == "string"
|
||||
assert cfg.option('string').value.get() == "blah"
|
||||
cfg.option('string').value.set('bol')
|
||||
assert cfg.option('string').value.get() == 'bol'
|
||||
|
|
|
@ -499,13 +499,13 @@ def test_validator_dependencies():
|
|||
opt2 = StrOption('opt2', '', validators=[Calculation(return_false, Params(ParamSelfOption(whole=False)))])
|
||||
od1 = OptionDescription('root', '', [ip_admin_eth0, netmask_admin_eth0, opt2])
|
||||
cfg = Config(od1)
|
||||
assert cfg.option('ip_admin_eth0').option.has_dependency() is False
|
||||
assert cfg.option('netmask_admin_eth0').option.has_dependency() is True
|
||||
assert cfg.option('opt2').option.has_dependency() is False
|
||||
assert cfg.option('ip_admin_eth0').has_dependency() is False
|
||||
assert cfg.option('netmask_admin_eth0').has_dependency() is True
|
||||
assert cfg.option('opt2').has_dependency() is False
|
||||
#
|
||||
assert cfg.option('ip_admin_eth0').option.has_dependency(False) is True
|
||||
assert cfg.option('netmask_admin_eth0').option.has_dependency(False) is False
|
||||
assert cfg.option('opt2').option.has_dependency(False) is False
|
||||
assert cfg.option('ip_admin_eth0').has_dependency(False) is True
|
||||
assert cfg.option('netmask_admin_eth0').has_dependency(False) is False
|
||||
assert cfg.option('opt2').has_dependency(False) is False
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
@ -1010,10 +1010,10 @@ def test_validator_has_dependency():
|
|||
b = NetmaskOption('b', '', validators=[Calculation(valid_ip_netmask, Params((ParamOption(a), ParamSelfOption())))])
|
||||
od1 = OptionDescription('od', '', [a, b])
|
||||
cfg = Config(od1)
|
||||
assert cfg.option('a').option.has_dependency() is False
|
||||
assert cfg.option('b').option.has_dependency() is True
|
||||
assert cfg.option('a').option.has_dependency(False) is True
|
||||
assert cfg.option('b').option.has_dependency(False) is False
|
||||
assert cfg.option('a').has_dependency() is False
|
||||
assert cfg.option('b').has_dependency() is True
|
||||
assert cfg.option('a').has_dependency(False) is True
|
||||
assert cfg.option('b').has_dependency(False) is False
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
@ -1250,10 +1250,10 @@ def test_consistency_not_equal_has_dependency():
|
|||
b = IntOption('b', '', validators=[Calculation(valid_not_equal, Params((ParamSelfOption(), ParamOption(a))))])
|
||||
od1 = OptionDescription('od', '', [a, b])
|
||||
cfg = Config(od1)
|
||||
assert cfg.option('a').option.has_dependency() is False
|
||||
assert cfg.option('b').option.has_dependency() is True
|
||||
assert cfg.option('a').option.has_dependency(False) is True
|
||||
assert cfg.option('b').option.has_dependency(False) is False
|
||||
assert cfg.option('a').has_dependency() is False
|
||||
assert cfg.option('b').has_dependency() is True
|
||||
assert cfg.option('a').has_dependency(False) is True
|
||||
assert cfg.option('b').has_dependency(False) is False
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ def test_submulti():
|
|||
multi3 = StrOption('multi3', '', default=[['yes']], multi=submulti)
|
||||
od1 = OptionDescription('od', '', [multi, multi2, multi3])
|
||||
cfg = Config(od1)
|
||||
assert cfg.option('multi').option.ismulti()
|
||||
assert cfg.option('multi').option.issubmulti()
|
||||
assert cfg.option('multi').ismulti()
|
||||
assert cfg.option('multi').issubmulti()
|
||||
assert cfg.option('multi').owner.get() == owners.default
|
||||
assert cfg.option('multi').value.get() == []
|
||||
assert cfg.option('multi').owner.get() == owners.default
|
||||
|
|
|
@ -24,10 +24,10 @@ def test_symlink_option(config_type):
|
|||
)
|
||||
cfg = Config(od1)
|
||||
cfg = get_config(cfg, config_type)
|
||||
assert not cfg.option('s1.b').option.issymlinkoption()
|
||||
assert cfg.option('c').option.issymlinkoption()
|
||||
assert cfg.option('s1.b').option.type() == _('boolean')
|
||||
assert cfg.option('c').option.type() == _('boolean')
|
||||
assert not cfg.option('s1.b').issymlinkoption()
|
||||
assert cfg.option('c').issymlinkoption()
|
||||
assert cfg.option('s1.b').type() == _('boolean')
|
||||
assert cfg.option('c').type() == _('boolean')
|
||||
assert cfg.option('s1.b').value.get() is False
|
||||
cfg.option("s1.b").value.set(True)
|
||||
cfg.option("s1.b").value.set(False)
|
||||
|
@ -50,21 +50,21 @@ def test_symlink_default(config_type):
|
|||
)
|
||||
cfg = Config(od1)
|
||||
cfg = get_config(cfg, config_type)
|
||||
assert not cfg.option('s1.b').option.ismulti()
|
||||
assert not cfg.option('c').option.ismulti()
|
||||
assert not cfg.option('s1.b').option.issubmulti()
|
||||
assert not cfg.option('c').option.issubmulti()
|
||||
assert not cfg.option('s1.b').option.default()
|
||||
assert not cfg.option('c').option.default()
|
||||
assert not cfg.option('s1.b').ismulti()
|
||||
assert not cfg.option('c').ismulti()
|
||||
assert not cfg.option('s1.b').issubmulti()
|
||||
assert not cfg.option('c').issubmulti()
|
||||
assert not cfg.option('s1.b').default()
|
||||
assert not cfg.option('c').default()
|
||||
assert not cfg.option('s1.b').value.default()
|
||||
assert not cfg.option('c').value.default()
|
||||
with pytest.raises(ConfigError):
|
||||
assert not cfg.option('s1.b').option.defaultmulti()
|
||||
assert not cfg.option('s1.b').defaultmulti()
|
||||
with pytest.raises(ConfigError):
|
||||
assert not cfg.option('c').option.defaultmulti()
|
||||
assert not cfg.option('c').defaultmulti()
|
||||
cfg.option("s1.b").value.set(True)
|
||||
assert not cfg.option('s1.b').option.default()
|
||||
assert not cfg.option('c').option.default()
|
||||
assert not cfg.option('s1.b').default()
|
||||
assert not cfg.option('c').default()
|
||||
assert not cfg.option('s1.b').value.default()
|
||||
assert not cfg.option('c').value.default()
|
||||
## assert not list_sessions()
|
||||
|
@ -78,23 +78,23 @@ def test_symlink_default_multi(config_type):
|
|||
)
|
||||
cfg = Config(od1)
|
||||
cfg = get_config(cfg, config_type)
|
||||
assert cfg.option('s1.b').option.ismulti()
|
||||
assert cfg.option('c').option.ismulti()
|
||||
assert not cfg.option('s1.b').option.issubmulti()
|
||||
assert not cfg.option('c').option.issubmulti()
|
||||
assert cfg.option('s1.b').option.default() == [False]
|
||||
assert cfg.option('c').option.default() == [False]
|
||||
assert cfg.option('s1.b').ismulti()
|
||||
assert cfg.option('c').ismulti()
|
||||
assert not cfg.option('s1.b').issubmulti()
|
||||
assert not cfg.option('c').issubmulti()
|
||||
assert cfg.option('s1.b').default() == [False]
|
||||
assert cfg.option('c').default() == [False]
|
||||
assert cfg.option('s1.b').value.default() == [False]
|
||||
assert cfg.option('c').value.default() == [False]
|
||||
assert cfg.option('s1.b').option.defaultmulti()
|
||||
assert cfg.option('c').option.defaultmulti()
|
||||
assert cfg.option('s1.b').defaultmulti()
|
||||
assert cfg.option('c').defaultmulti()
|
||||
cfg.option("s1.b").value.set([True])
|
||||
assert cfg.option('s1.b').option.default() == [False]
|
||||
assert cfg.option('c').option.default() == [False]
|
||||
assert cfg.option('s1.b').default() == [False]
|
||||
assert cfg.option('c').default() == [False]
|
||||
assert cfg.option('s1.b').value.default() == [False]
|
||||
assert cfg.option('c').value.default() == [False]
|
||||
assert cfg.option('s1.b').option.defaultmulti()
|
||||
assert cfg.option('c').option.defaultmulti()
|
||||
assert cfg.option('s1.b').defaultmulti()
|
||||
assert cfg.option('c').defaultmulti()
|
||||
## assert not list_sessions()
|
||||
|
||||
|
||||
|
@ -317,7 +317,7 @@ def test_symlink_with_follower(config_type):
|
|||
od1 = OptionDescription('root', '', [interface1, follower])
|
||||
cfg = Config(od1)
|
||||
cfg = get_config(cfg, config_type)
|
||||
assert not cfg.option('follower').option.isoptiondescription()
|
||||
assert not cfg.option('follower').isoptiondescription()
|
||||
assert cfg.value.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'follower': []}
|
||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['val1', 'val2'])
|
||||
assert cfg.value.dict() == {'ip_admin_eth0.ip_admin_eth0': [{'ip_admin_eth0.ip_admin_eth0': 'val1', 'ip_admin_eth0.netmask_admin_eth0': None}, {'ip_admin_eth0.ip_admin_eth0': 'val2', 'ip_admin_eth0.netmask_admin_eth0': None}], 'follower': [None, None]}
|
||||
|
@ -358,10 +358,10 @@ def test_symlink_dependency():
|
|||
od1 = OptionDescription("opt", "",
|
||||
[linkopt, OptionDescription("s1", "", [boolopt])])
|
||||
cfg = Config(od1)
|
||||
assert cfg.option('s1.b').option.has_dependency() is False
|
||||
assert cfg.option('c').option.has_dependency() is True
|
||||
assert cfg.option('s1.b').option.has_dependency(False) is True
|
||||
assert cfg.option('c').option.has_dependency(False) is False
|
||||
assert cfg.option('s1.b').has_dependency() is False
|
||||
assert cfg.option('c').has_dependency() is True
|
||||
assert cfg.option('s1.b').has_dependency(False) is True
|
||||
assert cfg.option('c').has_dependency(False) is False
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
@ -387,12 +387,12 @@ def test_symlink_list(config_type):
|
|||
cfg = get_config(cfg, config_type)
|
||||
list_opt = []
|
||||
for opt in cfg.option.list():
|
||||
list_opt.append(opt.option.path())
|
||||
list_opt.append(opt.path())
|
||||
assert list_opt == ['c']
|
||||
#
|
||||
list_opt = []
|
||||
for opt in cfg.option.list(recursive=True):
|
||||
list_opt.append(opt.option.path())
|
||||
list_opt.append(opt.path())
|
||||
assert list_opt == ['c', 's1.b']
|
||||
# assert not list_sessions()
|
||||
|
||||
|
@ -402,7 +402,7 @@ def test_submulti():
|
|||
multi2 = SymLinkOption('multi2', multi)
|
||||
od1 = OptionDescription('od', '', [multi, multi2])
|
||||
cfg = Config(od1)
|
||||
assert cfg.option('multi').option.ismulti()
|
||||
assert cfg.option('multi').option.issubmulti()
|
||||
assert cfg.option('multi2').option.ismulti()
|
||||
assert cfg.option('multi2').option.issubmulti()
|
||||
assert cfg.option('multi').ismulti()
|
||||
assert cfg.option('multi').issubmulti()
|
||||
assert cfg.option('multi2').ismulti()
|
||||
assert cfg.option('multi2').issubmulti()
|
||||
|
|
|
@ -210,7 +210,7 @@ class _TiramisuOptionWalk:
|
|||
return options
|
||||
|
||||
|
||||
class _TiramisuOptionOptionDescription(CommonTiramisuOption):
|
||||
class _TiramisuOptionOptionDescription:
|
||||
"""Manage option"""
|
||||
_validate_properties = False
|
||||
|
||||
|
@ -299,18 +299,8 @@ class _TiramisuOptionOptionDescription(CommonTiramisuOption):
|
|||
uncalculated=uncalculated,
|
||||
)
|
||||
|
||||
def __call__(self,
|
||||
name: str,
|
||||
index: Optional[int]=None,
|
||||
) -> 'TiramisuOption':
|
||||
"""Select an option by path"""
|
||||
return TiramisuOption(self._path + '.' + name,
|
||||
index,
|
||||
self._config_bag,
|
||||
)
|
||||
|
||||
|
||||
class TiramisuOptionOption(_TiramisuOptionOptionDescription):
|
||||
class _TiramisuOptionOption(_TiramisuOptionOptionDescription):
|
||||
"""Manage option"""
|
||||
@option_type(['option', 'symlink', 'with_or_without_index'])
|
||||
def ismulti(self, options_bag: List[OptionBag]):
|
||||
|
@ -396,6 +386,18 @@ class TiramisuOptionOption(_TiramisuOptionOptionDescription):
|
|||
return options_bag[-1].index
|
||||
|
||||
|
||||
class TiramisuOptionOption(CommonTiramisuOption):
|
||||
def __call__(self,
|
||||
name: str,
|
||||
index: Optional[int]=None,
|
||||
) -> 'TiramisuOption':
|
||||
"""Select an option by path"""
|
||||
return TiramisuOption(self._path + '.' + name,
|
||||
index,
|
||||
self._config_bag,
|
||||
)
|
||||
|
||||
|
||||
class TiramisuOptionOwner(CommonTiramisuOption):
|
||||
#FIXME optiondescription must not have Owner!
|
||||
"""Manage option's owner"""
|
||||
|
@ -730,7 +732,7 @@ class TiramisuConfig(TiramisuHelp, _TiramisuOptionWalk):
|
|||
return self._config_bag.context.impl_getname()
|
||||
|
||||
|
||||
class TiramisuOption(CommonTiramisu, TiramisuConfig):
|
||||
class TiramisuOption(CommonTiramisu, _TiramisuOptionOption, TiramisuConfig):
|
||||
"""Manage selected option"""
|
||||
_validate_properties = False
|
||||
_registers = {}
|
||||
|
|
|
@ -88,7 +88,7 @@ class Leadership(OptionDescription):
|
|||
def _check_default_value(self, child: BaseOption):
|
||||
default = child.impl_getdefault()
|
||||
if default != []:
|
||||
if child.impl_is_submulti() and isinstance(default, tuple):
|
||||
if child.impl_is_submulti() and isinstance(default, (list, tuple)):
|
||||
for val in default:
|
||||
if not isinstance(val, Calculation):
|
||||
calculation = False
|
||||
|
@ -100,8 +100,8 @@ class Leadership(OptionDescription):
|
|||
calculation = isinstance(default, Calculation)
|
||||
if not calculation:
|
||||
raise ValueError(_('not allowed default value for follower option '
|
||||
'"{child.impl_get_display_name()}" in leadership '
|
||||
'"{self.impl_get_display_name()}"'))
|
||||
f'"{child.impl_get_display_name()}" in leadership '
|
||||
f'"{self.impl_get_display_name()}"'))
|
||||
|
||||
def _setsubdyn(self,
|
||||
subdyn,
|
||||
|
|
|
@ -165,13 +165,13 @@ class CacheOptionDescription(BaseOption):
|
|||
doption = option
|
||||
subpath = doption.impl_getpath()
|
||||
for index in range(follower_len):
|
||||
if values.hasvalue(subpath, index):
|
||||
continue
|
||||
option_bag = OptionBag(doption,
|
||||
index,
|
||||
config_bag,
|
||||
properties=frozenset(),
|
||||
)
|
||||
if values.hasvalue(subpath, index=index):
|
||||
continue
|
||||
value = values.get_value(option_bag)
|
||||
if value is None:
|
||||
continue
|
||||
|
@ -186,7 +186,7 @@ class CacheOptionDescription(BaseOption):
|
|||
value = values.get_value(option_bag)
|
||||
if value is None:
|
||||
continue
|
||||
if values.hasvalue(option_bag.option.impl_getpath()):
|
||||
if values.hasvalue(option_bag.path):
|
||||
continue
|
||||
values.set_storage_value(option_bag.path,
|
||||
None,
|
||||
|
|
|
@ -465,7 +465,8 @@ class Values:
|
|||
return owners.default
|
||||
if only_default:
|
||||
if self.hasvalue(option_bag.path,
|
||||
option_bag.index):
|
||||
index=option_bag.index,
|
||||
):
|
||||
owner = 'not_default'
|
||||
else:
|
||||
owner = owners.default
|
||||
|
@ -499,7 +500,9 @@ class Values:
|
|||
if owner in forbidden_owners:
|
||||
raise ValueError(_('set owner "{0}" is forbidden').format(str(owner)))
|
||||
|
||||
if not self.hasvalue(option_bag.path, option_bag.index):
|
||||
if not self.hasvalue(option_bag.path,
|
||||
index=option_bag.index,
|
||||
):
|
||||
raise ConfigError(_(f'no value for {option_bag.path} cannot change owner to {owner}'))
|
||||
option_bag.config_bag.context.get_settings().validate_frozen(option_bag)
|
||||
self._values[option_bag.path][option_bag.index][1] = owner
|
||||
|
@ -611,7 +614,7 @@ class Values:
|
|||
self.resetvalue_index(option_bag)
|
||||
for index in range(option_bag.index + 1, self.get_max_length(option_bag.path)):
|
||||
if self.hasvalue(option_bag.path,
|
||||
index,
|
||||
index=index,
|
||||
):
|
||||
self._values[option_bag.path][index - 1] = self._values[option_bag.path].pop(index)
|
||||
|
||||
|
|
Loading…
Reference in a new issue