symlink support for getowner and raise if option in master/slave
This commit is contained in:
parent
c2471320c3
commit
4d15c91383
|
@ -5,7 +5,7 @@ from py.test import raises
|
||||||
from tiramisu.setting import owners
|
from tiramisu.setting import owners
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||||
StrOption, OptionDescription, SymLinkOption
|
StrOption, OptionDescription
|
||||||
from tiramisu.error import PropertiesOptionError
|
from tiramisu.error import PropertiesOptionError
|
||||||
|
|
||||||
|
|
||||||
|
@ -255,25 +255,6 @@ def test_choice_access_with_multi():
|
||||||
assert config.t1 == ["a", "b", "a", "b"]
|
assert config.t1 == ["a", "b", "a", "b"]
|
||||||
|
|
||||||
|
|
||||||
#____________________________________________________________
|
|
||||||
def test_symlink_option():
|
|
||||||
boolopt = BoolOption("b", "", default=False)
|
|
||||||
linkopt = SymLinkOption("c", boolopt)
|
|
||||||
descr = OptionDescription("opt", "",
|
|
||||||
[linkopt, OptionDescription("s1", "", [boolopt])])
|
|
||||||
config = Config(descr)
|
|
||||||
setattr(config, "s1.b", True)
|
|
||||||
setattr(config, "s1.b", False)
|
|
||||||
assert config.s1.b is False
|
|
||||||
assert config.c is False
|
|
||||||
config.c = True
|
|
||||||
assert config.s1.b is True
|
|
||||||
assert config.c is True
|
|
||||||
config.c = False
|
|
||||||
assert config.s1.b is False
|
|
||||||
assert config.c is False
|
|
||||||
|
|
||||||
|
|
||||||
#____________________________________________________________
|
#____________________________________________________________
|
||||||
def test_accepts_multiple_changes_from_option():
|
def test_accepts_multiple_changes_from_option():
|
||||||
s = StrOption("string", "", default="string")
|
s = StrOption("string", "", default="string")
|
||||||
|
|
|
@ -55,7 +55,7 @@ def carry_out_calculation(name, config, callback, callback_params, index=None):
|
||||||
continue
|
continue
|
||||||
raise ConfigError(_('unable to carry out a calculation, '
|
raise ConfigError(_('unable to carry out a calculation, '
|
||||||
'option {0} has properties: {1} for: '
|
'option {0} has properties: {1} for: '
|
||||||
'{2}').format(opt._name, err.proptype,
|
'{2}').format(path, err.proptype,
|
||||||
name))
|
name))
|
||||||
is_multi = opt.impl_is_multi()
|
is_multi = opt.impl_is_multi()
|
||||||
if is_multi:
|
if is_multi:
|
||||||
|
|
|
@ -761,6 +761,9 @@ class OptionDescription(BaseInformation):
|
||||||
if isinstance(child, OptionDescription):
|
if isinstance(child, OptionDescription):
|
||||||
raise ValueError(_("master group {} shall not have "
|
raise ValueError(_("master group {} shall not have "
|
||||||
"a subgroup").format(self._name))
|
"a subgroup").format(self._name))
|
||||||
|
if isinstance(child, SymLinkOption):
|
||||||
|
raise ValueError(_("master group {} shall not have "
|
||||||
|
"a symlinkoption").format(self._name))
|
||||||
if not child.impl_is_multi():
|
if not child.impl_is_multi():
|
||||||
raise ValueError(_("not allowed option {0} in group {1}"
|
raise ValueError(_("not allowed option {0} in group {1}"
|
||||||
": this option is not a multi"
|
": this option is not a multi"
|
||||||
|
|
|
@ -23,6 +23,7 @@ from tiramisu.error import ConfigError, SlaveError
|
||||||
from tiramisu.setting import owners, multitypes, expires_time
|
from tiramisu.setting import owners, multitypes, expires_time
|
||||||
from tiramisu.autolib import carry_out_calculation
|
from tiramisu.autolib import carry_out_calculation
|
||||||
from tiramisu.i18n import _
|
from tiramisu.i18n import _
|
||||||
|
from tiramisu.option import SymLinkOption
|
||||||
|
|
||||||
|
|
||||||
class Values(object):
|
class Values(object):
|
||||||
|
@ -192,6 +193,8 @@ class Values(object):
|
||||||
self._values[opt] = (setting.getowner(), value)
|
self._values[opt] = (setting.getowner(), value)
|
||||||
|
|
||||||
def getowner(self, opt):
|
def getowner(self, opt):
|
||||||
|
if isinstance(opt, SymLinkOption):
|
||||||
|
opt = opt._opt
|
||||||
owner = self._values.get(opt, (owners.default, None))[0]
|
owner = self._values.get(opt, (owners.default, None))[0]
|
||||||
meta = self.context.cfgimpl_get_meta()
|
meta = self.context.cfgimpl_get_meta()
|
||||||
if owner is owners.default and meta is not None:
|
if owner is owners.default and meta is not None:
|
||||||
|
|
Loading…
Reference in New Issue