remove some try/except + consistency not works with submulti
This commit is contained in:
@ -720,38 +720,6 @@ def test_consistency_dyndescription_default():
|
||||
raises(ValueError, "cfg.od.dodval2.st2val2 = 'yes'")
|
||||
|
||||
|
||||
def test_consistency_dyndescription_multi():
|
||||
st = StrOption('st', '', multi=True)
|
||||
st2 = StrOption('st2', '', multi=True)
|
||||
dod = DynOptionDescription('dod', '', [st, st2], callback=return_list)
|
||||
od = OptionDescription('od', '', [dod])
|
||||
st.impl_add_consistency('not_equal', st2)
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
cfg.od.dodval1.stval1.append('yes')
|
||||
raises(ValueError, "cfg.od.dodval1.st2val1.append('yes')")
|
||||
cfg.od.dodval2.stval2.append('yes')
|
||||
raises(ValueError, "cfg.od.dodval2.st2val2.append('yes')")
|
||||
raises(ValueError, "cfg.od.dodval1.st2val1.append('yes')")
|
||||
del(cfg.od.dodval2.stval2)
|
||||
raises(ValueError, "cfg.od.dodval1.st2val1.append('yes')")
|
||||
cfg.od.dodval2.st2val2.append('yes')
|
||||
raises(ValueError, "cfg.od.dodval2.stval2.append('yes')")
|
||||
|
||||
|
||||
def test_consistency_dyndescription_default_multi():
|
||||
st = StrOption('st', '', ['yes'], multi=True)
|
||||
st2 = StrOption('st2', '', multi=True)
|
||||
dod = DynOptionDescription('dod', '', [st, st2], callback=return_list)
|
||||
od = OptionDescription('od', '', [dod])
|
||||
st.impl_add_consistency('not_equal', st2)
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
raises(ValueError, "cfg.od.dodval1.st2val1.append('yes')")
|
||||
raises(ValueError, "cfg.od.dodval1.st2val1.append('yes')")
|
||||
cfg.od.dodval1.stval1.append('yes')
|
||||
|
||||
|
||||
def test_consistency_dyndescription_default_multi2():
|
||||
st = StrOption('st', '', ['yes'], multi=True)
|
||||
st2 = StrOption('st2', '', ['yes'], multi=True)
|
||||
|
@ -291,6 +291,25 @@ def test_meta_master_slaves_value():
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
|
||||
|
||||
def test_meta_master_slaves_value_default():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True)
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
meta.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
meta.netmask_admin_eth0 = ['255.255.255.0']
|
||||
assert meta.conf1.netmask_admin_eth0 == ['255.255.255.0']
|
||||
meta.netmask_admin_eth0 = ['255.255.0.0']
|
||||
assert meta.conf1.netmask_admin_eth0 == ['255.255.0.0']
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
|
||||
|
||||
def test_meta_master_slaves_owners():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
|
@ -17,8 +17,6 @@ def test_consistency():
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
#consistency to itself
|
||||
raises(ConfigError, "a.impl_add_consistency('not_equal', a)")
|
||||
#consistency with string
|
||||
raises(ConfigError, "a.impl_add_consistency('not_equal', 'a')")
|
||||
|
||||
|
||||
def test_consistency_not_exists():
|
||||
@ -157,21 +155,9 @@ def test_consistency_not_equal_symlink():
|
||||
def test_consistency_not_equal_submulti():
|
||||
a = IntOption('a', '', multi=submulti)
|
||||
b = IntOption('b', '', multi=submulti)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
c = Config(od)
|
||||
assert c.a == []
|
||||
assert c.b == []
|
||||
c.a = [[1]]
|
||||
del(c.a)
|
||||
c.a = [[1]]
|
||||
raises(ValueError, "c.b = [[1]]")
|
||||
c.a = [[1, 2]]
|
||||
c.b = [[3]]
|
||||
c.b = [[3, 1]]
|
||||
c.b = [[3]]
|
||||
c.b[0].append(1)
|
||||
c.b = [[3], [1]]
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
raises(ConfigError, 'a.impl_add_consistency("not_equal", b)')
|
||||
|
||||
|
||||
def test_consistency_not_equal_default_submulti():
|
||||
@ -179,13 +165,14 @@ def test_consistency_not_equal_default_submulti():
|
||||
b = IntOption('b', '', [[1]], multi=submulti)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
od
|
||||
raises(ValueError, "a.impl_add_consistency('not_equal', b)")
|
||||
raises(ConfigError, "a.impl_add_consistency('not_equal', b)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_multi():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
c = Config(od)
|
||||
assert c.a == []
|
||||
@ -200,16 +187,15 @@ def test_consistency_not_equal_multi():
|
||||
def test_consistency_not_equal_multi_default():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True, default_multi=1)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
c = Config(od)
|
||||
assert c.a == []
|
||||
assert c.b == []
|
||||
c.a = [1]
|
||||
raises(ValueError, 'c.a = [1]')
|
||||
c.a = [2]
|
||||
del(c.a)
|
||||
c.a = [1]
|
||||
raises(ValueError, "c.b = [1]")
|
||||
c.b = [2]
|
||||
|
||||
|
||||
def test_consistency_default():
|
||||
@ -325,8 +311,9 @@ def test_consistency_ip_netmask_error_multi():
|
||||
def test_consistency_ip_netmask_multi():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
b.impl_add_consistency('ip_netmask', a)
|
||||
od.impl_set_group_type(groups.master)
|
||||
c = Config(od)
|
||||
c.a = ['192.168.1.1']
|
||||
c.b = ['255.255.255.0']
|
||||
@ -339,7 +326,8 @@ def test_consistency_ip_netmask_multi():
|
||||
def test_consistency_network_netmask_multi():
|
||||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c = Config(od)
|
||||
c.a = ['192.168.1.1']
|
||||
|
@ -14,12 +14,12 @@ from tiramisu.i18n import _
|
||||
def return_true(value, param=None):
|
||||
if value == 'val' and param in [None, 'yes']:
|
||||
return True
|
||||
raise ValueError('error')
|
||||
return ValueError('error')
|
||||
|
||||
|
||||
def return_false(value, param=None):
|
||||
if value == 'val' and param in [None, 'yes']:
|
||||
raise ValueError('error')
|
||||
return ValueError('error')
|
||||
|
||||
|
||||
def return_val(value, param=None):
|
||||
@ -28,7 +28,7 @@ def return_val(value, param=None):
|
||||
|
||||
def return_if_val(value):
|
||||
if value != 'val':
|
||||
raise ValueError('error')
|
||||
return ValueError('error')
|
||||
|
||||
|
||||
def test_validator():
|
||||
|
Reference in New Issue
Block a user