slave with requires could not raise
This commit is contained in:
parent
6d71749014
commit
071035854b
@ -246,14 +246,27 @@ def test_multi_with_requires_that_is_masterslave_master():
|
||||
raises(ValueError, "Config(descr)")
|
||||
|
||||
|
||||
def test_multi_with_requires_that_is_masterslave2():
|
||||
def test_multi_with_requires_that_is_masterslave_slave():
|
||||
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
||||
c = StrOption('str', 'Test string option', multi=True)
|
||||
d = StrOption('str1', 'Test string option', requires=[{'option': c, 'expected': '1', 'action': 'hidden'}], multi=True)
|
||||
descr = OptionDescription("int", "", [b, c, d])
|
||||
descr.impl_set_group_type(groups.master)
|
||||
Config(descr)
|
||||
|
||||
config = Config(descr)
|
||||
config.read_write()
|
||||
assert config.int == [0]
|
||||
assert config.str == [None]
|
||||
assert config.str1 == [None]
|
||||
config.int = [0, 1]
|
||||
assert config.int == [0, 1]
|
||||
assert config.str == [None, None]
|
||||
assert config.str1 == [None, None]
|
||||
config.str = [None, '1']
|
||||
config.read_only()
|
||||
assert config.str1 == [None, None]
|
||||
config.read_write()
|
||||
assert config.str1[0] is None
|
||||
raises(PropertiesOptionError, 'config.str1[1]')
|
||||
|
||||
def test_multi_with_requires_that_is_not_same_masterslave():
|
||||
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
||||
|
@ -644,6 +644,12 @@ def test_master_slave_requires():
|
||||
cfg.ip_admin_eth0.ip_admin_eth0.append('192.168.1.1')
|
||||
assert cfg.ip_admin_eth0.netmask_admin_eth0[0] is None
|
||||
raises(PropertiesOptionError, "cfg.ip_admin_eth0.netmask_admin_eth0[1]")
|
||||
cfg.ip_admin_eth0.ip_admin_eth0[1] = '192.168.1.2'
|
||||
assert cfg.ip_admin_eth0.netmask_admin_eth0[1] is None
|
||||
cfg.ip_admin_eth0.netmask_admin_eth0[1] = '255.255.255.255'
|
||||
assert cfg.ip_admin_eth0.netmask_admin_eth0[1] == '255.255.255.255'
|
||||
cfg.ip_admin_eth0.ip_admin_eth0[1] = '192.168.1.1'
|
||||
raises(PropertiesOptionError, "cfg.ip_admin_eth0.netmask_admin_eth0[1]")
|
||||
|
||||
|
||||
def test_master_slave_requires_no_master():
|
||||
@ -668,3 +674,11 @@ def test_master_slave_requires_no_master():
|
||||
raises(PropertiesOptionError, "cfg.ip_admin_eth0.netmask_admin_eth0")
|
||||
raises(PropertiesOptionError, "cfg.ip_admin_eth0.netmask_admin_eth0[0]")
|
||||
raises(PropertiesOptionError, "cfg.ip_admin_eth0.netmask_admin_eth0[1]")
|
||||
cfg.activate = True
|
||||
assert cfg.ip_admin_eth0.netmask_admin_eth0 == [None, None]
|
||||
cfg.ip_admin_eth0.netmask_admin_eth0 = [None, '255.255.255.255']
|
||||
assert cfg.ip_admin_eth0.netmask_admin_eth0[1] == '255.255.255.255'
|
||||
cfg.activate = False
|
||||
raises(PropertiesOptionError, "cfg.ip_admin_eth0.netmask_admin_eth0")
|
||||
raises(PropertiesOptionError, "cfg.ip_admin_eth0.netmask_admin_eth0[0]")
|
||||
raises(PropertiesOptionError, "cfg.ip_admin_eth0.netmask_admin_eth0[1]")
|
||||
|
@ -230,10 +230,13 @@ class MasterSlaves(object):
|
||||
multi.append_properties_error(value)
|
||||
else:
|
||||
return value
|
||||
else:
|
||||
elif index is None:
|
||||
multi.append(value, setitem=False, force=True, validate=validate,
|
||||
force_permissive=force_permissive)
|
||||
one_has_value = True
|
||||
else:
|
||||
multi = value
|
||||
one_has_value = True
|
||||
if not one_has_value:
|
||||
#raise last err
|
||||
if returns_raise:
|
||||
|
Loading…
Reference in New Issue
Block a user