coverage
This commit is contained in:
@ -202,6 +202,7 @@ def test_config_impl_get_opt_by_path():
|
||||
assert config.cfgimpl_get_description().impl_get_opt_by_path('bool') == boo
|
||||
assert config.cfgimpl_get_description().impl_get_opt_by_path('gc.dummy') == dummy
|
||||
raises(AttributeError, "config.cfgimpl_get_description().impl_get_opt_by_path('gc.unknown')")
|
||||
raises(ConfigError, "config.gc.cfgimpl_get_description().impl_get_opt_by_path('gc.unknown')")
|
||||
|
||||
|
||||
def test_information_display():
|
||||
|
@ -46,6 +46,10 @@ def return_wrong_list():
|
||||
return ['---', ' ']
|
||||
|
||||
|
||||
def return_raise():
|
||||
raise Exception('error')
|
||||
|
||||
|
||||
def test_build_dyndescription():
|
||||
st = StrOption('st', '')
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list)
|
||||
@ -57,6 +61,14 @@ def test_build_dyndescription():
|
||||
assert str(cfg.dodval2) == "stval2 = None"
|
||||
|
||||
|
||||
def test_build_dyndescription_raise():
|
||||
st = StrOption('st', '')
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_raise)
|
||||
od = OptionDescription('od', '', [dod])
|
||||
cfg = Config(od)
|
||||
raises(ConfigError, "str(cfg)")
|
||||
|
||||
|
||||
def test_subpath_dyndescription():
|
||||
st = StrOption('st', '')
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list)
|
||||
@ -221,6 +233,14 @@ def test_prop_dyndescription():
|
||||
assert str(cfg.cfgimpl_get_settings()[dodval2]) == str([])
|
||||
|
||||
|
||||
def test_prop_dyndescription_force_store_value():
|
||||
st = StrOption('st', '', properties=('force_store_value',))
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list)
|
||||
od = OptionDescription('od', '', [dod])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
raises(ConfigError, "Config(od2)")
|
||||
|
||||
|
||||
def test_callback_dyndescription():
|
||||
st = StrOption('st', '', callback=return_dynval)
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list)
|
||||
|
@ -28,6 +28,11 @@ def make_description():
|
||||
i6 = IntOption('i6', '', properties=('disabled',))
|
||||
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
return od2
|
||||
|
||||
|
||||
def make_metaconfig():
|
||||
od2 = make_description()
|
||||
conf1 = Config(od2, session_id='conf3')
|
||||
conf2 = Config(od2, session_id='conf4')
|
||||
meta = MetaConfig([conf1, conf2], session_id='meta')
|
||||
@ -40,7 +45,7 @@ def make_description():
|
||||
#FIXME ne pas mettre 2 OD differents dans un meta
|
||||
#FIXME serialization
|
||||
def test_none():
|
||||
meta = make_description()
|
||||
meta = make_metaconfig()
|
||||
conf1, conf2 = meta.cfgimpl_get_children()
|
||||
assert conf1.od1.i3 is conf2.od1.i3 is None
|
||||
assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.default
|
||||
@ -69,7 +74,7 @@ def test_none():
|
||||
|
||||
|
||||
def test_default():
|
||||
meta = make_description()
|
||||
meta = make_metaconfig()
|
||||
conf1, conf2 = meta.cfgimpl_get_children()
|
||||
assert conf1.od1.i2 == conf2.od1.i2 == 1
|
||||
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
||||
@ -98,18 +103,19 @@ def test_default():
|
||||
|
||||
|
||||
def test_contexts():
|
||||
meta = make_description()
|
||||
meta = make_metaconfig()
|
||||
conf1, conf2 = meta.cfgimpl_get_children()
|
||||
assert conf1.od1.i2 == conf2.od1.i2 == 1
|
||||
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.default
|
||||
meta.set_value('od1.i2', 6, only_config=True)
|
||||
errors = meta.set_value('od1.i2', 6, only_config=True)
|
||||
assert meta.od1.i2 == 1
|
||||
assert conf1.od1.i2 == conf2.od1.i2 == 6
|
||||
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.user
|
||||
assert len(errors) == 0
|
||||
|
||||
|
||||
def test_find():
|
||||
meta = make_description()
|
||||
meta = make_metaconfig()
|
||||
i2 = meta.unwrap_from_path('od1.i2')
|
||||
assert [i2] == meta.find(byname='i2')
|
||||
assert i2 == meta.find_first(byname='i2')
|
||||
@ -123,8 +129,11 @@ def test_group_error():
|
||||
|
||||
|
||||
def test_meta_meta():
|
||||
meta1 = make_description()
|
||||
meta1 = make_metaconfig()
|
||||
meta2 = MetaConfig([meta1])
|
||||
assert str(meta1) == """(conf3)
|
||||
(conf4)
|
||||
[od1]"""
|
||||
meta2.cfgimpl_get_settings().setowner(owners.meta)
|
||||
conf1, conf2 = meta1.cfgimpl_get_children()
|
||||
assert conf1.od1.i2 == conf2.od1.i2 == 1
|
||||
@ -156,14 +165,38 @@ def test_meta_meta():
|
||||
assert conf1.getowner(conf1.unwrap_from_path('od1.i2')) is conf2.getowner(conf2.unwrap_from_path('od1.i2')) is owners.meta
|
||||
|
||||
|
||||
def test_meta_config_name():
|
||||
od = make_description()
|
||||
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
||||
assert len(meta.cfgimpl_get_children()) == 2
|
||||
assert meta.name1
|
||||
assert meta.name2
|
||||
|
||||
|
||||
def test_meta_new_config():
|
||||
meta = make_metaconfig()
|
||||
assert len(meta.cfgimpl_get_children()) == 2
|
||||
meta.new_config('newconf1')
|
||||
assert len(meta.cfgimpl_get_children()) == 3
|
||||
|
||||
|
||||
def test_meta_new_config_wrong_name():
|
||||
meta = make_metaconfig()
|
||||
assert len(meta.cfgimpl_get_children()) == 2
|
||||
raises(ConflictError, "meta.new_config('conf4')")
|
||||
assert len(meta.cfgimpl_get_children()) == 2
|
||||
|
||||
|
||||
def test_meta_meta_set():
|
||||
meta1 = make_description()
|
||||
meta1 = make_metaconfig()
|
||||
meta2 = MetaConfig([meta1])
|
||||
meta2.cfgimpl_get_settings().setowner(owners.meta)
|
||||
meta2.read_write()
|
||||
conf1, conf2 = meta1.cfgimpl_get_children()
|
||||
meta2.set_value('od1.i1', 7, only_config=True)
|
||||
meta2.set_value('od1.i6', 7, only_config=True)
|
||||
errors1 = meta2.set_value('od1.i1', 7, only_config=True)
|
||||
errors2 = meta2.set_value('od1.i6', 7, only_config=True)
|
||||
assert len(errors1) == 0
|
||||
assert len(errors2) == 2
|
||||
assert conf1.od1.i1 == conf2.od1.i1 == 7
|
||||
assert conf1.getowner(conf1.unwrap_from_path('od1.i1')) is conf2.getowner(conf2.unwrap_from_path('od1.i1')) is owners.user
|
||||
assert [conf1, conf2] == meta2.find_firsts(byname='i1', byvalue=7).cfgimpl_get_children()
|
||||
@ -189,7 +222,7 @@ def test_not_meta():
|
||||
conf3 = Config(od2)
|
||||
try:
|
||||
conf4 = Config(od2, session_id='conf2')
|
||||
except ValueError:
|
||||
except ConflictError:
|
||||
pass
|
||||
else:
|
||||
conf3, conf4
|
||||
@ -199,7 +232,8 @@ def test_not_meta():
|
||||
grp = GroupConfig([conf1, conf2])
|
||||
raises(ConfigError, 'grp.od1.i1')
|
||||
conf1, conf2 = grp.cfgimpl_get_children()
|
||||
grp.set_value('od1.i1', 7)
|
||||
errors = grp.set_value('od1.i1', 7)
|
||||
assert len(errors) == 0
|
||||
assert grp.conf1.od1.i1 == conf2.od1.i1 == 7
|
||||
assert grp.conf1.getowner(grp.conf1.unwrap_from_path('od1.i1')) is grp.conf2.getowner(grp.conf2.unwrap_from_path('od1.i1')) is owners.user
|
||||
|
||||
@ -211,6 +245,9 @@ def test_group_find_firsts():
|
||||
conf1 = Config(od2, session_id='conf1')
|
||||
conf2 = Config(od2, session_id='conf2')
|
||||
grp = GroupConfig([conf1, conf2])
|
||||
assert str(grp) == """(conf1)
|
||||
(conf2)
|
||||
"""
|
||||
assert [conf1, conf2] == grp.find_firsts(byname='i1').cfgimpl_get_children()
|
||||
|
||||
|
||||
@ -222,13 +259,14 @@ def test_group_group():
|
||||
conf2 = Config(od2, session_id='conf10')
|
||||
grp = GroupConfig([conf1, conf2], 'grp')
|
||||
grp2 = GroupConfig([grp])
|
||||
grp2.set_value('od1.i1', 2)
|
||||
errors = grp2.set_value('od1.i1', 2)
|
||||
assert grp2.grp.conf9.od1.i1 == 2
|
||||
assert grp2.grp.conf9.getowner(i1) == owners.user
|
||||
assert len(errors) == 0
|
||||
|
||||
|
||||
def test_meta_path():
|
||||
meta = make_description()
|
||||
meta = make_metaconfig()
|
||||
assert meta._impl_path is None
|
||||
assert meta.od1._impl_path == 'od1'
|
||||
|
||||
@ -265,6 +303,7 @@ def test_meta_master_slaves():
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_only()
|
||||
assert [conf1, conf2] == meta.find_firsts(byname='ip_admin_eth0').cfgimpl_get_children()
|
||||
assert [conf1, conf2] == meta.find_firsts(byname='netmask_admin_eth0').cfgimpl_get_children()
|
||||
meta.read_write()
|
||||
raises(AttributeError, "meta.find_firsts(byname='netmask_admin_eth0')")
|
||||
@ -361,19 +400,22 @@ def test_meta_force_default():
|
||||
assert meta.ip_admin_eth0 == []
|
||||
assert meta.conf1.ip_admin_eth0 == []
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
meta.set_value('ip_admin_eth0', ['192.168.1.1'])
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.1'])
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.1']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.1']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.1']
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.2']
|
||||
errors = meta.conf1.ip_admin_eth0 = ['192.168.1.2']
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.1']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.2']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.1']
|
||||
meta.set_value('ip_admin_eth0', ['192.168.1.3'])
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.3'])
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.3']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.2']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.3']
|
||||
meta.set_value('ip_admin_eth0', ['192.168.1.4'], force_default=True)
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.4'], force_default=True)
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.4']
|
||||
@ -399,7 +441,8 @@ def test_meta_force_dont_change_value():
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
assert conf1.getowner(ip_admin_eth0) is owners.user
|
||||
assert conf2.getowner(ip_admin_eth0) is owners.default
|
||||
meta.set_value('ip_admin_eth0', ['192.168.1.4'], force_dont_change_value=True)
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.4'], force_dont_change_value=True)
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
@ -429,7 +472,8 @@ def test_meta_force_default_if_same():
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
assert conf1.getowner(ip_admin_eth0) is owners.user
|
||||
assert conf2.getowner(ip_admin_eth0) is owners.default
|
||||
meta.set_value('ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True)
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True)
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.4']
|
||||
@ -441,7 +485,8 @@ def test_meta_force_default_if_same():
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert conf1.getowner(ip_admin_eth0) is owners.user
|
||||
assert conf2.getowner(ip_admin_eth0) is owners.meta
|
||||
meta.set_value('ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True)
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True)
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.5']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.3']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.5']
|
||||
@ -471,7 +516,8 @@ def test_meta_force_default_if_same_and_dont_change():
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
assert conf1.getowner(ip_admin_eth0) is owners.user
|
||||
assert conf2.getowner(ip_admin_eth0) is owners.default
|
||||
meta.set_value('ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True, force_dont_change_value=True)
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True, force_dont_change_value=True)
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
@ -483,7 +529,8 @@ def test_meta_force_default_if_same_and_dont_change():
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
assert conf1.getowner(ip_admin_eth0) is owners.user
|
||||
assert conf2.getowner(ip_admin_eth0) is owners.user
|
||||
meta.set_value('ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True, force_dont_change_value=True)
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True, force_dont_change_value=True)
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.5']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.3']
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
@ -640,3 +687,33 @@ def test_meta_properties_meta_set_value():
|
||||
ret = meta.set_value('ip_admin_eth0', '255.255.255.255', force_default_if_same=True)
|
||||
assert len(ret) == 1
|
||||
assert isinstance(ret[0], ValueError)
|
||||
|
||||
|
||||
def test_meta_reset():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||
assert meta.ip_admin_eth0 == []
|
||||
assert meta.conf1.ip_admin_eth0 == []
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.1'])
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.1']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.1']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.1']
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.2']
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.1']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.2']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.1']
|
||||
meta.reset('ip_admin_eth0')
|
||||
assert meta.ip_admin_eth0 == []
|
||||
assert meta.conf1.ip_admin_eth0 == []
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
|
@ -215,7 +215,6 @@ def test_consistency_not_equal_submulti():
|
||||
a = IntOption('a', '', multi=submulti)
|
||||
b = IntOption('b', '', multi=submulti)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
raises(ConfigError, 'a.impl_add_consistency("not_equal", b)')
|
||||
|
||||
|
||||
@ -250,6 +249,42 @@ def test_consistency_not_equal_masterslave():
|
||||
raises(ValueError, "c.b[1] = 3")
|
||||
|
||||
|
||||
def test_consistency_not_equal_masterslave_error_multi1():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = NetmaskOption('c', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od2 = OptionDescription('b', '', [od, c])
|
||||
c.impl_add_consistency('ip_netmask', a)
|
||||
raises(ConfigError, "Config(od2)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_masterslave_error_multi2():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = IPOption('c', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od2 = OptionDescription('b', '', [od, c])
|
||||
b.impl_add_consistency('ip_netmask', c)
|
||||
raises(ConfigError, "Config(od2)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_masterslave_error_othermaster():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = IPOption('c', '', multi=True)
|
||||
d = NetmaskOption('d', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od2 = OptionDescription('c', '', [c, d])
|
||||
od2.impl_set_group_type(groups.master)
|
||||
od3 = OptionDescription('b', '', [od, od2])
|
||||
d.impl_add_consistency('ip_netmask', a)
|
||||
raises(ConfigError, "Config(od2)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_masterslaves_default():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True, default_multi=1)
|
||||
|
@ -5,7 +5,7 @@ do_autopath()
|
||||
from py.test import raises
|
||||
|
||||
from tiramisu.i18n import _
|
||||
from tiramisu.error import display_list
|
||||
from tiramisu.error import display_list, ConfigError
|
||||
from tiramisu.setting import owners, groups
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
@ -431,8 +431,11 @@ def test_append_properties():
|
||||
assert tuple(option._properties) == tuple()
|
||||
assert not 'test' in setting[option]
|
||||
setting[option].append('test')
|
||||
raises(ConfigError, "setting[option].append('force_store_value')")
|
||||
raises(ConfigError, "setting.append('force_store_value')")
|
||||
assert tuple(option._properties) == tuple()
|
||||
assert 'test' in setting[option]
|
||||
assert setting[option].get() == ('test',)
|
||||
|
||||
|
||||
def test_reset_properties():
|
||||
|
@ -154,6 +154,65 @@ def test_permissive_option():
|
||||
assert props == ['disabled']
|
||||
|
||||
|
||||
def test_permissive_option_cache():
|
||||
descr = make_description()
|
||||
u1 = descr.u1
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.read_write()
|
||||
setting.remove('expire')
|
||||
|
||||
props = []
|
||||
try:
|
||||
config.u1
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
props = []
|
||||
try:
|
||||
config.u2
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
|
||||
setting.setpermissive(('disabled',), u1)
|
||||
props = []
|
||||
try:
|
||||
config.u1
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == []
|
||||
props = []
|
||||
try:
|
||||
config.u2
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
|
||||
setting.append('permissive')
|
||||
config.u1
|
||||
props = []
|
||||
try:
|
||||
config.u2
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
|
||||
setting.remove('permissive')
|
||||
props = []
|
||||
try:
|
||||
config.u1
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == []
|
||||
props = []
|
||||
try:
|
||||
config.u2
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
|
||||
|
||||
def test_permissive_option_mandatory():
|
||||
descr = make_description()
|
||||
u1 = descr.u1
|
||||
|
@ -324,6 +324,30 @@ def test_requires_transitive_hidden_disabled():
|
||||
raises(RequirementError, 'c.ip_address_service_web')
|
||||
|
||||
|
||||
def test_requires_transitive_hidden_disabled_multiple():
|
||||
a = BoolOption('activate_service', '', True)
|
||||
b = BoolOption('activate_service_web', '', True,
|
||||
requires=[{'option': a, 'expected': False, 'action': 'hidden'},
|
||||
{'option': a, 'expected': False, 'action': 'disabled'}])
|
||||
d = IPOption('ip_address_service_web', '',
|
||||
requires=[{'option': b, 'expected': False, 'action': 'mandatory'}])
|
||||
od = OptionDescription('service', '', [a, b, d])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
c.activate_service
|
||||
c.activate_service_web
|
||||
c.ip_address_service_web
|
||||
c.activate_service = False
|
||||
#
|
||||
props = []
|
||||
try:
|
||||
c.activate_service_web
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert set(props) == {'disabled', 'hidden'}
|
||||
raises(RequirementError, 'c.ip_address_service_web')
|
||||
|
||||
|
||||
def test_requires_not_transitive():
|
||||
a = BoolOption('activate_service', '', True)
|
||||
b = BoolOption('activate_service_web', '', True,
|
||||
|
Reference in New Issue
Block a user