use python-coverage to delete dead part of code
This commit is contained in:
@ -5,6 +5,7 @@ do_autopath()
|
||||
from tiramisu.setting import owners
|
||||
from tiramisu.option import ChoiceOption, StrOption, OptionDescription
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.error import ConfigError
|
||||
|
||||
from py.test import raises
|
||||
|
||||
@ -86,3 +87,18 @@ def test_choiceoption_calc_opt_multi_function():
|
||||
assert cfg.getowner(ch) == owners.default
|
||||
#
|
||||
raises(ValueError, "cfg.ch2")
|
||||
|
||||
|
||||
def test_choiceoption_calc_invalid():
|
||||
st = StrOption('st', '', ['val1'], multi=True)
|
||||
st
|
||||
raises(ValueError, "ch = ChoiceOption('ch', '', default_multi='val2', values=[1, 2, 3], values_params={'': ((st, False),)}, multi=True)")
|
||||
|
||||
|
||||
def test_choiceoption_calc_not_list():
|
||||
st = StrOption('st', '', 'val1')
|
||||
ch = ChoiceOption('ch', "", default_multi='val2', values=return_val, values_params={'': ((st, False),)}, multi=True)
|
||||
od = OptionDescription('od', '', [st, ch])
|
||||
cfg = Config(od)
|
||||
cfg.read_write()
|
||||
raises(ConfigError, "cfg.ch = ['val1']")
|
||||
|
@ -49,6 +49,14 @@ def test_base_config():
|
||||
assert dm.impl_getname() == 'dummy'
|
||||
|
||||
|
||||
def test_base_config_name():
|
||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||
descr = OptionDescription('tiramisu', '', [gcdummy])
|
||||
cfg = Config(descr, name='cfg')
|
||||
cfg.impl_getname() == 'cfg'
|
||||
raises(ValueError, "Config(descr, name='unvalid name')")
|
||||
|
||||
|
||||
def test_not_config():
|
||||
assert raises(TypeError, "Config('str')")
|
||||
|
||||
@ -324,6 +332,15 @@ def test_delete_config_with_subconfig():
|
||||
raises(ConfigError, 'sub.make_dict()')
|
||||
|
||||
|
||||
def test_subconfig():
|
||||
i = IntOption('i', '')
|
||||
o = OptionDescription('val', '', [i])
|
||||
o2 = OptionDescription('val', '', [o])
|
||||
c = Config(o2)
|
||||
raises(TypeError, "SubConfig(i, weakref.ref(c))")
|
||||
pass
|
||||
|
||||
|
||||
def test_config_weakref():
|
||||
o = OptionDescription('val', '', [])
|
||||
o2 = OptionDescription('val', '', [o])
|
||||
|
@ -85,7 +85,7 @@ def test_domainname_warning():
|
||||
raises(ValueError, "c.f = 'domainnametoolongthathavemorethanmaximumsizeforatruedomainnamean'")
|
||||
c.f = 'domainnametoolongthathavemorethanmaximumsizeforatruedomainnamea.nd'
|
||||
c.f = 'domainnametoolongthathavemorethanmaximumsizeforatruedomainnamea.nditsnoteasytogeneratesolongdomainnamewithoutrepeatdomainnameto.olongthathavemorethanmaximumsizeforatruedomainnameanditsnoteas.ytogeneratesolongdomainnamewithoutrepeatbutimnotabletodoitnowie'
|
||||
raises(ValueError, "c.f = 'domainnametoolongthathavemorethanmaximumsizeforatruedomainnamea.nditsnoteasytogeneratesolongdomainnamewithoutrepeatdomainnameto.olongthathavemorethanmaximumsizeforatruedomainnameanditsnoteas.ytogeneratesolongdomainnamewithoutrepeatbutimnotabletodoitnowien'")
|
||||
raises(ValueError, "c.f = 'domainnametoolongthathavemorethanmaximumsizeforatruedomainname.nditsnoteasytogeneratesolongdomainnamewithoutrepeatdomainnamet.olongthathavemorethanmaximumsizeforatruedomainnameanditsnotea.ytogeneratesolongdomainnamewithoutrepeatbutimnotabletodoitnowie.xxxx'")
|
||||
c.f = 'd'
|
||||
c.f = 'd.t'
|
||||
#
|
||||
|
@ -1,16 +1,20 @@
|
||||
from autopath import do_autopath
|
||||
do_autopath()
|
||||
|
||||
import warnings
|
||||
from py.test import raises
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import IPOption, NetworkOption, NetmaskOption, \
|
||||
PortOption, OptionDescription
|
||||
from tiramisu.error import ValueWarning
|
||||
|
||||
|
||||
def test_ip():
|
||||
a = IPOption('a', '')
|
||||
b = IPOption('b', '', private_only=True)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
d = IPOption('d', '', warnings_only=True, private_only=True)
|
||||
warnings.simplefilter("always", ValueWarning)
|
||||
od = OptionDescription('od', '', [a, b, d])
|
||||
c = Config(od)
|
||||
c.a = '192.168.1.1'
|
||||
c.a = '192.168.1.0'
|
||||
@ -24,10 +28,9 @@ def test_ip():
|
||||
raises(ValueError, "c.b = '255.255.255.0'")
|
||||
|
||||
raises(ValueError, "IPOption('a', 'ip', default='192.000.023.01')")
|
||||
d = IPOption('a', 'ip', default='192.0.23.1')
|
||||
od = OptionDescription('od', '', [d])
|
||||
c = Config(od)
|
||||
raises(ValueError, "c.a = '192.000.023.01'")
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
c.d = '88.88.88.88'
|
||||
assert len(w) == 1
|
||||
|
||||
|
||||
def test_ip_default():
|
||||
@ -40,21 +43,31 @@ def test_ip_default():
|
||||
def test_ip_reserved():
|
||||
a = IPOption('a', '')
|
||||
b = IPOption('b', '', allow_reserved=True)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
c = Config(od)
|
||||
raises(ValueError, "c.a = '226.94.1.1'")
|
||||
c.b = '226.94.1.1'
|
||||
c = IPOption('c', '', warnings_only=True)
|
||||
od = OptionDescription('od', '', [a, b, c])
|
||||
warnings.simplefilter("always", ValueWarning)
|
||||
cfg = Config(od)
|
||||
raises(ValueError, "cfg.a = '226.94.1.1'")
|
||||
cfg.b = '226.94.1.1'
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.c = '226.94.1.1'
|
||||
assert len(w) == 1
|
||||
|
||||
|
||||
def test_network():
|
||||
a = NetworkOption('a', '')
|
||||
od = OptionDescription('od', '', [a])
|
||||
b = NetworkOption('b', '', warnings_only=True)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
warnings.simplefilter("always", ValueWarning)
|
||||
c = Config(od)
|
||||
c.a = '192.168.1.1'
|
||||
c.a = '192.168.1.0'
|
||||
c.a = '88.88.88.88'
|
||||
c.a = '0.0.0.0'
|
||||
raises(ValueError, "c.a = '255.255.255.0'")
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
c.b = '255.255.255.0'
|
||||
assert len(w) == 1
|
||||
|
||||
|
||||
def test_netmask():
|
||||
|
@ -707,6 +707,88 @@ def test_consistency_dyndescription():
|
||||
raises(ValueError, "cfg.od.dodval2.stval2 = 'yes'")
|
||||
|
||||
|
||||
def test_consistency_dyndescription_default():
|
||||
st = StrOption('st', '', 'yes')
|
||||
st2 = StrOption('st2', '')
|
||||
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
|
||||
raises(ValueError, "cfg.od.dodval1.st2val1 = 'yes'")
|
||||
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)
|
||||
dod = DynOptionDescription('dod', '', [st, st2], callback=return_list)
|
||||
dod
|
||||
raises(ValueError, "st.impl_add_consistency('not_equal', st2)")
|
||||
|
||||
|
||||
def test_consistency_only_one_dyndescription():
|
||||
st = StrOption('st', '')
|
||||
st
|
||||
st2 = StrOption('st2', '')
|
||||
DynOptionDescription('dod', '', [st2], callback=return_list)
|
||||
raises(ConfigError, "st.impl_add_consistency('not_equal', st2)")
|
||||
raises(ConfigError, "st2.impl_add_consistency('not_equal', st)")
|
||||
|
||||
|
||||
def test_consistency_became_dyndescription():
|
||||
st = StrOption('st', '')
|
||||
st2 = StrOption('st2', '')
|
||||
st2.impl_add_consistency('not_equal', st)
|
||||
od = DynOptionDescription('dod', '', [st2], callback=return_list)
|
||||
od2 = OptionDescription('od', '', [od, st])
|
||||
od2
|
||||
raises(ConfigError, "c = Config(od2)")
|
||||
|
||||
|
||||
def test_consistency_became_dyndescription2():
|
||||
st = StrOption('st', '')
|
||||
st2 = StrOption('st2', '')
|
||||
st.impl_add_consistency('not_equal', st2)
|
||||
od = DynOptionDescription('dod', '', [st2], callback=return_list)
|
||||
od2 = OptionDescription('od', '', [od, st])
|
||||
od2
|
||||
raises(ConfigError, "c = Config(od2)")
|
||||
|
||||
|
||||
def test_consistency_external_dyndescription():
|
||||
st = StrOption('st', '')
|
||||
st1 = StrOption('st1', '')
|
||||
|
@ -24,7 +24,7 @@ def make_description():
|
||||
conf2 = Config(od2, name='conf2')
|
||||
conf1.read_write()
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta = MetaConfig([conf1, conf2], name='meta')
|
||||
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||
return meta
|
||||
|
||||
@ -168,6 +168,9 @@ def test_meta_meta_set():
|
||||
raises(AttributeError, "meta2.find_firsts(byname='i1', byvalue=10)")
|
||||
raises(AttributeError, "meta2.find_firsts(byname='not', byvalue=10)")
|
||||
raises(AttributeError, "meta2.find_firsts(byname='i6')")
|
||||
raises(ValueError, "meta2.set_value('od1.i6', 7, only_config=True, force_default=True)")
|
||||
raises(ValueError, "meta2.set_value('od1.i6', 7, only_config=True, force_default_if_same=True)")
|
||||
raises(ValueError, "meta2.set_value('od1.i6', 7, only_config=True, force_dont_change_value=True)")
|
||||
|
||||
|
||||
def test_not_meta():
|
||||
@ -200,6 +203,21 @@ def test_group_find_firsts():
|
||||
assert [conf1, conf2] == grp.find_firsts(byname='i1').cfgimpl_get_children()
|
||||
|
||||
|
||||
def test_group_group():
|
||||
i1 = IntOption('i1', '')
|
||||
od1 = OptionDescription('od1', '', [i1])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
conf1 = Config(od2, name='conf1')
|
||||
conf2 = Config(od2, name='conf2')
|
||||
grp = GroupConfig([conf1, conf2])
|
||||
raises(ValueError, "GroupConfig([grp])")
|
||||
grp = GroupConfig([conf1, conf2], 'grp')
|
||||
grp2 = GroupConfig([grp])
|
||||
grp2.set_value('od1.i1', 2)
|
||||
assert grp2.grp.conf1.od1.i1 == 2
|
||||
assert grp2.grp.conf1.getowner(i1) == owners.user
|
||||
|
||||
|
||||
def test_meta_path():
|
||||
meta = make_description()
|
||||
assert meta._impl_path is None
|
||||
|
@ -869,3 +869,10 @@ def test_masterslaves_callback_description():
|
||||
assert cfg.od.st.st1.st1 == ['yes']
|
||||
assert cfg.od.st.st1.st2 == ['yes']
|
||||
assert cfg.getowner(st1) == owner
|
||||
|
||||
|
||||
def test_re_set_callback():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True)
|
||||
st2.impl_set_callback(return_value, {'': ((st1, False),)})
|
||||
raises(ConfigError, "st2.impl_set_callback(return_value, {'': ((st1, False),)})")
|
||||
|
@ -6,7 +6,7 @@ from py.test import raises
|
||||
from tiramisu.setting import owners, groups
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import IPOption, NetworkOption, NetmaskOption, IntOption,\
|
||||
BroadcastOption, SymLinkOption, OptionDescription
|
||||
BroadcastOption, SymLinkOption, OptionDescription, submulti
|
||||
from tiramisu.error import ConfigError, ValueWarning, PropertiesOptionError
|
||||
import warnings
|
||||
|
||||
@ -14,7 +14,6 @@ import warnings
|
||||
def test_consistency():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
#consistency to itself
|
||||
raises(ConfigError, "a.impl_add_consistency('not_equal', a)")
|
||||
@ -25,17 +24,26 @@ def test_consistency():
|
||||
def test_consistency_not_exists():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
a, b
|
||||
raises(ConfigError, "a.impl_add_consistency('not_exists', b)")
|
||||
|
||||
|
||||
def test_consistency_unknown_params():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
a, b
|
||||
raises(ValueError, "a.impl_add_consistency('not_equal', b, unknown=False)")
|
||||
|
||||
|
||||
def test_consistency_warnings_only_default():
|
||||
a = IntOption('a', '', 1)
|
||||
b = IntOption('b', '', 1)
|
||||
warnings.simplefilter("always", ValueWarning)
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
a.impl_add_consistency('not_equal', b, warnings_only=True)
|
||||
assert w != []
|
||||
|
||||
|
||||
def test_consistency_warnings_only():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
@ -99,8 +107,8 @@ def test_consistency_not_in_config_1():
|
||||
b = IntOption('b', '')
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
od1 = OptionDescription('od1', '', [a])
|
||||
od2 = OptionDescription('od2', '', [b])
|
||||
od = OptionDescription('root', '', [od1])
|
||||
od
|
||||
raises(ConfigError, "Config(od)")
|
||||
|
||||
|
||||
@ -121,6 +129,7 @@ def test_consistency_not_in_config_3():
|
||||
od1 = OptionDescription('od1', '', [a])
|
||||
od2 = OptionDescription('od2', '', [b])
|
||||
od = OptionDescription('root', '', [od1, od2])
|
||||
od
|
||||
#with subconfig
|
||||
raises(ConfigError, "Config(od.od1)")
|
||||
|
||||
@ -145,6 +154,34 @@ def test_consistency_not_equal_symlink():
|
||||
assert set(od._cache_consistencies.keys()) == set([a, b])
|
||||
|
||||
|
||||
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]]
|
||||
|
||||
|
||||
def test_consistency_not_equal_default_submulti():
|
||||
a = IntOption('a', '', [[1, 2]], multi=submulti)
|
||||
b = IntOption('b', '', [[1]], multi=submulti)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
od
|
||||
raises(ValueError, "a.impl_add_consistency('not_equal', b)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_multi():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True)
|
||||
@ -160,9 +197,25 @@ def test_consistency_not_equal_multi():
|
||||
c.b = [2]
|
||||
|
||||
|
||||
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])
|
||||
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.b = [2]
|
||||
|
||||
|
||||
def test_consistency_default():
|
||||
a = IntOption('a', '', 1)
|
||||
b = IntOption('b', '', 1)
|
||||
a, b
|
||||
raises(ValueError, "a.impl_add_consistency('not_equal', b)")
|
||||
|
||||
|
||||
@ -170,6 +223,7 @@ def test_consistency_default_multi():
|
||||
a = IntOption('a', '', [2, 1], multi=True)
|
||||
b = IntOption('b', '', [1, 1], multi=True)
|
||||
c = IntOption('c', '', [1, 2], multi=True)
|
||||
b
|
||||
raises(ValueError, "a.impl_add_consistency('not_equal', b)")
|
||||
a.impl_add_consistency('not_equal', c)
|
||||
|
||||
@ -221,8 +275,11 @@ def test_consistency_ip_in_network():
|
||||
a = NetworkOption('a', '')
|
||||
b = NetmaskOption('b', '')
|
||||
c = IPOption('c', '')
|
||||
od = OptionDescription('od', '', [a, b, c])
|
||||
d = IPOption('d', '')
|
||||
od = OptionDescription('od', '', [a, b, c, d])
|
||||
c.impl_add_consistency('in_network', a, b)
|
||||
d.impl_add_consistency('in_network', a, b, warnings_only=True)
|
||||
warnings.simplefilter("always", ValueWarning)
|
||||
cfg = Config(od)
|
||||
cfg.a = '192.168.1.0'
|
||||
cfg.b = '255.255.255.0'
|
||||
@ -230,6 +287,9 @@ def test_consistency_ip_in_network():
|
||||
raises(ValueError, "cfg.c = '192.168.2.1'")
|
||||
raises(ValueError, "cfg.c = '192.168.1.0'")
|
||||
raises(ValueError, "cfg.c = '192.168.1.255'")
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.d = '192.168.2.1'
|
||||
assert len(w) == 1
|
||||
|
||||
|
||||
def test_consistency_ip_in_network_len_error():
|
||||
@ -239,6 +299,7 @@ def test_consistency_ip_in_network_len_error():
|
||||
od = OptionDescription('od', '', [a, b, c])
|
||||
c.impl_add_consistency('in_network', a)
|
||||
cfg = Config(od)
|
||||
cfg
|
||||
raises(ConfigError, "cfg.a = '192.168.2.0'")
|
||||
|
||||
|
||||
@ -257,7 +318,7 @@ def test_consistency_ip_netmask_network_error():
|
||||
def test_consistency_ip_netmask_error_multi():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '')
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
OptionDescription('od', '', [a, b])
|
||||
raises(ConfigError, "b.impl_add_consistency('ip_netmask', a)")
|
||||
|
||||
|
||||
@ -449,17 +510,17 @@ def test_consistency_broadcast_default_1():
|
||||
a = NetworkOption('a', '', '192.168.1.0')
|
||||
b = NetmaskOption('b', '', '255.255.255.128')
|
||||
c = BroadcastOption('c', '', '192.168.2.127')
|
||||
d = BroadcastOption('d', '', '192.168.1.127')
|
||||
od = OptionDescription('a', '', [a, b, c])
|
||||
od
|
||||
raises(ValueError, "c.impl_add_consistency('broadcast', a, b)")
|
||||
|
||||
|
||||
def test_consistency_broadcast_default_2():
|
||||
a = NetworkOption('a', '', '192.168.1.0')
|
||||
b = NetmaskOption('b', '', '255.255.255.128')
|
||||
c = BroadcastOption('c', '', '192.168.2.127')
|
||||
d = BroadcastOption('d', '', '192.168.1.127')
|
||||
od2 = OptionDescription('a', '', [a, b, d])
|
||||
od2
|
||||
d.impl_add_consistency('broadcast', a, b)
|
||||
|
||||
|
||||
|
@ -11,8 +11,11 @@ from tiramisu.error import SlaveError
|
||||
from py.test import raises
|
||||
|
||||
|
||||
def return_val():
|
||||
return 'val'
|
||||
def return_val(val=None):
|
||||
if val is None:
|
||||
return 'val'
|
||||
else:
|
||||
return val
|
||||
|
||||
|
||||
def return_list(value=None):
|
||||
@ -319,6 +322,8 @@ def test_callback_submulti_list():
|
||||
cfg.multi.append()
|
||||
assert cfg.getowner(multi) == owner
|
||||
assert cfg.multi == [['val', 'val'], ['val', 'val']]
|
||||
cfg.multi.append()
|
||||
assert cfg.multi == [['val', 'val'], ['val', 'val'], ['val', 'val']]
|
||||
del(cfg.multi)
|
||||
assert cfg.getowner(multi) == owners.default
|
||||
cfg.multi[0].append()
|
||||
@ -342,6 +347,8 @@ def test_callback_submulti_list_list():
|
||||
cfg.multi[0].append()
|
||||
assert cfg.getowner(multi) == owner
|
||||
assert cfg.multi == [['val', 'val', None]]
|
||||
del(cfg.multi)
|
||||
cfg.multi.append()
|
||||
|
||||
|
||||
#FIXME multi sur une master
|
||||
@ -639,3 +646,20 @@ def test__master_is_submulti():
|
||||
cfg.ip_admin_eth0.ip_admin_eth0[0].pop(0)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == [["192.168.1.1"], ["192.168.230.147"]]
|
||||
raises(ValueError, 'cfg.ip_admin_eth0.ip_admin_eth0 = ["192.168.1.1", "192.168.1.1"]')
|
||||
|
||||
|
||||
def test_callback_submulti():
|
||||
multi = StrOption('multi', '', multi=submulti)
|
||||
multi2 = StrOption('multi2', '', multi=submulti, callback=return_val, callback_params={'': ((multi, False),)})
|
||||
od = OptionDescription('multi', '', [multi, multi2])
|
||||
cfg = Config(od)
|
||||
cfg.read_write()
|
||||
owner = cfg.cfgimpl_get_settings().getowner()
|
||||
assert cfg.getowner(multi) == owners.default
|
||||
assert cfg.multi == []
|
||||
assert cfg.multi2 == []
|
||||
cfg.multi.append(['val'])
|
||||
assert cfg.getowner(multi) == owner
|
||||
assert cfg.getowner(multi2) == owners.default
|
||||
assert cfg.multi == [['val']]
|
||||
assert cfg.multi2 == [['val']]
|
||||
|
Reference in New Issue
Block a user