Merge branch 'master' into metaconfig
This commit is contained in:
@ -230,3 +230,9 @@ def test_duplicated_option():
|
||||
root = OptionDescription('root', '', [d1, d2])
|
||||
#in different OptionDescription
|
||||
raises(ConflictError, "config = Config(root)")
|
||||
|
||||
def test_cannot_assign_value_to_option_description():
|
||||
descr = make_description()
|
||||
cfg = Config(descr)
|
||||
raises(TypeError, "cfg.gc = 3")
|
||||
|
||||
|
@ -116,6 +116,23 @@ def test_find_in_config():
|
||||
#assert conf.find_first(byvalue=False, byname='dummy', byattrs=dict(default=False)) == conf.unwrap_from_path('gc.dummy')
|
||||
|
||||
|
||||
def test_find_multi():
|
||||
b = BoolOption('bool', '', multi=True)
|
||||
o = OptionDescription('od', '', [b])
|
||||
conf = Config(o)
|
||||
raises(AttributeError, "conf.find(byvalue=True)")
|
||||
raises(AttributeError, "conf.find_first(byvalue=True)")
|
||||
conf.bool.append(False)
|
||||
raises(AttributeError, "conf.find(byvalue=True)")
|
||||
raises(AttributeError, "conf.find_first(byvalue=True)")
|
||||
conf.bool.append(False)
|
||||
raises(AttributeError, "conf.find(byvalue=True)")
|
||||
raises(AttributeError, "conf.find_first(byvalue=True)")
|
||||
conf.bool.append(True)
|
||||
assert conf.find(byvalue=True) == [b]
|
||||
assert conf.find_first(byvalue=True) == b
|
||||
|
||||
|
||||
def test_does_not_find_in_config():
|
||||
descr = make_description()
|
||||
conf = Config(descr)
|
||||
|
@ -7,7 +7,7 @@ from tiramisu.option import IPOption, NetworkOption, NetmaskOption, \
|
||||
|
||||
def test_ip():
|
||||
a = IPOption('a', '')
|
||||
b = IPOption('b', '', only_private=True)
|
||||
b = IPOption('b', '', private_only=True)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
c = Config(od)
|
||||
c.a = '192.168.1.1'
|
||||
@ -29,6 +29,15 @@ def test_ip_default():
|
||||
c.a == '88.88.88.88'
|
||||
|
||||
|
||||
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'
|
||||
|
||||
|
||||
def test_network():
|
||||
a = NetworkOption('a', '')
|
||||
od = OptionDescription('od', '', [a])
|
||||
|
@ -4,19 +4,33 @@ from py.test import raises
|
||||
from tiramisu.setting import groups
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription
|
||||
from tiramisu.error import PropertiesOptionError, ConflictError, SlaveError
|
||||
StrOption, OptionDescription, SymLinkOption
|
||||
from tiramisu.error import PropertiesOptionError, ConflictError, SlaveError, ConfigError
|
||||
|
||||
|
||||
def return_val():
|
||||
return 'val'
|
||||
|
||||
|
||||
def return_list():
|
||||
def return_concat(*args):
|
||||
return '.'.join(list(args))
|
||||
|
||||
|
||||
def return_list(value=None):
|
||||
return ['val', 'val']
|
||||
|
||||
|
||||
def return_value(value):
|
||||
def return_list2(*args):
|
||||
return list(args)
|
||||
|
||||
|
||||
def return_value(value=None):
|
||||
return value
|
||||
|
||||
|
||||
def return_value2(*args, **kwargs):
|
||||
value = list(args)
|
||||
value.extend(kwargs.values())
|
||||
return value
|
||||
|
||||
|
||||
@ -298,18 +312,73 @@ def test_callback():
|
||||
|
||||
def test_callback_value():
|
||||
val1 = StrOption('val1', "", 'val')
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params={'': (('val1', False),)})
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2])
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params={'': ('yes',)})
|
||||
val4 = StrOption('val4', "", callback=return_value, callback_params={'value': ((val1, False),)})
|
||||
val5 = StrOption('val5', "", callback=return_value, callback_params={'value': ('yes',)})
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
assert cfg.val1 == 'val'
|
||||
assert cfg.val2 == 'val'
|
||||
assert cfg.val4 == 'val'
|
||||
cfg.val1 = 'new-val'
|
||||
assert cfg.val1 == 'new-val'
|
||||
assert cfg.val2 == 'new-val'
|
||||
assert cfg.val4 == 'new-val'
|
||||
del(cfg.val1)
|
||||
assert cfg.val1 == 'val'
|
||||
assert cfg.val2 == 'val'
|
||||
assert cfg.val3 == 'yes'
|
||||
assert cfg.val4 == 'val'
|
||||
assert cfg.val5 == 'yes'
|
||||
|
||||
|
||||
def test_callback_value_tuple():
|
||||
val1 = StrOption('val1', "", 'val1')
|
||||
val2 = StrOption('val2', "", 'val2')
|
||||
val3 = StrOption('val3', "", callback=return_concat, callback_params={'': ((val1, False), (val2, False))})
|
||||
val4 = StrOption('val4', "", callback=return_concat, callback_params={'': ('yes', 'no')})
|
||||
raises(ValueError, "StrOption('val4', '', callback=return_concat, callback_params={'value': ('yes', 'no')})")
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
assert cfg.val1 == 'val1'
|
||||
assert cfg.val2 == 'val2'
|
||||
assert cfg.val3 == 'val1.val2'
|
||||
assert cfg.val4 == 'yes.no'
|
||||
cfg.val1 = 'new-val'
|
||||
assert cfg.val3 == 'new-val.val2'
|
||||
del(cfg.val1)
|
||||
assert cfg.val3 == 'val1.val2'
|
||||
|
||||
|
||||
def test_callback_value_force_permissive():
|
||||
val1 = StrOption('val1', "", 'val', properties=('disabled',))
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params={'': ((val1, True),)})
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_only()
|
||||
raises(ConfigError, "cfg.val2")
|
||||
assert cfg.val3 is None
|
||||
|
||||
|
||||
def test_callback_symlink():
|
||||
val1 = StrOption('val1', "", 'val')
|
||||
val2 = SymLinkOption('val2', val1)
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params={'': ((val2, False),)})
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
assert cfg.val1 == 'val'
|
||||
assert cfg.val3 == 'val'
|
||||
cfg.val1 = 'new-val'
|
||||
assert cfg.val1 == 'new-val'
|
||||
assert cfg.val3 == 'new-val'
|
||||
del(cfg.val1)
|
||||
assert cfg.val1 == 'val'
|
||||
assert cfg.val3 == 'val'
|
||||
|
||||
|
||||
def test_callback_list():
|
||||
@ -336,21 +405,28 @@ def test_callback_multi():
|
||||
|
||||
def test_callback_multi_value():
|
||||
val1 = StrOption('val1', "", ['val'], multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': (('val1', False),)})
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2])
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ('yes',)})
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_list2, callback_params={'': ((val1, False), 'yes')})
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
assert cfg.val1 == ['val']
|
||||
assert cfg.val2 == ['val']
|
||||
assert cfg.val4 == ['val', 'yes']
|
||||
cfg.val1 = ['new-val']
|
||||
assert cfg.val1 == ['new-val']
|
||||
assert cfg.val2 == ['new-val']
|
||||
assert cfg.val4 == ['new-val', 'yes']
|
||||
cfg.val1.append('new-val2')
|
||||
assert cfg.val1 == ['new-val', 'new-val2']
|
||||
assert cfg.val2 == ['new-val', 'new-val2']
|
||||
assert cfg.val4 == ['new-val', 'yes', 'new-val2', 'yes']
|
||||
del(cfg.val1)
|
||||
assert cfg.val1 == ['val']
|
||||
assert cfg.val2 == ['val']
|
||||
assert cfg.val3 == ['yes']
|
||||
assert cfg.val4 == ['val', 'yes']
|
||||
|
||||
|
||||
def test_callback_multi_list():
|
||||
@ -455,41 +531,67 @@ def test_callback_master_and_slaves_slave_list():
|
||||
|
||||
def test_callback_master_and_slaves_value():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': (('val1.val1', False),)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ('yes',)})
|
||||
val4 = StrOption('val4', '', multi=True, default=['val10', 'val11'])
|
||||
val5 = StrOption('val5', "", multi=True, callback=return_value, callback_params={'': ((val4, False),)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val2, val3, val5])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val4])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
assert cfg.val1.val1 == []
|
||||
assert cfg.val1.val2 == []
|
||||
assert cfg.val1.val3 == []
|
||||
assert cfg.val1.val5 == []
|
||||
#
|
||||
cfg.val1.val1 = ['val1']
|
||||
assert cfg.val1.val1 == ['val1']
|
||||
assert cfg.val1.val2 == ['val1']
|
||||
assert cfg.val1.val3 == ['yes']
|
||||
assert cfg.val1.val5 == ['val10']
|
||||
#
|
||||
cfg.val1.val1.append('val2')
|
||||
assert cfg.val1.val1 == ['val1', 'val2']
|
||||
assert cfg.val1.val2 == ['val1', 'val2']
|
||||
assert cfg.val1.val3 == ['yes', 'yes']
|
||||
assert cfg.val1.val5 == ['val10', 'val11']
|
||||
#
|
||||
cfg.val1.val1 = ['val1', 'val2', 'val3']
|
||||
assert cfg.val1.val1 == ['val1', 'val2', 'val3']
|
||||
assert cfg.val1.val2 == ['val1', 'val2', 'val3']
|
||||
assert cfg.val1.val3 == ['yes', 'yes', 'yes']
|
||||
assert cfg.val1.val5 == ['val10', 'val11', None]
|
||||
#
|
||||
cfg.val1.val1.pop(2)
|
||||
assert cfg.val1.val1 == ['val1', 'val2']
|
||||
assert cfg.val1.val2 == ['val1', 'val2']
|
||||
assert cfg.val1.val3 == ['yes', 'yes']
|
||||
assert cfg.val1.val5 == ['val10', 'val11']
|
||||
#
|
||||
cfg.val1.val2 = ['val2', 'val2']
|
||||
cfg.val1.val3 = ['val2', 'val2']
|
||||
cfg.val1.val5 = ['val2', 'val2']
|
||||
assert cfg.val1.val2 == ['val2', 'val2']
|
||||
assert cfg.val1.val3 == ['val2', 'val2']
|
||||
assert cfg.val1.val5 == ['val2', 'val2']
|
||||
#
|
||||
cfg.val1.val1.append('val3')
|
||||
assert cfg.val1.val2 == ['val2', 'val2', 'val3']
|
||||
assert cfg.val1.val3 == ['val2', 'val2', 'yes']
|
||||
assert cfg.val1.val5 == ['val2', 'val2', None]
|
||||
cfg.cfgimpl_get_settings().remove('cache')
|
||||
cfg.val4 = ['val10', 'val11', 'val12']
|
||||
#if value is already set, not updated !
|
||||
cfg.val1.val1.pop(2)
|
||||
cfg.val1.val1.append('val3')
|
||||
cfg.val1.val1 = ['val1', 'val2', 'val3']
|
||||
assert cfg.val1.val5 == ['val2', 'val2', 'val12']
|
||||
|
||||
|
||||
def test_callback_hidden():
|
||||
opt1 = BoolOption('opt1', '')
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': (('od1.opt1', False),)})
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)})
|
||||
od1 = OptionDescription('od1', '', [opt1], properties=('hidden',))
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
@ -498,3 +600,94 @@ def test_callback_hidden():
|
||||
cfg.read_write()
|
||||
raises(PropertiesOptionError, 'cfg.od1.opt1')
|
||||
cfg.od2.opt2
|
||||
|
||||
|
||||
def test_callback_two_disabled():
|
||||
opt1 = BoolOption('opt1', '', properties=('disabled',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)}, properties=('disabled',))
|
||||
od1 = OptionDescription('od1', '', [opt1])
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
raises(PropertiesOptionError, 'cfg.od2.opt2')
|
||||
|
||||
|
||||
def test_callback_calculating_disabled():
|
||||
opt1 = BoolOption('opt1', '', properties=('disabled',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)})
|
||||
od1 = OptionDescription('od1', '', [opt1])
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
raises(ConfigError, 'cfg.od2.opt2')
|
||||
|
||||
|
||||
def test_callback_calculating_mandatory():
|
||||
opt1 = BoolOption('opt1', '', properties=('disabled',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)}, properties=('mandatory',))
|
||||
od1 = OptionDescription('od1', '', [opt1])
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_only()
|
||||
raises(ConfigError, 'cfg.od2.opt2')
|
||||
|
||||
|
||||
def test_callback_two_disabled_multi():
|
||||
opt1 = BoolOption('opt1', '', properties=('disabled',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)}, properties=('disabled',), multi=True)
|
||||
od1 = OptionDescription('od1', '', [opt1])
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
raises(PropertiesOptionError, 'cfg.od2.opt2')
|
||||
|
||||
|
||||
def test_callback_multi_list_params():
|
||||
val1 = StrOption('val1', "", multi=True, default=['val1', 'val2'])
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_list, callback_params={'': ((val1, False),)})
|
||||
oval2 = OptionDescription('val2', '', [val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, oval2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
assert cfg.val2.val2 == ['val', 'val', 'val', 'val']
|
||||
|
||||
|
||||
def test_callback_multi_list_params_key():
|
||||
val1 = StrOption('val1', "", multi=True, default=['val1', 'val2'])
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_list, callback_params={'value': ((val1, False),)})
|
||||
oval2 = OptionDescription('val2', '', [val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, oval2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
assert cfg.val2.val2 == ['val', 'val', 'val', 'val']
|
||||
|
||||
|
||||
def test_callback_multi_multi():
|
||||
val1 = StrOption('val1', "", multi=True, default=['val1', 'val2', 'val3'])
|
||||
val2 = StrOption('val2', "", multi=True, default=['val11', 'val12'])
|
||||
val3 = StrOption('val3', "", default='val4')
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_list2, callback_params={'': ((val1, False), (val2, False))})
|
||||
val5 = StrOption('val5', "", multi=True, callback=return_list2, callback_params={'': ((val1, False), (val3, False))})
|
||||
val6 = StrOption('val6', "", multi=True, default=['val21', 'val22', 'val23'])
|
||||
val7 = StrOption('val7', "", multi=True, callback=return_list2, callback_params={'': ((val1, False), (val6, False))})
|
||||
raises(ValueError, "StrOption('val8', '', multi=True, callback=return_list2, callback_params={'value': ((val1, False), (val6, False))})")
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5, val6, val7])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
raises(ConfigError, "cfg.val4")
|
||||
assert cfg.val5 == ['val1', 'val4', 'val2', 'val4', 'val3', 'val4']
|
||||
assert cfg.val7 == ['val1', 'val21', 'val2', 'val22', 'val3', 'val23']
|
||||
|
||||
|
||||
def test_multi_with_no_value():
|
||||
#First option return [] (so without value)
|
||||
val1 = StrOption('val1', "", ['val'], multi=True)
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
val3 = StrOption('val3', '', multi=True, callback=return_value, callback_params={'': ((val2, False),), 'value': ((val1, False),)})
|
||||
od = OptionDescription('od', '', [val1, val2, val3])
|
||||
c = Config(od)
|
||||
raises(ConfigError, "c.val3")
|
||||
|
@ -4,7 +4,8 @@ from py.test import raises
|
||||
from tiramisu.setting import owners, groups
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import IPOption, NetworkOption, NetmaskOption, IntOption,\
|
||||
SymLinkOption, OptionDescription
|
||||
BroadcastOption, SymLinkOption, OptionDescription
|
||||
from tiramisu.error import ConfigError
|
||||
|
||||
|
||||
def test_consistency_not_equal():
|
||||
@ -22,6 +23,60 @@ def test_consistency_not_equal():
|
||||
c.b = 2
|
||||
|
||||
|
||||
def test_consistency_not_equal_many_opts():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
c = IntOption('c', '')
|
||||
d = IntOption('d', '')
|
||||
e = IntOption('e', '')
|
||||
f = IntOption('f', '')
|
||||
od = OptionDescription('od', '', [a, b, c, d, e, f])
|
||||
a.impl_add_consistency('not_equal', b, c, d, e, f)
|
||||
c = Config(od)
|
||||
assert c.a is None
|
||||
assert c.b is None
|
||||
#
|
||||
c.a = 1
|
||||
del(c.a)
|
||||
#
|
||||
c.a = 1
|
||||
raises(ValueError, "c.b = 1")
|
||||
#
|
||||
c.b = 2
|
||||
raises(ValueError, "c.f = 2")
|
||||
raises(ValueError, "c.f = 1")
|
||||
#
|
||||
c.d = 3
|
||||
raises(ValueError, "c.f = 3")
|
||||
raises(ValueError, "c.a = 3")
|
||||
raises(ValueError, "c.c = 3")
|
||||
raises(ValueError, "c.e = 3")
|
||||
|
||||
|
||||
def test_consistency_not_in_config():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
od1 = OptionDescription('od1', '', [a])
|
||||
od2 = OptionDescription('od2', '', [b])
|
||||
od = OptionDescription('root', '', [od1])
|
||||
raises(ConfigError, "Config(od)")
|
||||
od = OptionDescription('root', '', [od1, od2])
|
||||
Config(od)
|
||||
#with subconfig
|
||||
raises(ConfigError, "Config(od.od1)")
|
||||
|
||||
|
||||
def test_consistency_afer_config():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
od1 = OptionDescription('od1', '', [a])
|
||||
od2 = OptionDescription('od2', '', [b])
|
||||
od = OptionDescription('root', '', [od1, od2])
|
||||
Config(od)
|
||||
raises(AttributeError, "a.impl_add_consistency('not_equal', b)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_symlink():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
@ -29,7 +84,7 @@ def test_consistency_not_equal_symlink():
|
||||
od = OptionDescription('od', '', [a, b, c])
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
c = Config(od)
|
||||
assert set(od._consistencies.keys()) == set([a, b])
|
||||
assert set(od._cache_consistencies.keys()) == set([a, b])
|
||||
|
||||
|
||||
def test_consistency_not_equal_multi():
|
||||
@ -53,6 +108,14 @@ def test_consistency_default():
|
||||
raises(ValueError, "a.impl_add_consistency('not_equal', b)")
|
||||
|
||||
|
||||
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)
|
||||
raises(ValueError, "a.impl_add_consistency('not_equal', b)")
|
||||
a.impl_add_consistency('not_equal', c)
|
||||
|
||||
|
||||
def test_consistency_default_diff():
|
||||
a = IntOption('a', '', 3)
|
||||
b = IntOption('b', '', 1)
|
||||
@ -99,7 +162,7 @@ def test_consistency_ip_netmask_error_multi():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '')
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
raises(ValueError, "b.impl_add_consistency('ip_netmask', a)")
|
||||
raises(ConfigError, "b.impl_add_consistency('ip_netmask', a)")
|
||||
|
||||
|
||||
def test_consistency_ip_netmask_multi():
|
||||
@ -159,3 +222,53 @@ def test_consistency_network_netmask_multi_master():
|
||||
c.a = ['192.168.1.0']
|
||||
c.b = ['255.255.255.0']
|
||||
raises(ValueError, "c.a = ['192.168.1.1']")
|
||||
|
||||
|
||||
def test_consistency_broadcast():
|
||||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = BroadcastOption('c', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b, c])
|
||||
od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c.impl_add_consistency('broadcast', a, b)
|
||||
c = Config(od)
|
||||
#first, test network_netmask
|
||||
c.a = ['192.168.1.128']
|
||||
raises(ValueError, "c.b = ['255.255.255.0']")
|
||||
#
|
||||
c.a = ['192.168.1.0']
|
||||
c.b = ['255.255.255.0']
|
||||
c.c = ['192.168.1.255']
|
||||
raises(ValueError, "c.a = ['192.168.1.1']")
|
||||
#
|
||||
c.a = ['192.168.1.0', '192.168.2.128']
|
||||
c.b = ['255.255.255.0', '255.255.255.128']
|
||||
c.c = ['192.168.1.255', '192.168.2.255']
|
||||
raises(ValueError, "c.c[1] = '192.168.2.128'")
|
||||
c.c[1] = '192.168.2.255'
|
||||
|
||||
|
||||
def test_consistency_broadcast_default():
|
||||
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])
|
||||
raises(ValueError, "c.impl_add_consistency('broadcast', a, b)")
|
||||
od2 = OptionDescription('a', '', [a, b, d])
|
||||
d.impl_add_consistency('broadcast', a, b)
|
||||
|
||||
|
||||
def test_consistency_not_all():
|
||||
#_cache_consistencies is not None by not options has consistencies
|
||||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = BroadcastOption('c', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b, c])
|
||||
od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c = Config(od)
|
||||
c.a = ['192.168.1.0']
|
||||
c.b = ['255.255.255.0']
|
||||
c.c = ['192.168.1.255']
|
||||
|
@ -327,23 +327,23 @@ def test_reset_properties():
|
||||
cfg = Config(descr)
|
||||
setting = cfg.cfgimpl_get_settings()
|
||||
option = cfg.cfgimpl_get_description().gc.dummy
|
||||
assert setting._p_.get_properties(cfg) == {}
|
||||
assert setting._p_.get_modified_properties() == {}
|
||||
setting.append('frozen')
|
||||
assert setting._p_.get_properties(cfg) == {None: set(('frozen', 'expire', 'cache', 'validator'))}
|
||||
assert setting._p_.get_modified_properties() == {None: set(('frozen', 'expire', 'cache', 'validator'))}
|
||||
setting.reset()
|
||||
assert setting._p_.get_properties(cfg) == {}
|
||||
assert setting._p_.get_modified_properties() == {}
|
||||
setting[option].append('test')
|
||||
assert setting._p_.get_properties(cfg) == {'gc.dummy': set(('test',))}
|
||||
assert setting._p_.get_modified_properties() == {'gc.dummy': set(('test',))}
|
||||
setting.reset()
|
||||
assert setting._p_.get_properties(cfg) == {'gc.dummy': set(('test',))}
|
||||
assert setting._p_.get_modified_properties() == {'gc.dummy': set(('test',))}
|
||||
setting.append('frozen')
|
||||
assert setting._p_.get_properties(cfg) == {None: set(('frozen', 'expire', 'validator', 'cache')), 'gc.dummy': set(('test',))}
|
||||
assert setting._p_.get_modified_properties() == {None: set(('frozen', 'expire', 'validator', 'cache')), 'gc.dummy': set(('test',))}
|
||||
setting.reset(option)
|
||||
assert setting._p_.get_properties(cfg) == {None: set(('frozen', 'expire', 'validator', 'cache'))}
|
||||
assert setting._p_.get_modified_properties() == {None: set(('frozen', 'expire', 'validator', 'cache'))}
|
||||
setting[option].append('test')
|
||||
assert setting._p_.get_properties(cfg) == {None: set(('frozen', 'expire', 'validator', 'cache')), 'gc.dummy': set(('test',))}
|
||||
assert setting._p_.get_modified_properties() == {None: set(('frozen', 'expire', 'validator', 'cache')), 'gc.dummy': set(('test',))}
|
||||
setting.reset(all_properties=True)
|
||||
assert setting._p_.get_properties(cfg) == {}
|
||||
assert setting._p_.get_modified_properties() == {}
|
||||
raises(ValueError, 'setting.reset(all_properties=True, opt=option)')
|
||||
a = descr.wantref
|
||||
setting[a].append('test')
|
||||
|
155
test/test_option_validator.py
Normal file
155
test/test_option_validator.py
Normal file
@ -0,0 +1,155 @@
|
||||
import autopath
|
||||
import warnings
|
||||
from py.test import raises
|
||||
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import StrOption, OptionDescription
|
||||
from tiramisu.setting import groups
|
||||
from tiramisu.error import ValueWarning
|
||||
|
||||
|
||||
def return_true(value, param=None):
|
||||
if value == 'val' and param in [None, 'yes']:
|
||||
return True
|
||||
|
||||
|
||||
def return_false(value, param=None):
|
||||
if value == 'val' and param in [None, 'yes']:
|
||||
raise ValueError('error')
|
||||
|
||||
|
||||
def return_val(value, param=None):
|
||||
return 'val'
|
||||
|
||||
|
||||
def return_if_val(value):
|
||||
if value != 'val':
|
||||
raise ValueError('error')
|
||||
|
||||
|
||||
def test_validator():
|
||||
opt1 = StrOption('opt1', '', validator=return_true, default='val')
|
||||
raises(ValueError, "StrOption('opt2', '', validator=return_false, default='val')")
|
||||
opt2 = StrOption('opt2', '', validator=return_false)
|
||||
root = OptionDescription('root', '', [opt1, opt2])
|
||||
cfg = Config(root)
|
||||
assert cfg.opt1 == 'val'
|
||||
raises(ValueError, "cfg.opt2 = 'val'")
|
||||
|
||||
|
||||
def test_validator_params():
|
||||
opt1 = StrOption('opt1', '', validator=return_true, validator_params={'': ('yes',)}, default='val')
|
||||
raises(ValueError, "StrOption('opt2', '', validator=return_false, validator_params={'': ('yes',)}, default='val')")
|
||||
opt2 = StrOption('opt2', '', validator=return_false, validator_params={'': ('yes',)})
|
||||
root = OptionDescription('root', '', [opt1, opt2])
|
||||
cfg = Config(root)
|
||||
assert cfg.opt1 == 'val'
|
||||
raises(ValueError, "cfg.opt2 = 'val'")
|
||||
|
||||
|
||||
def test_validator_params_key():
|
||||
opt1 = StrOption('opt1', '', validator=return_true, validator_params={'param': ('yes',)}, default='val')
|
||||
raises(TypeError, "StrOption('opt2', '', validator=return_true, validator_params={'param_unknown': ('yes',)}, default='val')")
|
||||
root = OptionDescription('root', '', [opt1])
|
||||
cfg = Config(root)
|
||||
assert cfg.opt1 == 'val'
|
||||
|
||||
|
||||
def test_validator_params_option():
|
||||
opt0 = StrOption('opt0', '', default='val')
|
||||
raises(ValueError, "opt1 = StrOption('opt1', '', validator=return_true, validator_params={'': ((opt0, False),)}, default='val')")
|
||||
|
||||
|
||||
def test_validator_multi():
|
||||
opt1 = StrOption('opt1', '', validator=return_if_val, multi=True)
|
||||
root = OptionDescription('root', '', [opt1])
|
||||
cfg = Config(root)
|
||||
assert cfg.opt1 == []
|
||||
cfg.opt1.append('val')
|
||||
assert cfg.opt1 == ['val']
|
||||
raises(ValueError, "cfg.opt1.append('val1')")
|
||||
raises(ValueError, "cfg.opt1 = ['val', 'val1']")
|
||||
|
||||
|
||||
def test_validator_warning():
|
||||
opt1 = StrOption('opt1', '', validator=return_true, default='val', warnings_only=True)
|
||||
opt2 = StrOption('opt2', '', validator=return_false, warnings_only=True)
|
||||
opt3 = StrOption('opt3', '', validator=return_if_val, multi=True, warnings_only=True)
|
||||
root = OptionDescription('root', '', [opt1, opt2, opt3])
|
||||
cfg = Config(root)
|
||||
assert cfg.opt1 == 'val'
|
||||
warnings.simplefilter("always", ValueWarning)
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.opt1 = 'val'
|
||||
assert w == []
|
||||
#
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.opt2 = 'val'
|
||||
assert len(w) == 1
|
||||
assert w[0].message.opt == opt2
|
||||
assert str(w[0].message) == 'invalid value val for option opt2: error'
|
||||
#
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.opt3.append('val')
|
||||
assert w == []
|
||||
#
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.opt3.append('val1')
|
||||
assert len(w) == 1
|
||||
assert w[0].message.opt == opt3
|
||||
assert str(w[0].message) == 'invalid value val1 for option opt3: error'
|
||||
raises(ValueError, "cfg.opt2 = 1")
|
||||
#
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.opt2 = 'val'
|
||||
cfg.opt3.append('val')
|
||||
assert len(w) == 2
|
||||
assert w[0].message.opt == opt2
|
||||
assert str(w[0].message) == 'invalid value val for option opt2: error'
|
||||
assert w[1].message.opt == opt3
|
||||
assert str(w[1].message) == 'invalid value val1 for option opt3: error'
|
||||
|
||||
|
||||
def test_validator_warning_master_slave():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True, validator=return_false, warnings_only=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-reseau", multi=True, validator=return_if_val, warnings_only=True)
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(root)
|
||||
warnings.simplefilter("always", ValueWarning)
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.ip_admin_eth0.ip_admin_eth0.append(None)
|
||||
assert w == []
|
||||
#
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.ip_admin_eth0.netmask_admin_eth0 = ['val1']
|
||||
assert len(w) == 1
|
||||
assert w[0].message.opt == netmask_admin_eth0
|
||||
assert str(w[0].message) == 'invalid value val1 for option netmask_admin_eth0: error'
|
||||
#
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.ip_admin_eth0.ip_admin_eth0 = ['val']
|
||||
assert len(w) == 1
|
||||
assert w[0].message.opt == ip_admin_eth0
|
||||
assert str(w[0].message) == 'invalid value val for option ip_admin_eth0: error'
|
||||
#
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.ip_admin_eth0.ip_admin_eth0 = ['val', 'val1', 'val1']
|
||||
assert len(w) == 1
|
||||
assert w[0].message.opt == ip_admin_eth0
|
||||
assert str(w[0].message) == 'invalid value val for option ip_admin_eth0: error'
|
||||
#
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.ip_admin_eth0.ip_admin_eth0 = ['val1', 'val', 'val1']
|
||||
assert len(w) == 1
|
||||
assert w[0].message.opt == ip_admin_eth0
|
||||
assert str(w[0].message) == 'invalid value val for option ip_admin_eth0: error'
|
||||
#
|
||||
warnings.resetwarnings()
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.ip_admin_eth0.ip_admin_eth0 = ['val1', 'val1', 'val']
|
||||
assert len(w) == 1
|
||||
assert w[0].message.opt == ip_admin_eth0
|
||||
assert str(w[0].message) == 'invalid value val for option ip_admin_eth0: error'
|
@ -64,9 +64,9 @@ def test_make_dict_filter():
|
||||
config = Config(descr)
|
||||
config.read_write()
|
||||
subresult = {'numero_etab': None, 'nombre_interfaces': 1,
|
||||
'serveur_ntp': [], 'mode_conteneur_actif': False,
|
||||
'time_zone': 'Paris', 'nom_machine': 'eoleng',
|
||||
'activer_proxy_client': False}
|
||||
'serveur_ntp': [], 'mode_conteneur_actif': False,
|
||||
'time_zone': 'Paris', 'nom_machine': 'eoleng',
|
||||
'activer_proxy_client': False}
|
||||
result = {}
|
||||
for key, value in subresult.items():
|
||||
result['general.' + key] = value
|
||||
@ -114,7 +114,6 @@ def test_iter_not_group():
|
||||
raises(TypeError, "list(config.iter_groups(group_type='family'))")
|
||||
|
||||
|
||||
|
||||
def test_groups_with_master():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
@ -252,6 +251,22 @@ def test_values_with_master_and_slaves_master():
|
||||
assert cfg.ip_admin_eth0.netmask_admin_eth0 == []
|
||||
|
||||
|
||||
def test_values_with_master_and_slaves_master_error():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
cfg.ip_admin_eth0.ip_admin_eth0 = ["192.168.230.145", "192.168.230.145"]
|
||||
raises(SlaveError, "cfg.ip_admin_eth0.netmask_admin_eth0 = ['255.255.255.0']")
|
||||
raises(SlaveError, "cfg.ip_admin_eth0.netmask_admin_eth0 = ['255.255.255.0', '255.255.255.0', '255.255.255.0']")
|
||||
cfg.ip_admin_eth0.netmask_admin_eth0 = ['255.255.255.0', '255.255.255.0']
|
||||
raises(SlaveError, "cfg.ip_admin_eth0.netmask_admin_eth0 = ['255.255.255.0']")
|
||||
raises(SlaveError, "cfg.ip_admin_eth0.netmask_admin_eth0 = ['255.255.255.0', '255.255.255.0', '255.255.255.0']")
|
||||
|
||||
|
||||
def test_values_with_master_owner():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
|
@ -1,8 +1,16 @@
|
||||
from tiramisu.option import BoolOption, UnicodeOption, SymLinkOption, \
|
||||
OptionDescription
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.setting import owners
|
||||
from tiramisu.storage import delete_session
|
||||
from tiramisu.error import ConfigError
|
||||
from pickle import dumps, loads
|
||||
|
||||
|
||||
def return_value(value=None):
|
||||
return value
|
||||
|
||||
|
||||
def _get_slots(opt):
|
||||
slots = set()
|
||||
for subclass in opt.__class__.__mro__:
|
||||
@ -32,7 +40,7 @@ def _diff_opt(opt1, opt2):
|
||||
if diff2 != set():
|
||||
raise Exception('more attribute in opt2 {0}'.format(list(diff2)))
|
||||
for attr in attr1:
|
||||
if attr in ['_cache_paths']:
|
||||
if attr in ['_cache_paths', '_cache_consistencies']:
|
||||
continue
|
||||
err1 = False
|
||||
err2 = False
|
||||
@ -64,7 +72,20 @@ def _diff_opt(opt1, opt2):
|
||||
if isinstance(val1, list):
|
||||
for index, consistency in enumerate(val1):
|
||||
assert consistency[0] == val2[index][0]
|
||||
assert consistency[1]._name == val2[index][1]._name
|
||||
for idx, opt in enumerate(consistency[1]):
|
||||
assert opt._name == val2[index][1][idx]._name
|
||||
elif attr == '_callback':
|
||||
assert val1[0] == val2[0]
|
||||
if val1[1] is not None:
|
||||
for key, values in val1[1].items():
|
||||
for idx, value in enumerate(values):
|
||||
if isinstance(value, tuple):
|
||||
assert val1[1][key][idx][0]._name == val2[1][key][idx][0]._name
|
||||
assert val1[1][key][idx][1] == val2[1][key][idx][1]
|
||||
else:
|
||||
assert val1[1][key][idx] == val2[1][key][idx]
|
||||
else:
|
||||
assert val1[1] == val2[1]
|
||||
else:
|
||||
assert val1 == val2
|
||||
|
||||
@ -104,6 +125,23 @@ def test_diff_opt_cache():
|
||||
_diff_opt(o1.o.s, q.o.s)
|
||||
|
||||
|
||||
def test_diff_opt_callback():
|
||||
b = BoolOption('b', '', callback=return_value)
|
||||
b2 = BoolOption('b2', '', callback=return_value, callback_params={'': ('yes',)})
|
||||
b3 = BoolOption('b3', '', callback=return_value, callback_params={'': ('yes', (b, False)), 'value': ('no',)})
|
||||
o = OptionDescription('o', '', [b, b2, b3])
|
||||
o1 = OptionDescription('o1', '', [o])
|
||||
o1.impl_build_cache()
|
||||
|
||||
a = dumps(o1)
|
||||
q = loads(a)
|
||||
_diff_opt(o1, q)
|
||||
_diff_opt(o1.o, q.o)
|
||||
_diff_opt(o1.o.b, q.o.b)
|
||||
_diff_opt(o1.o.b2, q.o.b2)
|
||||
_diff_opt(o1.o.b3, q.o.b3)
|
||||
|
||||
|
||||
def test_no_state_attr():
|
||||
# all _state_xxx attributes should be deleted
|
||||
b = BoolOption('b', '')
|
||||
@ -119,3 +157,95 @@ def test_no_state_attr():
|
||||
_no_state(q.o.b)
|
||||
_no_state(q.o.u)
|
||||
_no_state(q.o.s)
|
||||
|
||||
|
||||
def test_state_config():
|
||||
val1 = BoolOption('val1', "")
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
try:
|
||||
cfg = Config(maconfig, persistent=True, session_id='29090931')
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090931')
|
||||
cfg._impl_test = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opt(maconfig, q.cfgimpl_get_description())
|
||||
assert cfg.cfgimpl_get_values().get_modified_values() == q.cfgimpl_get_values().get_modified_values()
|
||||
assert cfg.cfgimpl_get_settings().get_modified_properties() == q.cfgimpl_get_settings().get_modified_properties()
|
||||
assert cfg.cfgimpl_get_settings().get_modified_permissives() == q.cfgimpl_get_settings().get_modified_permissives()
|
||||
try:
|
||||
delete_session('29090931')
|
||||
except ConfigError:
|
||||
pass
|
||||
|
||||
|
||||
def test_state_properties():
|
||||
val1 = BoolOption('val1', "")
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
try:
|
||||
cfg = Config(maconfig, persistent=True, session_id='29090932')
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090932')
|
||||
cfg._impl_test = True
|
||||
cfg.read_write()
|
||||
cfg.cfgimpl_get_settings()[val1].append('test')
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opt(maconfig, q.cfgimpl_get_description())
|
||||
assert cfg.cfgimpl_get_values().get_modified_values() == q.cfgimpl_get_values().get_modified_values()
|
||||
assert cfg.cfgimpl_get_settings().get_modified_properties() == q.cfgimpl_get_settings().get_modified_properties()
|
||||
assert cfg.cfgimpl_get_settings().get_modified_permissives() == q.cfgimpl_get_settings().get_modified_permissives()
|
||||
try:
|
||||
delete_session('29090931')
|
||||
except ConfigError:
|
||||
pass
|
||||
|
||||
|
||||
def test_state_values():
|
||||
val1 = BoolOption('val1', "")
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
try:
|
||||
cfg = Config(maconfig, persistent=True, session_id='29090933')
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090933')
|
||||
cfg._impl_test = True
|
||||
cfg.val1 = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opt(maconfig, q.cfgimpl_get_description())
|
||||
assert cfg.cfgimpl_get_values().get_modified_values() == q.cfgimpl_get_values().get_modified_values()
|
||||
assert cfg.cfgimpl_get_settings().get_modified_properties() == q.cfgimpl_get_settings().get_modified_properties()
|
||||
assert cfg.cfgimpl_get_settings().get_modified_permissives() == q.cfgimpl_get_settings().get_modified_permissives()
|
||||
q.val1 = False
|
||||
#assert cfg.val1 is True
|
||||
assert q.val1 is False
|
||||
try:
|
||||
delete_session('29090931')
|
||||
except ConfigError:
|
||||
pass
|
||||
|
||||
|
||||
def test_state_values_owner():
|
||||
val1 = BoolOption('val1', "")
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
try:
|
||||
cfg = Config(maconfig, persistent=True, session_id='29090934')
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090934')
|
||||
cfg._impl_test = True
|
||||
owners.addowner('newowner')
|
||||
cfg.cfgimpl_get_settings().setowner(owners.newowner)
|
||||
cfg.val1 = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opt(maconfig, q.cfgimpl_get_description())
|
||||
assert cfg.cfgimpl_get_values().get_modified_values() == q.cfgimpl_get_values().get_modified_values()
|
||||
assert cfg.cfgimpl_get_settings().get_modified_properties() == q.cfgimpl_get_settings().get_modified_properties()
|
||||
assert cfg.cfgimpl_get_settings().get_modified_permissives() == q.cfgimpl_get_settings().get_modified_permissives()
|
||||
q.val1 = False
|
||||
nval1 = q.cfgimpl_get_description().val1
|
||||
assert q.getowner(nval1) == owners.newowner
|
||||
try:
|
||||
delete_session('29090931')
|
||||
except ConfigError:
|
||||
pass
|
||||
|
Reference in New Issue
Block a user