symlink support for getowner and raise if option in master/slave
authorEmmanuel Garette <egarette@cadoles.com>
Thu, 13 Jun 2013 20:06:49 +0000 (22:06 +0200)
committerEmmanuel Garette <egarette@cadoles.com>
Thu, 13 Jun 2013 20:06:49 +0000 (22:06 +0200)
test/test_option_setting.py
tiramisu/autolib.py
tiramisu/option.py
tiramisu/value.py

index 5f23796..15c8925 100644 (file)
@@ -5,7 +5,7 @@ from py.test import raises
 from tiramisu.setting import owners
 from tiramisu.config import Config
 from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
-    StrOption, OptionDescription, SymLinkOption
+    StrOption, OptionDescription
 from tiramisu.error import PropertiesOptionError
 
 
@@ -256,25 +256,6 @@ def test_choice_access_with_multi():
 
 
 #____________________________________________________________
-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():
     s = StrOption("string", "", default="string")
     descr = OptionDescription("options", "", [s])
index 06a66cc..0d700c3 100644 (file)
@@ -55,7 +55,7 @@ def carry_out_calculation(name, config, callback, callback_params, index=None):
                         continue
                     raise ConfigError(_('unable to carry out a calculation, '
                                         'option {0} has properties: {1} for: '
-                                        '{2}').format(opt._name, err.proptype,
+                                        '{2}').format(path, err.proptype,
                                                       name))
                 is_multi = opt.impl_is_multi()
                 if is_multi:
index 2185a7d..46ad5e9 100644 (file)
@@ -761,6 +761,9 @@ class OptionDescription(BaseInformation):
                     if isinstance(child, OptionDescription):
                         raise ValueError(_("master group {} shall not have "
                                          "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():
                         raise ValueError(_("not allowed option {0} in group {1}"
                                          ": this option is not a multi"
index 11d23cd..851b340 100644 (file)
@@ -23,6 +23,7 @@ from tiramisu.error import ConfigError, SlaveError
 from tiramisu.setting import owners, multitypes, expires_time
 from tiramisu.autolib import carry_out_calculation
 from tiramisu.i18n import _
+from tiramisu.option import SymLinkOption
 
 
 class Values(object):
@@ -192,6 +193,8 @@ class Values(object):
         self._values[opt] = (setting.getowner(), value)
 
     def getowner(self, opt):
+        if isinstance(opt, SymLinkOption):
+            opt = opt._opt
         owner = self._values.get(opt, (owners.default, None))[0]
         meta = self.context.cfgimpl_get_meta()
         if owner is owners.default and meta is not None: