valid correctly consistencies for master/slaves
This commit is contained in:
@ -6,7 +6,7 @@ from py.test import raises
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription, SymLinkOption
|
||||
StrOption, OptionDescription, SymLinkOption, IPOption, NetmaskOption
|
||||
from tiramisu.error import PropertiesOptionError, ConflictError, SlaveError, ConfigError
|
||||
|
||||
|
||||
@ -480,6 +480,46 @@ def test_callback_master_and_slaves_master4():
|
||||
assert list(cfg.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == []
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_mandatory_transitive():
|
||||
#default value
|
||||
val1 = IPOption('val1', "", ['192.168.0.1'], multi=True, properties=('mandatory',))
|
||||
val2 = NetmaskOption('val2', "", multi=True, default_multi='255.255.255.0', properties=('disabled', 'mandatory'))
|
||||
val2.impl_add_consistency('ip_netmask', val1)
|
||||
#no value
|
||||
val3 = IPOption('val3', "", multi=True, properties=('mandatory',))
|
||||
val4 = NetmaskOption('val4', "", multi=True, default_multi='255.255.255.0', properties=('disabled', 'mandatory'))
|
||||
val4.impl_add_consistency('ip_netmask', val3)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface2 = OptionDescription('val3', '', [val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface2.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, interface2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
raises(PropertiesOptionError, "cfg.val1.val1")
|
||||
raises(PropertiesOptionError, "cfg.val3.val3")
|
||||
assert list(cfg.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == []
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_mandatory_non_transitive():
|
||||
#no value
|
||||
val1 = IPOption('val1', "", multi=True, properties=('mandatory',))
|
||||
val2 = NetmaskOption('val2', "", multi=True, default_multi='255.255.255.0', properties=('disabled', 'mandatory'))
|
||||
val2.impl_add_consistency('ip_netmask', val1, transitive=False)
|
||||
#default value
|
||||
val3 = IPOption('val3', "", ['192.168.0.1'], multi=True, properties=('mandatory',))
|
||||
val4 = NetmaskOption('val4', "", multi=True, default_multi='255.255.255.0', properties=('disabled', 'mandatory'))
|
||||
val4.impl_add_consistency('ip_netmask', val3, transitive=False)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface2 = OptionDescription('val3', '', [val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface2.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, interface2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
assert list(cfg.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ["val1.val1"]
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_list():
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_list)
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
|
Reference in New Issue
Block a user