better validation with parent + deepconfig
This commit is contained in:
@ -745,6 +745,22 @@ def test_meta_exception_meta():
|
||||
raises(Exception, "conf1.make_dict()")
|
||||
|
||||
|
||||
def test_meta_properties_requires1():
|
||||
opt1 = BoolOption('opt1', 'opt1', False)
|
||||
opt2 = BoolOption('opt2', "")
|
||||
od2 = OptionDescription('od2', "", [opt2], requires=({'option': opt1, 'expected': False, 'action': 'disabled'},))
|
||||
opt3 = BoolOption('opt3', '')
|
||||
opt2.impl_add_consistency('not_equal', opt3)
|
||||
od = OptionDescription('root', '', [opt1, od2, opt3])
|
||||
conf1 = Config(od, session_id='conf1')
|
||||
conf1.property.read_write()
|
||||
meta = MetaConfig([conf1], 'meta')
|
||||
meta.property.read_write()
|
||||
meta.option('opt1').value.set(True)
|
||||
#
|
||||
conf1.option('od2.opt2').value.set(False)
|
||||
|
||||
|
||||
def test_meta_properties_requires_mandatory():
|
||||
probes = BoolOption('probes', 'probes available', False)
|
||||
eth0_method = ChoiceOption('eth0_method', '', ('static', 'dhcp'), 'static')
|
||||
|
@ -1,4 +1,6 @@
|
||||
from tiramisu import IntOption, OptionDescription, MetaConfig
|
||||
from tiramisu.error import ConfigError
|
||||
from pytest import raises
|
||||
|
||||
|
||||
def make_metaconfig():
|
||||
@ -28,6 +30,36 @@ def test_multi_parents_path():
|
||||
assert cfg1.config.path() == 'metacfg2.metacfg1.cfg1'
|
||||
|
||||
|
||||
def test_multi_parents_path_same():
|
||||
"""
|
||||
--- metacfg2 (1) ---
|
||||
metacfg1 --| | -- cfg1
|
||||
--- metacfg3 (2) ---
|
||||
"""
|
||||
metacfg1 = make_metaconfig()
|
||||
metacfg2 = metacfg1.config.new(type='metaconfig', session_id="metacfg2")
|
||||
metacfg3 = metacfg1.config.new(type='metaconfig', session_id="metacfg3")
|
||||
cfg1 = metacfg2.config.new(type='config', session_id="cfg1")
|
||||
metacfg3.config.add(cfg1)
|
||||
#
|
||||
assert metacfg2.config.path() == 'metacfg1.metacfg2'
|
||||
assert metacfg3.config.path() == 'metacfg1.metacfg3'
|
||||
assert cfg1.config.path() == 'metacfg1.metacfg3.metacfg1.metacfg2.cfg1'
|
||||
orideep = cfg1.config.deepcopy(metaconfig_prefix="test_", session_id='test_cfg1')
|
||||
deep = orideep
|
||||
while True:
|
||||
try:
|
||||
children = list(deep.config.list())
|
||||
except:
|
||||
break
|
||||
assert len(children) < 2
|
||||
deep = children[0]
|
||||
assert deep.config.path() == 'test_metacfg3.test_metacfg1.test_metacfg2.test_cfg1'
|
||||
del orideep
|
||||
raises(ConfigError, "deep.config.path()")
|
||||
|
||||
|
||||
|
||||
def test_multi_parents_value():
|
||||
metacfg1 = make_metaconfig()
|
||||
cfg1 = metacfg1.config.new(type='config', session_id="cfg1")
|
||||
|
Reference in New Issue
Block a user