add some tests for values
[tiramisu.git] / test / test_option_owner.py
index dbefd07..eb3790a 100644 (file)
@@ -5,6 +5,7 @@ from tiramisu.setting import owners
 from tiramisu.config import Config
 from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
     StrOption, OptionDescription
+from tiramisu.error import ConfigError
 
 
 def make_description():
@@ -70,3 +71,18 @@ def test_setowner_without_valid_owner():
     assert cfg.dummy is False
     assert cfg.getowner(gcdummy) == 'default'
     raises(TypeError, "cfg.cfgimpl_get_settings().setowner('gen_config')")
+
+
+def test_setowner_for_value():
+    gcdummy = BoolOption('dummy', 'dummy', default=False)
+    descr = OptionDescription('tiramisu', '', [gcdummy])
+    cfg = Config(descr)
+    assert cfg.dummy is False
+    assert cfg.getowner(gcdummy) == 'default'
+    owners.add_owner("new")
+    raises(ConfigError, "cfg.cfgimpl_get_values().setowner(gcdummy, owners.new)")
+    cfg.dummy = False
+    assert cfg.getowner(gcdummy) == owners.user
+    cfg.cfgimpl_get_values().setowner(gcdummy, owners.new)
+    assert cfg.getowner(gcdummy) == owners.new
+    raises(TypeError, "cfg.cfgimpl_get_values().setowner(gcdummy, 'new')")