add multi parents tests
This commit is contained in:
parent
b6ec77aa23
commit
a9ca9fdb6a
56
tests/test_multi_parents.py
Normal file
56
tests/test_multi_parents.py
Normal file
@ -0,0 +1,56 @@
|
||||
from tiramisu import IntOption, OptionDescription, MetaConfig
|
||||
|
||||
|
||||
def make_metaconfig():
|
||||
i1 = IntOption('i1', '')
|
||||
i2 = IntOption('i2', '', default=1)
|
||||
i3 = IntOption('i3', '')
|
||||
i4 = IntOption('i4', '', default=2)
|
||||
i5 = IntOption('i5', '', default=[2], multi=True)
|
||||
i6 = IntOption('i6', '', properties=('disabled',))
|
||||
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
return MetaConfig([], optiondescription=od2, session_id='metacfg1')
|
||||
|
||||
|
||||
def test_multi_parents_path():
|
||||
"""
|
||||
metacfg1 (1) ---
|
||||
| -- cfg1
|
||||
metacfg2 (2) ---
|
||||
"""
|
||||
metacfg1 = make_metaconfig()
|
||||
cfg1 = metacfg1.config.new(type='config', session_id="cfg1")
|
||||
metacfg2 = MetaConfig([cfg1], session_id='metacfg2')
|
||||
#
|
||||
assert metacfg1.config.path() == 'metacfg1'
|
||||
assert metacfg2.config.path() == 'metacfg2'
|
||||
assert cfg1.config.path() == 'metacfg2.metacfg1.cfg1'
|
||||
|
||||
|
||||
def test_multi_parents_value():
|
||||
metacfg1 = make_metaconfig()
|
||||
cfg1 = metacfg1.config.new(type='config', session_id="cfg1")
|
||||
metacfg2 = MetaConfig([cfg1], session_id='metacfg2')
|
||||
#
|
||||
assert cfg1.option('od1.i1').value.get() == None
|
||||
assert cfg1.option('od1.i2').value.get() == 1
|
||||
assert cfg1.option('od1.i3').value.get() == None
|
||||
#
|
||||
assert metacfg1.option('od1.i1').value.get() == None
|
||||
assert metacfg1.option('od1.i2').value.get() == 1
|
||||
assert metacfg1.option('od1.i3').value.get() == None
|
||||
#
|
||||
assert metacfg2.option('od1.i1').value.get() == None
|
||||
assert metacfg2.option('od1.i2').value.get() == 1
|
||||
assert metacfg2.option('od1.i3').value.get() == None
|
||||
#
|
||||
metacfg1.option('od1.i3').value.set(3)
|
||||
assert metacfg1.option('od1.i3').value.get() == 3
|
||||
assert cfg1.option('od1.i3').value.get() == 3
|
||||
assert metacfg2.option('od1.i2').value.get() == 1
|
||||
#
|
||||
metacfg2.option('od1.i2').value.set(4)
|
||||
assert metacfg2.option('od1.i2').value.get() == 4
|
||||
assert metacfg1.option('od1.i2').value.get() == 1
|
||||
assert cfg1.option('od1.i2').value.get() == 4
|
Loading…
Reference in New Issue
Block a user