better force_default_on_freeze support for slave
This commit is contained in:
parent
821f36ea65
commit
d4cf1faff8
@ -7,7 +7,7 @@ from py.test import raises
|
||||
from tiramisu.setting import owners
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||
from tiramisu import IntOption, FloatOption, StrOption, ChoiceOption, \
|
||||
BoolOption, OptionDescription, Config, getapi, undefined
|
||||
BoolOption, OptionDescription, MasterSlaves, Config, getapi, undefined
|
||||
|
||||
|
||||
def make_description():
|
||||
@ -107,6 +107,61 @@ def test_force_default_on_freeze_multi():
|
||||
api.option('dummy1').property.add('frozen')
|
||||
|
||||
|
||||
def test_force_default_on_freeze_master():
|
||||
dummy1 = BoolOption('dummy1', 'Test int option', multi=True, properties=('force_default_on_freeze',))
|
||||
dummy2 = BoolOption('dummy2', 'Test string option', multi=True)
|
||||
descr = MasterSlaves("dummy1", "", [dummy1, dummy2])
|
||||
descr = OptionDescription("root", "", [descr])
|
||||
raises(ConfigError, "Config(descr)")
|
||||
|
||||
|
||||
def test_force_default_on_freeze_slave():
|
||||
dummy1 = BoolOption('dummy1', 'Test int option', multi=True)
|
||||
dummy2 = BoolOption('dummy2', 'Test string option', multi=True, properties=('force_default_on_freeze',))
|
||||
descr = MasterSlaves("dummy1", "", [dummy1, dummy2])
|
||||
descr = OptionDescription("root", "", [descr])
|
||||
api = getapi(Config(descr))
|
||||
api.property.read_write()
|
||||
owners.addowner("frozenmultislave")
|
||||
api.option('dummy1.dummy1').value.set([True])
|
||||
api.option('dummy1.dummy2', 0).value.set(False)
|
||||
assert api.option('dummy1.dummy1').value.get() == [True]
|
||||
assert api.option('dummy1.dummy2', 0).value.get() == False
|
||||
assert api.option('dummy1.dummy1').owner.get() == 'user'
|
||||
assert api.option('dummy1.dummy2', 0).owner.get() == 'user'
|
||||
#
|
||||
api.option('dummy1.dummy2').property.add('frozen')
|
||||
assert api.option('dummy1.dummy1').value.get() == [True]
|
||||
assert api.option('dummy1.dummy2', 0).value.get() == None
|
||||
assert api.option('dummy1.dummy1').owner.get() == 'user'
|
||||
assert api.option('dummy1.dummy2', 0).owner.isdefault()
|
||||
raises(PropertiesOptionError, "api.option('dummy1.dummy2', 0).owner.set('frozenmultislave')")
|
||||
#
|
||||
api.option('dummy1.dummy2').property.pop('frozen')
|
||||
api.option('dummy1.dummy1').value.set([True, True])
|
||||
api.option('dummy1.dummy2', 1).value.set(False)
|
||||
assert api.option('dummy1.dummy1').value.get() == [True, True]
|
||||
assert api.option('dummy1.dummy2', 0).value.get() == False
|
||||
assert api.option('dummy1.dummy2', 1).value.get() == False
|
||||
#
|
||||
api.option('dummy1.dummy2').property.add('frozen')
|
||||
assert api.option('dummy1.dummy1').value.get() == [True, True]
|
||||
assert api.option('dummy1.dummy2', 0).value.get() == None
|
||||
assert api.option('dummy1.dummy2', 1).value.get() == None
|
||||
#
|
||||
api.option('dummy1.dummy1').value.pop(1)
|
||||
assert api.option('dummy1.dummy1').value.get() == [True]
|
||||
assert api.option('dummy1.dummy2', 0).value.get() == None
|
||||
#
|
||||
api.option('dummy1.dummy2').property.pop('frozen')
|
||||
assert api.option('dummy1.dummy1').value.get() == [True]
|
||||
assert api.option('dummy1.dummy2', 0).value.get() == False
|
||||
#
|
||||
api.option('dummy1.dummy1').value.set([True, True])
|
||||
assert api.option('dummy1.dummy2', 0).value.get() == False
|
||||
assert api.option('dummy1.dummy2', 1).value.get() == None
|
||||
|
||||
|
||||
def test_overrides_changes_option_value():
|
||||
"with config.override(), the default is changed and the value is changed"
|
||||
descr = OptionDescription("test", "", [
|
||||
|
@ -74,8 +74,13 @@ class CacheOptionDescription(BaseOption):
|
||||
else:
|
||||
option._set_readonly()
|
||||
is_multi = option.impl_is_multi()
|
||||
if not option.impl_is_symlinkoption() and 'force_store_value' in option.impl_getproperties():
|
||||
force_store_values.append((subpath, option))
|
||||
if not option.impl_is_symlinkoption():
|
||||
if 'force_store_value' in option.impl_getproperties():
|
||||
force_store_values.append((subpath, option))
|
||||
if 'force_default_on_freeze' in option.impl_getproperties() and \
|
||||
option.impl_is_master_slaves('master'):
|
||||
raise ConfigError(_('a master ({0}) cannot have '
|
||||
'force_default_on_freeze property').format(subpath))
|
||||
for cons_id, func, all_cons_opts, params in option.get_consistencies():
|
||||
option._valid_consistencies(all_cons_opts[1:], init=False)
|
||||
if func not in ALLOWED_CONST_LIST and is_multi:
|
||||
|
Loading…
Reference in New Issue
Block a user