From 73c8db5839d64b02a77d2c8779133748707dd7a9 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 17 Nov 2023 22:39:33 +0100 Subject: [PATCH] do not add suffix for suboption in dynamic optiondescription --- tests/test_dyn_optiondescription.py | 1394 ++++++++++---------- tests/test_mandatory.py | 4 +- tiramisu/config.py | 55 +- tiramisu/option/dynoptiondescription.py | 30 +- tiramisu/option/optiondescription.py | 21 +- tiramisu/option/syndynoption.py | 3 +- tiramisu/option/syndynoptiondescription.py | 23 +- tiramisu/value.py | 7 +- 8 files changed, 760 insertions(+), 777 deletions(-) diff --git a/tests/test_dyn_optiondescription.py b/tests/test_dyn_optiondescription.py index d03a2d4..5c1f29c 100644 --- a/tests/test_dyn_optiondescription.py +++ b/tests/test_dyn_optiondescription.py @@ -67,9 +67,9 @@ def test_build_dyndescription(): dod = DynOptionDescription('dod', '', [st1], suffixes=Calculation(return_list)) od1 = OptionDescription('od', '', [dod]) cfg = Config(od1) - assert cfg.value.dict() == {'dodval1.stval1': None, 'dodval2.stval2': None} + assert cfg.value.get() == {'dodval1.st': None, 'dodval2.st': None} assert cfg.option('dodval1').isdynamic() - assert cfg.option('dodval1.stval1').isdynamic() + assert cfg.option('dodval1.st').isdynamic() # assert not list_sessions() @@ -78,7 +78,7 @@ def test_build_dyndescription_with_int(): dod = DynOptionDescription('dod', '', [int1], suffixes=Calculation(return_list, Params(ParamValue([1, 2])))) od1 = OptionDescription('od', '', [dod]) cfg = Config(od1) - assert cfg.value.dict() == {'dod1.int1': 1, 'dod2.int2': 2} + assert cfg.value.get() == {'dod1.int': 1, 'dod2.int': 2} # assert not list_sessions() @@ -87,7 +87,7 @@ def test_build_dyndescription_with_dot(): dod = DynOptionDescription('dod', '', [st1], suffixes=Calculation(return_list_dot)) od1 = OptionDescription('od', '', [dod]) cfg = Config(od1) - assert cfg.value.dict() == {'dodval_1.stval_1': 'val.1', 'dodval_2.stval_2': 'val.2'} + assert cfg.value.get() == {'dodval_1.st': 'val.1', 'dodval_2.st': 'val.2'} # assert not list_sessions() @@ -97,7 +97,7 @@ def test_build_dyndescription_raise(): od1 = OptionDescription('od', '', [dod]) cfg = Config(od1) with pytest.raises(ConfigError): - cfg.value.dict() + cfg.value.get() # assert not list_sessions() @@ -107,7 +107,7 @@ def test_build_dyndescription_not_list(): od1 = OptionDescription('od', '', [dod]) cfg = Config(od1) with pytest.raises(ValueError): - cfg.value.dict() + cfg.value.get() # assert not list_sessions() @@ -117,7 +117,7 @@ def test_subpath_dyndescription(): od1 = OptionDescription('od', '', [dod]) od2 = OptionDescription('od', '', [od1]) cfg = Config(od2) - assert cfg.value.dict() == {'od.dodval1.stval1': None, 'od.dodval2.stval2': None} + assert cfg.value.get() == {'od.dodval1.st': None, 'od.dodval2.st': None} # assert not list_sessions() @@ -127,8 +127,8 @@ def test_list_dyndescription(): od = OptionDescription('od', '', [dod]) od2 = OptionDescription('od', '', [od]) cfg = Config(od2) - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None # assert not list_sessions() @@ -155,12 +155,12 @@ def test_getdoc_dyndescription(): od1 = OptionDescription('od', '', [dod]) od2 = OptionDescription('od', '', [od1]) cfg = Config(od2) - assert cfg.option('od.dodval1.stval1').name() == 'stval1' - assert cfg.option('od.dodval2.stval2').name() == 'stval2' + assert cfg.option('od.dodval1.st').name() == 'st' + assert cfg.option('od.dodval2.st').name() == 'st' assert cfg.option('od.dodval1').name() == 'dodval1' assert cfg.option('od.dodval2').name() == 'dodval2' - assert cfg.option('od.dodval1.stval1').doc() == 'doc1val1' - assert cfg.option('od.dodval2.stval2').doc() == 'doc1val2' + assert cfg.option('od.dodval1.st').doc() == 'doc1val1' + assert cfg.option('od.dodval2.st').doc() == 'doc1val2' assert cfg.option('od.dodval1').doc() == 'doc2val1' assert cfg.option('od.dodval2').doc() == 'doc2val2' # assert not list_sessions() @@ -174,22 +174,22 @@ def test_mod_dyndescription(): cfg = Config(od2) owner = cfg.owner.get() # - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None - assert cfg.option('od.dodval1.stval1').owner.isdefault() - assert cfg.option('od.dodval2.stval2').owner.isdefault() + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None + assert cfg.option('od.dodval1.st').owner.isdefault() + assert cfg.option('od.dodval2.st').owner.isdefault() # - cfg.option('od.dodval1.stval1').value.set('yes') - assert cfg.option('od.dodval1.stval1').value.get() == 'yes' - assert cfg.option('od.dodval2.stval2').value.get() is None - assert cfg.option('od.dodval1.stval1').owner.get() == owner - assert cfg.option('od.dodval2.stval2').owner.isdefault() + cfg.option('od.dodval1.st').value.set('yes') + assert cfg.option('od.dodval1.st').value.get() == 'yes' + assert cfg.option('od.dodval2.st').value.get() is None + assert cfg.option('od.dodval1.st').owner.get() == owner + assert cfg.option('od.dodval2.st').owner.isdefault() # - cfg.option('od.dodval2.stval2').value.set('no') - assert cfg.option('od.dodval1.stval1').value.get() == 'yes' - assert cfg.option('od.dodval2.stval2').value.get() == 'no' - assert cfg.option('od.dodval1.stval1').owner.get() == owner - assert cfg.option('od.dodval2.stval2').owner.get() == owner + cfg.option('od.dodval2.st').value.set('no') + assert cfg.option('od.dodval1.st').value.get() == 'yes' + assert cfg.option('od.dodval2.st').value.get() == 'no' + assert cfg.option('od.dodval1.st').owner.get() == owner + assert cfg.option('od.dodval2.st').owner.get() == owner # assert not list_sessions() @@ -200,12 +200,12 @@ def test_del_dyndescription(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) owner = cfg.owner.get() - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None - cfg.option('od.dodval1.stval1').value.set('yes') - assert cfg.option('od.dodval1.stval1').owner.get() == owner - cfg.option('od.dodval1.stval1').value.reset() - assert cfg.option('od.dodval1.stval1').owner.isdefault() + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None + cfg.option('od.dodval1.st').value.set('yes') + assert cfg.option('od.dodval1.st').owner.get() == owner + cfg.option('od.dodval1.st').value.reset() + assert cfg.option('od.dodval1.st').owner.isdefault() # assert not list_sessions() @@ -216,24 +216,24 @@ def test_multi_dyndescription(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) owner = cfg.owner.get() - assert cfg.option('od.dodval1.stval1').value.get() == [] - assert cfg.option('od.dodval2.stval2').value.get() == [] - assert cfg.option('od.dodval1.stval1').owner.isdefault() - assert cfg.option('od.dodval2.stval2').owner.isdefault() - cfg.option('od.dodval1.stval1').value.set(['yes']) - assert cfg.option('od.dodval1.stval1').value.get() == ['yes'] - assert cfg.option('od.dodval2.stval2').value.get() == [] - assert cfg.option('od.dodval1.stval1').owner.get() == owner - assert cfg.option('od.dodval2.stval2').owner.isdefault() - cfg.option('od.dodval2.stval2').value.set(['no']) - assert cfg.option('od.dodval1.stval1').value.get() == ['yes'] - assert cfg.option('od.dodval2.stval2').value.get() == ['no'] - assert cfg.option('od.dodval1.stval1').owner.get() == owner - assert cfg.option('od.dodval2.stval2').owner.get() == owner - cfg.option('od.dodval1.stval1').value.set(['yes', 'no']) - assert cfg.option('od.dodval1.stval1').value.get() == ['yes', 'no'] - cfg.option('od.dodval1.stval1').value.set(['yes']) - assert cfg.option('od.dodval1.stval1').value.get() == ['yes'] + assert cfg.option('od.dodval1.st').value.get() == [] + assert cfg.option('od.dodval2.st').value.get() == [] + assert cfg.option('od.dodval1.st').owner.isdefault() + assert cfg.option('od.dodval2.st').owner.isdefault() + cfg.option('od.dodval1.st').value.set(['yes']) + assert cfg.option('od.dodval1.st').value.get() == ['yes'] + assert cfg.option('od.dodval2.st').value.get() == [] + assert cfg.option('od.dodval1.st').owner.get() == owner + assert cfg.option('od.dodval2.st').owner.isdefault() + cfg.option('od.dodval2.st').value.set(['no']) + assert cfg.option('od.dodval1.st').value.get() == ['yes'] + assert cfg.option('od.dodval2.st').value.get() == ['no'] + assert cfg.option('od.dodval1.st').owner.get() == owner + assert cfg.option('od.dodval2.st').owner.get() == owner + cfg.option('od.dodval1.st').value.set(['yes', 'no']) + assert cfg.option('od.dodval1.st').value.get() == ['yes', 'no'] + cfg.option('od.dodval1.st').value.set(['yes']) + assert cfg.option('od.dodval1.st').value.get() == ['yes'] # assert not list_sessions() @@ -243,13 +243,13 @@ def test_prop_dyndescription(): od = OptionDescription('od', '', [dod]) od2 = OptionDescription('od', '', [od]) cfg = Config(od2) - assert set(cfg.option('od.dodval1.stval1').property.get()) == set(['test']) - assert set(cfg.option('od.dodval2.stval2').property.get()) == set(['test']) - cfg.option('od.dodval2.stval2').property.add('test2') - assert set(cfg.option('od.dodval1.stval1').property.get()) == set(['test']) - assert set(cfg.option('od.dodval2.stval2').property.get()) == set(['test', 'test2']) - cfg.option('od.dodval1.stval1').property.remove('test') - assert set(cfg.option('od.dodval1.stval1').property.get()) == set([]) + assert set(cfg.option('od.dodval1.st').property.get()) == set(['test']) + assert set(cfg.option('od.dodval2.st').property.get()) == set(['test']) + cfg.option('od.dodval2.st').property.add('test2') + assert set(cfg.option('od.dodval1.st').property.get()) == set(['test']) + assert set(cfg.option('od.dodval2.st').property.get()) == set(['test', 'test2']) + cfg.option('od.dodval1.st').property.remove('test') + assert set(cfg.option('od.dodval1.st').property.get()) == set([]) # assert set(cfg.option('od.dodval1').property.get()) == set([]) assert set(cfg.option('od.dodval2').property.get()) == set([]) @@ -269,7 +269,7 @@ def test_prop_dyndescription_force_store_value(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) cfg.property.read_write() - assert cfg.value.dict() == {'od.dodval1.stval1': None, 'od.dodval2.stval2': None} + assert cfg.value.get() == {'od.dodval1.st': None, 'od.dodval2.st': None} # assert not list_sessions() @@ -281,15 +281,15 @@ def test_prop_dyndescription_force_store_value_calculation_prefix(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) cfg.property.read_write() - assert cfg.option('od.dodval1.stval1').owner.isdefault() == False - assert cfg.option('od.dodval2.stval2').owner.isdefault() == False - assert cfg.value.dict() == {'od.lst': ['val1', 'val2'], 'od.dodval1.stval1': 'val1', 'od.dodval2.stval2': 'val2'} + assert cfg.option('od.dodval1.st').owner.isdefault() == False + assert cfg.option('od.dodval2.st').owner.isdefault() == False + assert cfg.value.get() == {'od.lst': ['val1', 'val2'], 'od.dodval1.st': 'val1', 'od.dodval2.st': 'val2'} # cfg.option('od.lst').value.set(['val1', 'val2', 'val3']) - assert cfg.option('od.dodval3.stval3').owner.isdefault() == False - assert cfg.option('od.dodval1.stval1').owner.isdefault() == False - assert cfg.option('od.dodval2.stval2').owner.isdefault() == False - assert cfg.value.dict() == {'od.lst': ['val1', 'val2', 'val3'], 'od.dodval1.stval1': 'val1', 'od.dodval2.stval2': 'val2', 'od.dodval3.stval3': 'val3'} + assert cfg.option('od.dodval3.st').owner.isdefault() == False + assert cfg.option('od.dodval1.st').owner.isdefault() == False + assert cfg.option('od.dodval2.st').owner.isdefault() == False + assert cfg.value.get() == {'od.lst': ['val1', 'val2', 'val3'], 'od.dodval1.st': 'val1', 'od.dodval2.st': 'val2', 'od.dodval3.st': 'val3'} # assert not list_sessions() @@ -301,20 +301,20 @@ def test_callback_dyndescription(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) owner = cfg.owner.get() - assert cfg.option('od.dodval1.stval1').value.get() == 'val' - assert cfg.option('od.dodval2.stval2').value.get() == 'val' - assert cfg.option('od.dodval1.stval1').owner.isdefault() - assert cfg.option('od.dodval2.stval2').owner.isdefault() - cfg.option('od.dodval1.stval1').value.set('val2') - assert cfg.option('od.dodval1.stval1').value.get() == 'val2' - assert cfg.option('od.dodval2.stval2').value.get() == 'val' - assert cfg.option('od.dodval1.stval1').owner.get() == owner - assert cfg.option('od.dodval2.stval2').owner.isdefault() - cfg.option('od.dodval1.stval1').value.reset() - assert cfg.option('od.dodval1.stval1').value.get() == 'val' - assert cfg.option('od.dodval2.stval2').value.get() == 'val' - assert cfg.option('od.dodval1.stval1').owner.isdefault() - assert cfg.option('od.dodval2.stval2').owner.isdefault() + assert cfg.option('od.dodval1.st').value.get() == 'val' + assert cfg.option('od.dodval2.st').value.get() == 'val' + assert cfg.option('od.dodval1.st').owner.isdefault() + assert cfg.option('od.dodval2.st').owner.isdefault() + cfg.option('od.dodval1.st').value.set('val2') + assert cfg.option('od.dodval1.st').value.get() == 'val2' + assert cfg.option('od.dodval2.st').value.get() == 'val' + assert cfg.option('od.dodval1.st').owner.get() == owner + assert cfg.option('od.dodval2.st').owner.isdefault() + cfg.option('od.dodval1.st').value.reset() + assert cfg.option('od.dodval1.st').value.get() == 'val' + assert cfg.option('od.dodval2.st').value.get() == 'val' + assert cfg.option('od.dodval1.st').owner.isdefault() + assert cfg.option('od.dodval2.st').owner.isdefault() # assert not list_sessions() @@ -327,7 +327,7 @@ def test_callback_dyndescription_outside_wrong_param(): od2 = OptionDescription('od', '', [od, lst]) cfg = Config(od2) with pytest.raises(ValueOptionError): - cfg.value.dict() + cfg.value.get() # assert not list_sessions() @@ -339,15 +339,15 @@ def test_callback_dyndescription_outside1(): od = OptionDescription('od', '', [dod, out]) od2 = OptionDescription('od', '', [od, lst]) cfg = Config(od2) - assert cfg.value.dict() == {'od.dodval1.stval1': 'val', 'od.dodval2.stval2': 'val', 'od.out': 'val', 'lst': ['val1', 'val2']} - cfg.option('od.dodval1.stval1').value.set('val1') - cfg.option('od.dodval2.stval2').value.set('val2') - assert cfg.value.dict() == {'od.dodval1.stval1': 'val1', 'od.dodval2.stval2': 'val2', 'od.out': 'val1', 'lst': ['val1', 'val2']} + assert cfg.value.get() == {'od.dodval1.st': 'val', 'od.dodval2.st': 'val', 'od.out': 'val', 'lst': ['val1', 'val2']} + cfg.option('od.dodval1.st').value.set('val1') + cfg.option('od.dodval2.st').value.set('val2') + assert cfg.value.get() == {'od.dodval1.st': 'val1', 'od.dodval2.st': 'val2', 'od.out': 'val1', 'lst': ['val1', 'val2']} cfg.option('lst').value.set(['val2']) with pytest.raises(ConfigError): - cfg.value.dict() + cfg.value.get() cfg.option('lst').value.set(['val1']) - assert cfg.value.dict() == {'od.dodval1.stval1': 'val1', 'od.out': 'val1', 'lst': ['val1']} + assert cfg.value.get() == {'od.dodval1.st': 'val1', 'od.out': 'val1', 'lst': ['val1']} # assert not list_sessions() @@ -359,9 +359,9 @@ def test_callback_dyndescription_outside2(): od = OptionDescription('od', '', [dod, out]) od2 = OptionDescription('od', '', [od, lst]) cfg = Config(od2) - assert cfg.value.dict() == {'od.dodval1.stval1': None, 'od.dodval2.stval2': None, 'od.out': None, 'lst': ['val1', 'val2']} + assert cfg.value.get() == {'od.dodval1.st': None, 'od.dodval2.st': None, 'od.out': None, 'lst': ['val1', 'val2']} cfg.option('od.out').value.set('val1') - assert cfg.value.dict() == {'od.dodval1.stval1': 'val1', 'od.dodval2.stval2': 'val1', 'od.out': 'val1', 'lst': ['val1', 'val2']} + assert cfg.value.get() == {'od.dodval1.st': 'val1', 'od.dodval2.st': 'val1', 'od.out': 'val1', 'lst': ['val1', 'val2']} # assert not list_sessions() @@ -372,15 +372,15 @@ def test_callback_list_dyndescription(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) owner = cfg.owner.get() - assert cfg.option('od.dodval1.stval1').value.get() == ['val1', 'val2'] - assert cfg.option('od.dodval2.stval2').value.get() == ['val2', 'val2'] - assert cfg.option('od.dodval1.stval1').owner.isdefault() - assert cfg.option('od.dodval2.stval2').owner.isdefault() - cfg.option('od.dodval1.stval1').value.set(['val3', 'val2']) - assert cfg.option('od.dodval1.stval1').value.get() == ['val3', 'val2'] - assert cfg.option('od.dodval2.stval2').value.get() == ['val2', 'val2'] - assert cfg.option('od.dodval1.stval1').owner.get() == owner - assert cfg.option('od.dodval2.stval2').owner.isdefault() + assert cfg.option('od.dodval1.st').value.get() == ['val1', 'val2'] + assert cfg.option('od.dodval2.st').value.get() == ['val2', 'val2'] + assert cfg.option('od.dodval1.st').owner.isdefault() + assert cfg.option('od.dodval2.st').owner.isdefault() + cfg.option('od.dodval1.st').value.set(['val3', 'val2']) + assert cfg.option('od.dodval1.st').value.get() == ['val3', 'val2'] + assert cfg.option('od.dodval2.st').value.get() == ['val2', 'val2'] + assert cfg.option('od.dodval1.st').owner.get() == owner + assert cfg.option('od.dodval2.st').owner.isdefault() # assert not list_sessions() @@ -392,20 +392,20 @@ def test_mandatory_dyndescription(): cfg = Config(od2) cfg.property.read_only() with pytest.raises(PropertiesOptionError): - cfg.option('od.dodval1.stval1').value.get() + cfg.option('od.dodval1.st').value.get() with pytest.raises(PropertiesOptionError): - cfg.option('od.dodval2.stval2').value.get() + cfg.option('od.dodval2.st').value.get() cfg.property.read_write() - cfg.option('od.dodval1.stval1').value.set('val') + cfg.option('od.dodval1.st').value.set('val') cfg.property.read_only() - assert cfg.option('od.dodval1.stval1').value.get() == 'val' + assert cfg.option('od.dodval1.st').value.get() == 'val' with pytest.raises(PropertiesOptionError): - cfg.option('od.dodval2.stval2').value.get() + cfg.option('od.dodval2.st').value.get() cfg.property.read_write() - cfg.option('od.dodval1.stval1').value.reset() + cfg.option('od.dodval1.st').value.reset() cfg.property.read_only() with pytest.raises(PropertiesOptionError): - cfg.option('od.dodval1.stval1').value.get() + cfg.option('od.dodval1.st').value.get() # assert not list_sessions() @@ -415,7 +415,7 @@ def test_build_dyndescription_context(): dod = DynOptionDescription('dod', '', [st1], suffixes=Calculation(return_list, Params(ParamOption(val1)))) od1 = OptionDescription('od', '', [dod, val1]) cfg = Config(od1) - assert cfg.value.dict() == {'dodval1.stval1': None, 'dodval2.stval2': None, 'val1': ['val1', 'val2']} + assert cfg.value.get() == {'dodval1.st': None, 'dodval2.st': None, 'val1': ['val1', 'val2']} # assert not list_sessions() @@ -426,7 +426,7 @@ def test_subpath_dyndescription_context(): od1 = OptionDescription('od', '', [dod, val1]) od2 = OptionDescription('od', '', [od1]) cfg = Config(od2) - assert cfg.value.dict() == {'od.dodval1.stval1': None, 'od.dodval2.stval2': None, 'od.val1': ['val1', 'val2']} + assert cfg.value.get() == {'od.dodval1.st': None, 'od.dodval2.st': None, 'od.val1': ['val1', 'val2']} # assert not list_sessions() @@ -437,8 +437,8 @@ def test_list_dyndescription_context(): od = OptionDescription('od', '', [dod, val1]) od2 = OptionDescription('od', '', [od]) cfg = Config(od2) - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None with pytest.raises(AttributeError): cfg.option('od.dodval3').value.get() # assert not list_sessions() @@ -452,20 +452,20 @@ def test_mod_dyndescription_context(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) owner = cfg.owner.get() - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None - assert cfg.option('od.dodval1.stval1').owner.isdefault() - assert cfg.option('od.dodval2.stval2').owner.isdefault() - cfg.option('od.dodval1.stval1').value.set('yes') - assert cfg.option('od.dodval1.stval1').value.get() == 'yes' - assert cfg.option('od.dodval2.stval2').value.get() is None - assert cfg.option('od.dodval1.stval1').owner.get() == owner - assert cfg.option('od.dodval2.stval2').owner.isdefault() - cfg.option('od.dodval2.stval2').value.set('no') - assert cfg.option('od.dodval1.stval1').value.get() == 'yes' - assert cfg.option('od.dodval2.stval2').value.get() == 'no' - assert cfg.option('od.dodval1.stval1').owner.get() == owner - assert cfg.option('od.dodval2.stval2').owner.get() == owner + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None + assert cfg.option('od.dodval1.st').owner.isdefault() + assert cfg.option('od.dodval2.st').owner.isdefault() + cfg.option('od.dodval1.st').value.set('yes') + assert cfg.option('od.dodval1.st').value.get() == 'yes' + assert cfg.option('od.dodval2.st').value.get() is None + assert cfg.option('od.dodval1.st').owner.get() == owner + assert cfg.option('od.dodval2.st').owner.isdefault() + cfg.option('od.dodval2.st').value.set('no') + assert cfg.option('od.dodval1.st').value.get() == 'yes' + assert cfg.option('od.dodval2.st').value.get() == 'no' + assert cfg.option('od.dodval1.st').owner.get() == owner + assert cfg.option('od.dodval2.st').owner.get() == owner # assert not list_sessions() @@ -477,12 +477,12 @@ def test_del_dyndescription_context(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) owner = cfg.owner.get() - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None - cfg.option('od.dodval1.stval1').value.set('yes') - assert cfg.option('od.dodval1.stval1').owner.get() == owner - cfg.option('od.dodval1.stval1').value.reset() - assert cfg.option('od.dodval1.stval1').owner.isdefault() + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None + cfg.option('od.dodval1.st').value.set('yes') + assert cfg.option('od.dodval1.st').owner.get() == owner + cfg.option('od.dodval1.st').value.reset() + assert cfg.option('od.dodval1.st').owner.isdefault() # assert not list_sessions() @@ -494,24 +494,24 @@ def test_multi_dyndescription_context(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) owner = cfg.owner.get() - assert cfg.option('od.dodval1.stval1').value.get() == [] - assert cfg.option('od.dodval2.stval2').value.get() == [] - assert cfg.option('od.dodval1.stval1').owner.isdefault() - assert cfg.option('od.dodval2.stval2').owner.isdefault() - cfg.option('od.dodval1.stval1').value.set(['yes']) - assert cfg.option('od.dodval1.stval1').value.get() == ['yes'] - assert cfg.option('od.dodval2.stval2').value.get() == [] - assert cfg.option('od.dodval1.stval1').owner.get() == owner - assert cfg.option('od.dodval2.stval2').owner.isdefault() - cfg.option('od.dodval2.stval2').value.set(['no']) - assert cfg.option('od.dodval1.stval1').value.get() == ['yes'] - assert cfg.option('od.dodval2.stval2').value.get() == ['no'] - assert cfg.option('od.dodval1.stval1').owner.get() == owner - assert cfg.option('od.dodval2.stval2').owner.get() == owner - cfg.option('od.dodval1.stval1').value.set(['yes', 'yes']) - assert cfg.option('od.dodval1.stval1').value.get() == ['yes', 'yes'] - cfg.option('od.dodval1.stval1').value.set(['yes']) - assert cfg.option('od.dodval1.stval1').value.get() == ['yes'] + assert cfg.option('od.dodval1.st').value.get() == [] + assert cfg.option('od.dodval2.st').value.get() == [] + assert cfg.option('od.dodval1.st').owner.isdefault() + assert cfg.option('od.dodval2.st').owner.isdefault() + cfg.option('od.dodval1.st').value.set(['yes']) + assert cfg.option('od.dodval1.st').value.get() == ['yes'] + assert cfg.option('od.dodval2.st').value.get() == [] + assert cfg.option('od.dodval1.st').owner.get() == owner + assert cfg.option('od.dodval2.st').owner.isdefault() + cfg.option('od.dodval2.st').value.set(['no']) + assert cfg.option('od.dodval1.st').value.get() == ['yes'] + assert cfg.option('od.dodval2.st').value.get() == ['no'] + assert cfg.option('od.dodval1.st').owner.get() == owner + assert cfg.option('od.dodval2.st').owner.get() == owner + cfg.option('od.dodval1.st').value.set(['yes', 'yes']) + assert cfg.option('od.dodval1.st').value.get() == ['yes', 'yes'] + cfg.option('od.dodval1.st').value.set(['yes']) + assert cfg.option('od.dodval1.st').value.get() == ['yes'] # assert not list_sessions() @@ -522,14 +522,14 @@ def test_prop_dyndescription_context(): od = OptionDescription('od', '', [dod, val1]) od2 = OptionDescription('od', '', [od]) cfg = Config(od2) - assert set(cfg.option('od.dodval1.stval1').property.get()) == set(['test']) - assert set(cfg.option('od.dodval2.stval2').property.get()) == set(['test']) - cfg.option('od.dodval2.stval2').property.add('test2') - assert set(cfg.option('od.dodval1.stval1').property.get()) == set(['test']) - assert set(cfg.option('od.dodval2.stval2').property.get()) == set(['test', 'test2']) - cfg.option('od.dodval1.stval1').property.remove('test') - assert set(cfg.option('od.dodval1.stval1').property.get()) == set([]) - assert set(cfg.option('od.dodval2.stval2').property.get()) == set(['test', 'test2']) + assert set(cfg.option('od.dodval1.st').property.get()) == set(['test']) + assert set(cfg.option('od.dodval2.st').property.get()) == set(['test']) + cfg.option('od.dodval2.st').property.add('test2') + assert set(cfg.option('od.dodval1.st').property.get()) == set(['test']) + assert set(cfg.option('od.dodval2.st').property.get()) == set(['test', 'test2']) + cfg.option('od.dodval1.st').property.remove('test') + assert set(cfg.option('od.dodval1.st').property.get()) == set([]) + assert set(cfg.option('od.dodval2.st').property.get()) == set(['test', 'test2']) # assert not list_sessions() @@ -541,20 +541,20 @@ def test_callback_dyndescription_context(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) owner = cfg.owner.get() - assert cfg.option('od.dodval1.stval1').value.get() == 'val' - assert cfg.option('od.dodval2.stval2').value.get() == 'val' - assert cfg.option('od.dodval1.stval1').owner.isdefault() - assert cfg.option('od.dodval2.stval2').owner.isdefault() - cfg.option('od.dodval1.stval1').value.set('val2') - assert cfg.option('od.dodval1.stval1').value.get() == 'val2' - assert cfg.option('od.dodval2.stval2').value.get() == 'val' - assert cfg.option('od.dodval1.stval1').owner.get() == owner - assert cfg.option('od.dodval2.stval2').owner.isdefault() - cfg.option('od.dodval1.stval1').value.reset() - assert cfg.option('od.dodval1.stval1').value.get() == 'val' - assert cfg.option('od.dodval2.stval2').value.get() == 'val' - assert cfg.option('od.dodval1.stval1').owner.isdefault() - assert cfg.option('od.dodval2.stval2').owner.isdefault() + assert cfg.option('od.dodval1.st').value.get() == 'val' + assert cfg.option('od.dodval2.st').value.get() == 'val' + assert cfg.option('od.dodval1.st').owner.isdefault() + assert cfg.option('od.dodval2.st').owner.isdefault() + cfg.option('od.dodval1.st').value.set('val2') + assert cfg.option('od.dodval1.st').value.get() == 'val2' + assert cfg.option('od.dodval2.st').value.get() == 'val' + assert cfg.option('od.dodval1.st').owner.get() == owner + assert cfg.option('od.dodval2.st').owner.isdefault() + cfg.option('od.dodval1.st').value.reset() + assert cfg.option('od.dodval1.st').value.get() == 'val' + assert cfg.option('od.dodval2.st').value.get() == 'val' + assert cfg.option('od.dodval1.st').owner.isdefault() + assert cfg.option('od.dodval2.st').owner.isdefault() # assert not list_sessions() @@ -567,20 +567,20 @@ def test_mandatory_dyndescription_context(): cfg = Config(od2) cfg.property.read_only() with pytest.raises(PropertiesOptionError): - cfg.option('od.dodval1.stval1').value.get() + cfg.option('od.dodval1.st').value.get() with pytest.raises(PropertiesOptionError): - cfg.option('od.dodval2.stval2').value.get() + cfg.option('od.dodval2.st').value.get() cfg.property.read_write() - cfg.option('od.dodval1.stval1').value.set('val') + cfg.option('od.dodval1.st').value.set('val') cfg.property.read_only() - assert cfg.option('od.dodval1.stval1').value.get() == 'val' + assert cfg.option('od.dodval1.st').value.get() == 'val' with pytest.raises(PropertiesOptionError): - cfg.option('od.dodval2.stval2').value.get() + cfg.option('od.dodval2.st').value.get() cfg.property.read_write() - cfg.option('od.dodval1.stval1').value.reset() + cfg.option('od.dodval1.st').value.reset() cfg.property.read_only() with pytest.raises(PropertiesOptionError): - cfg.option('od.dodval1.stval1').value.get() + cfg.option('od.dodval1.st').value.get() # assert not list_sessions() @@ -592,14 +592,14 @@ def test_increase_dyndescription_context(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) cfg.property.read_write() - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None with pytest.raises(AttributeError): - cfg.option('od.dodval3.stval3').value.get() + cfg.option('od.dodval3.st').value.get() cfg.option('od.val1').value.set(['val1', 'val2', 'val3']) - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None - assert cfg.option('od.dodval3.stval3').value.get() is None + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None + assert cfg.option('od.dodval3.st').value.get() is None # assert not list_sessions() @@ -612,26 +612,26 @@ def test_decrease_dyndescription_context(): cfg = Config(od2) owner = cfg.owner.get() cfg.property.read_write() - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None - cfg.option('od.dodval2.stval2').value.set('yes') - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() == 'yes' - assert cfg.option('od.dodval1.stval1').owner.isdefault() - assert cfg.option('od.dodval2.stval2').owner.get() == owner + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None + cfg.option('od.dodval2.st').value.set('yes') + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() == 'yes' + assert cfg.option('od.dodval1.st').owner.isdefault() + assert cfg.option('od.dodval2.st').owner.get() == owner with pytest.raises(AttributeError): cfg.option('od.dodval3').value.get() cfg.option('od.val1').value.set(['val1']) - assert cfg.option('od.dodval1.stval1').value.get() is None + assert cfg.option('od.dodval1.st').value.get() is None with pytest.raises(AttributeError): cfg.option('od.dodval2').value.get() with pytest.raises(AttributeError): cfg.option('od.dodval3').value.get() - assert cfg.option('od.dodval1.stval1').owner.isdefault() + assert cfg.option('od.dodval1.st').owner.isdefault() with pytest.raises(AttributeError): - cfg.option('od.dodval2.stval2').owner.get() + cfg.option('od.dodval2.st').owner.get() with pytest.raises(AttributeError): - cfg.option('od.dodval2.stval2').value.get() + cfg.option('od.dodval2.st').value.get() # assert not list_sessions() @@ -662,10 +662,10 @@ def test_dyndescription_disable_suffix_root(): od1 = OptionDescription('root', 'root', [boolean, val, dod]) cfg = Config(od1) cfg.property.read_write() - assert cfg.value.dict() == {'boolean': True, 'val': ['ext1', 'ext2'], 'dodext1.stext1': None, 'dodext2.stext2': None} + assert cfg.value.get() == {'boolean': True, 'val': ['ext1', 'ext2'], 'dodext1.st': None, 'dodext2.st': None} # cfg.option('boolean').value.set(False) - assert cfg.value.dict() == {'boolean': False} + assert cfg.value.get() == {'boolean': False} # assert not list_sessions() @@ -682,10 +682,10 @@ def test_dyndescription_disable_suffix_root_2(): od1 = OptionDescription('root', 'root', [boolean, val, dod]) cfg = Config(od1) cfg.property.read_write() - assert cfg.value.dict() == {'boolean': False} + assert cfg.value.get() == {'boolean': False} # cfg.option('boolean').value.set(True) - assert cfg.value.dict() == {'boolean': True, 'val': ['ext1', 'ext2'], 'dodext1.stext1': None, 'dodext2.stext2': None} + assert cfg.value.get() == {'boolean': True, 'val': ['ext1', 'ext2'], 'dodext1.st': None, 'dodext2.st': None} # assert not list_sessions() @@ -703,10 +703,10 @@ def test_dyndescription_disable_suffix(): od1 = OptionDescription('root', 'root', [od]) cfg = Config(od1) cfg.property.read_write() - assert cfg.value.dict() == {'root.boolean': True, 'root.val': ['ext1', 'ext2'], 'root.dodext1.stext1': None, 'root.dodext2.stext2': None} + assert cfg.value.get() == {'root.boolean': True, 'root.val': ['ext1', 'ext2'], 'root.dodext1.st': None, 'root.dodext2.st': None} # cfg.option('root.boolean').value.set(False) - assert cfg.value.dict() == {'root.boolean': False} + assert cfg.value.get() == {'root.boolean': False} # assert not list_sessions() @@ -723,37 +723,37 @@ def test_requires_dyndescription(): od2 = OptionDescription('od', '', [od1, boolean]) cfg = Config(od2) cfg.property.read_write() - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None # cfg.option('boolean').value.set(False) props = [] try: - cfg.option('od.dodval1.stval1').value.get() + cfg.option('od.dodval1.st').value.get() except PropertiesOptionError as err: props = err.proptype assert frozenset(props) == frozenset(['disabled']) props = [] try: - cfg.option('od.dodval2.stval2').value.get() + cfg.option('od.dodval2.st').value.get() except PropertiesOptionError as err: props = err.proptype assert frozenset(props) == frozenset(['disabled']) # cfg.option('boolean').value.set(True) - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None #transitive cfg.option('boolean').property.add('disabled') props = [] try: - cfg.option('od.dodval1.stval1').value.get() + cfg.option('od.dodval1.st').value.get() except PropertiesOptionError as err: props = err.proptype assert frozenset(props) == frozenset(['disabled']) props = [] try: - cfg.option('od.dodval2.stval2').value.get() + cfg.option('od.dodval2.st').value.get() except PropertiesOptionError as err: props = err.proptype assert frozenset(props) == frozenset(['disabled']) @@ -779,23 +779,23 @@ def test_requires_dyndescription_boolean(): od2 = OptionDescription('od', '', [od, boolean1, boolean]) cfg = Config(od2) cfg.property.read_write() - assert cfg.value.dict() == {'boolean1': True, + assert cfg.value.get() == {'boolean1': True, 'boolean': True, - 'od.dodval1.stval1': None, - 'od.dodval2.stval2': None} + 'od.dodval1.st': None, + 'od.dodval2.st': None} # cfg.option('boolean').value.set(False) - assert cfg.value.dict() == {'boolean1': True, + assert cfg.value.get() == {'boolean1': True, 'boolean': False} # cfg.option('boolean').value.set(True) - assert cfg.value.dict() == {'boolean1': True, + assert cfg.value.get() == {'boolean1': True, 'boolean': True, - 'od.dodval1.stval1': None, - 'od.dodval2.stval2': None} + 'od.dodval1.st': None, + 'od.dodval2.st': None} # cfg.option('boolean1').value.set(False) - assert cfg.value.dict() == {'boolean1': False} + assert cfg.value.get() == {'boolean1': False} # assert not list_sessions() @@ -813,23 +813,23 @@ def test_requires_dyndescription_in_dyn(): cfg = Config(od2) cfg.property.read_write() - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None # - cfg.option('od.dodval1.booleanval1').value.set(False) + cfg.option('od.dodval1.boolean').value.set(False) props = [] try: - cfg.option('od.dodval1.stval1').value.get() + cfg.option('od.dodval1.st').value.get() except PropertiesOptionError as err: props = err.proptype assert props == frozenset(['disabled']) props = [] - cfg.option('od.dodval2.stval2').value.get() + cfg.option('od.dodval2.st').value.get() # - cfg.option('od.dodval1.booleanval1').value.set(True) - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None + cfg.option('od.dodval1.boolean').value.set(True) + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None # assert not list_sessions() @@ -857,23 +857,23 @@ def test_requires_dyndescription_in_dyn_not_same(): cfg = Config(od2) cfg.property.read_write() - assert cfg.option('od.dod2val1.stval1').value.get() is None - assert cfg.option('od.dod2val2.stval2').value.get() is None + assert cfg.option('od.dod2val1.st').value.get() is None + assert cfg.option('od.dod2val2.st').value.get() is None # - cfg.option('od.dod1val1.booleanval1').value.set(False) + cfg.option('od.dod1val1.boolean').value.set(False) props = [] try: - cfg.option('od.dod2val1.stval1').value.get() + cfg.option('od.dod2val1.st').value.get() except PropertiesOptionError as err: props = err.proptype assert props == frozenset(['disabled']) props = [] - cfg.option('od.dod2val2.stval2').value.get() + cfg.option('od.dod2val2.st').value.get() # - cfg.option('od.dod1val1.booleanval1').value.set(True) - assert cfg.option('od.dod2val1.stval1').value.get() is None - assert cfg.option('od.dod2val2.stval2').value.get() is None + cfg.option('od.dod1val1.boolean').value.set(True) + assert cfg.option('od.dod2val1.st').value.get() is None + assert cfg.option('od.dod2val2.st').value.get() is None # assert not list_sessions() @@ -890,37 +890,37 @@ def test_requires_dyndescription2(): od2 = OptionDescription('od', '', [od1, boolean]) cfg = Config(od2) cfg.property.read_write() - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None # cfg.option('boolean').value.set(False) props = [] try: - cfg.option('od.dodval1.stval1').value.get() + cfg.option('od.dodval1.st').value.get() except PropertiesOptionError as err: props = err.proptype assert frozenset(props) == frozenset(['disabled']) props = [] try: - cfg.option('od.dodval2.stval2').value.get() + cfg.option('od.dodval2.st').value.get() except PropertiesOptionError as err: props = err.proptype assert frozenset(props) == frozenset(['disabled']) # cfg.option('boolean').value.set(True) - assert cfg.option('od.dodval1.stval1').value.get() is None - assert cfg.option('od.dodval2.stval2').value.get() is None + assert cfg.option('od.dodval1.st').value.get() is None + assert cfg.option('od.dodval2.st').value.get() is None #transitive cfg.option('boolean').property.add('disabled') props = [] try: - cfg.option('od.dodval1.stval1').value.get() + cfg.option('od.dodval1.st').value.get() except PropertiesOptionError as err: props = err.proptype assert frozenset(props) == frozenset(['disabled']) props = [] try: - cfg.option('od.dodval2.stval2').value.get() + cfg.option('od.dodval2.st').value.get() except PropertiesOptionError as err: props = err.proptype assert frozenset(props) == frozenset(['disabled']) @@ -934,10 +934,10 @@ def test_validator_dyndescription(): od = OptionDescription('od', '', [dod, val1]) od2 = OptionDescription('od', '', [od]) cfg = Config(od2) - assert cfg.option('od.dodval1.stval1').value.get() == 'val' + assert cfg.option('od.dodval1.st').value.get() == 'val' with pytest.raises(ValueError): - cfg.option('od.dodval1.stval1').value.set('no') - cfg.option('od.dodval1.stval1').value.set('val') + cfg.option('od.dodval1.st').value.set('no') + cfg.option('od.dodval1.st').value.set('val') # assert not list_sessions() @@ -948,8 +948,8 @@ def test_makedict_dyndescription_context(): od = OptionDescription('od', '', [dod, val1]) od2 = OptionDescription('od', '', [od]) cfg = Config(od2) - cfg.option('od.dodval1.stval1').value.set('yes') - assert cfg.value.dict() == {'od.val1': ['val1', 'val2'], 'od.dodval1.stval1': 'yes', 'od.dodval2.stval2': None} + cfg.option('od.dodval1.st').value.set('yes') + assert cfg.value.get() == {'od.val1': ['val1', 'val2'], 'od.dodval1.st': 'yes', 'od.dodval2.st': None} # assert not list_sessions() @@ -960,16 +960,16 @@ def test_find_dyndescription_context(): od = OptionDescription('od', '', [dod, val1]) od2 = OptionDescription('od', '', [od]) cfg = Config(od2) - cfg.option('od.dodval1.stval1').value.set('yes') - ret = cfg.option.find('stval1', first=True) + cfg.option('od.dodval1.st').value.set('yes') + ret = cfg.option.find('st', first=True) assert ret.value.get() == "yes" - ret = cfg.option.find('stval1', first=True) + ret = cfg.option.find('st', first=True) assert isinstance(ret.get(), SynDynOption) - #assert cfg.option.find(bytype=StrOption, type='path') == ['od.dodval1.stval1', 'od.dodval2.stval2', 'od.val1'] + #assert cfg.option.find(bytype=StrOption, type='path') == ['od.dodval1.st', 'od.dodval2.st', 'od.val1'] #opts = cfg.option.find(byvalue='yes') #assert len(opts) == 1 #assert isinstance(opts[0], SynDynOption) - #assert opts[0].impl_getname() == 'stval1' + #assert opts[0].impl_getname() == 'st' with pytest.raises(AttributeError): list(cfg.option.find('strnotexists')) # assert not list_sessions() @@ -987,8 +987,8 @@ def test_information_dyndescription_context(): cfg.information.set('testcfgod', 'val3') assert cfg.option('od.dodval1').information.get('testod') == 'val1' assert cfg.option('od.dodval2').information.get('testod') == 'val1' - assert cfg.option('od.dodval1.stval1').information.get('testst') == 'val2' - assert cfg.option('od.dodval2.stval2').information.get('testst') == 'val2' + assert cfg.option('od.dodval1.st').information.get('testst') == 'val2' + assert cfg.option('od.dodval2.st').information.get('testst') == 'val2' assert cfg.information.get('testcfgod') == 'val3' # assert not list_sessions() @@ -1017,75 +1017,75 @@ def test_all_dyndescription(): filename], suffixes=Calculation(return_list)) od1 = OptionDescription('od', '', [dod]) cfg = Config(od1) - assert cfg.option('dodval1.stval1').value.get() is None - assert cfg.option('dodval1.ipval1').value.get() is None - assert cfg.option('dodval1.networkval1').value.get() is None - assert cfg.option('dodval1.netmaskval1').value.get() is None - assert cfg.option('dodval1.chval1').value.get() is None - assert cfg.option('dodval1.ch1val1').value.get() is None - assert cfg.option('dodval1.booval1').value.get() is None - assert cfg.option('dodval1.intrval1').value.get() is None - assert cfg.option('dodval1.floaval1').value.get() is None - assert cfg.option('dodval1.unival1').value.get() is None - assert cfg.option('dodval1.portval1').value.get() is None - assert cfg.option('dodval1.broadval1').value.get() is None - assert cfg.option('dodval1.domainval1').value.get() is None - assert cfg.option('dodval1.emailval1').value.get() is None - assert cfg.option('dodval1.urlval1').value.get() is None - assert cfg.option('dodval1.usernameval1').value.get() is None - assert cfg.option('dodval1.filenameval1').value.get() is None + assert cfg.option('dodval1.st').value.get() is None + assert cfg.option('dodval1.ip').value.get() is None + assert cfg.option('dodval1.network').value.get() is None + assert cfg.option('dodval1.netmask').value.get() is None + assert cfg.option('dodval1.ch').value.get() is None + assert cfg.option('dodval1.ch1').value.get() is None + assert cfg.option('dodval1.boo').value.get() is None + assert cfg.option('dodval1.intr').value.get() is None + assert cfg.option('dodval1.floa').value.get() is None + assert cfg.option('dodval1.uni').value.get() is None + assert cfg.option('dodval1.port').value.get() is None + assert cfg.option('dodval1.broad').value.get() is None + assert cfg.option('dodval1.domain').value.get() is None + assert cfg.option('dodval1.email').value.get() is None + assert cfg.option('dodval1.url').value.get() is None + assert cfg.option('dodval1.username').value.get() is None + assert cfg.option('dodval1.filename').value.get() is None # - cfg.option('dodval1.stval1').value.set("no") - cfg.option('dodval1.ipval1').value.set("1.1.1.1") - cfg.option('dodval1.networkval1').value.set("1.1.1.0") - cfg.option('dodval1.netmaskval1').value.set("255.255.255.0") - cfg.option('dodval1.chval1').value.set("val1") - cfg.option('dodval1.ch1val1').value.set("val2") - cfg.option('dodval1.booval1').value.set(True) - cfg.option('dodval1.intrval1').value.set(1) - cfg.option('dodval1.floaval1').value.set(0.1) - cfg.option('dodval1.unival1').value.set(u"no") - cfg.option('dodval1.portval1').value.set('80') - cfg.option('dodval1.broadval1').value.set("1.1.1.255") - cfg.option('dodval1.domainval1').value.set("test.com") - cfg.option('dodval1.emailval1').value.set("test@test.com") - cfg.option('dodval1.urlval1').value.set("http://test.com") - cfg.option('dodval1.usernameval1').value.set("user1") - cfg.option('dodval1.filenameval1').value.set("/tmp") - assert cfg.option('dodval1.stval1').value.get() == "no" - assert cfg.option('dodval1.ipval1').value.get() == "1.1.1.1" - assert cfg.option('dodval1.networkval1').value.get() == "1.1.1.0" - assert cfg.option('dodval1.netmaskval1').value.get() == "255.255.255.0" - assert cfg.option('dodval1.chval1').value.get() == "val1" - assert cfg.option('dodval1.ch1val1').value.get() == "val2" - assert cfg.option('dodval1.booval1').value.get() is True - assert cfg.option('dodval1.intrval1').value.get() == 1 - assert cfg.option('dodval1.floaval1').value.get() == 0.1 - assert cfg.option('dodval1.unival1').value.get() == u"no" - assert cfg.option('dodval1.portval1').value.get() == '80' - assert cfg.option('dodval1.broadval1').value.get() == "1.1.1.255" - assert cfg.option('dodval1.domainval1').value.get() == "test.com" - assert cfg.option('dodval1.emailval1').value.get() == "test@test.com" - assert cfg.option('dodval1.urlval1').value.get() == "http://test.com" - assert cfg.option('dodval1.usernameval1').value.get() == "user1" - assert cfg.option('dodval1.filenameval1').value.get() == "/tmp" - assert cfg.option('dodval2.stval2').value.get() is None - assert cfg.option('dodval2.ipval2').value.get() is None - assert cfg.option('dodval2.networkval2').value.get() is None - assert cfg.option('dodval2.netmaskval2').value.get() is None - assert cfg.option('dodval2.chval2').value.get() is None - assert cfg.option('dodval2.ch1val2').value.get() is None - assert cfg.option('dodval2.booval2').value.get() is None - assert cfg.option('dodval2.intrval2').value.get() is None - assert cfg.option('dodval2.floaval2').value.get() is None - assert cfg.option('dodval2.unival2').value.get() is None - assert cfg.option('dodval2.portval2').value.get() is None - assert cfg.option('dodval2.broadval2').value.get() is None - assert cfg.option('dodval2.domainval2').value.get() is None - assert cfg.option('dodval2.emailval2').value.get() is None - assert cfg.option('dodval2.urlval2').value.get() is None - assert cfg.option('dodval2.usernameval2').value.get() is None - assert cfg.option('dodval2.filenameval2').value.get() is None + cfg.option('dodval1.st').value.set("no") + cfg.option('dodval1.ip').value.set("1.1.1.1") + cfg.option('dodval1.network').value.set("1.1.1.0") + cfg.option('dodval1.netmask').value.set("255.255.255.0") + cfg.option('dodval1.ch').value.set("val1") + cfg.option('dodval1.ch1').value.set("val2") + cfg.option('dodval1.boo').value.set(True) + cfg.option('dodval1.intr').value.set(1) + cfg.option('dodval1.floa').value.set(0.1) + cfg.option('dodval1.uni').value.set(u"no") + cfg.option('dodval1.port').value.set('80') + cfg.option('dodval1.broad').value.set("1.1.1.255") + cfg.option('dodval1.domain').value.set("test.com") + cfg.option('dodval1.email').value.set("test@test.com") + cfg.option('dodval1.url').value.set("http://test.com") + cfg.option('dodval1.username').value.set("user1") + cfg.option('dodval1.filename').value.set("/tmp") + assert cfg.option('dodval1.st').value.get() == "no" + assert cfg.option('dodval1.ip').value.get() == "1.1.1.1" + assert cfg.option('dodval1.network').value.get() == "1.1.1.0" + assert cfg.option('dodval1.netmask').value.get() == "255.255.255.0" + assert cfg.option('dodval1.ch').value.get() == "val1" + assert cfg.option('dodval1.ch1').value.get() == "val2" + assert cfg.option('dodval1.boo').value.get() is True + assert cfg.option('dodval1.intr').value.get() == 1 + assert cfg.option('dodval1.floa').value.get() == 0.1 + assert cfg.option('dodval1.uni').value.get() == u"no" + assert cfg.option('dodval1.port').value.get() == '80' + assert cfg.option('dodval1.broad').value.get() == "1.1.1.255" + assert cfg.option('dodval1.domain').value.get() == "test.com" + assert cfg.option('dodval1.email').value.get() == "test@test.com" + assert cfg.option('dodval1.url').value.get() == "http://test.com" + assert cfg.option('dodval1.username').value.get() == "user1" + assert cfg.option('dodval1.filename').value.get() == "/tmp" + assert cfg.option('dodval2.st').value.get() is None + assert cfg.option('dodval2.ip').value.get() is None + assert cfg.option('dodval2.network').value.get() is None + assert cfg.option('dodval2.netmask').value.get() is None + assert cfg.option('dodval2.ch').value.get() is None + assert cfg.option('dodval2.ch1').value.get() is None + assert cfg.option('dodval2.boo').value.get() is None + assert cfg.option('dodval2.intr').value.get() is None + assert cfg.option('dodval2.floa').value.get() is None + assert cfg.option('dodval2.uni').value.get() is None + assert cfg.option('dodval2.port').value.get() is None + assert cfg.option('dodval2.broad').value.get() is None + assert cfg.option('dodval2.domain').value.get() is None + assert cfg.option('dodval2.email').value.get() is None + assert cfg.option('dodval2.url').value.get() is None + assert cfg.option('dodval2.username').value.get() is None + assert cfg.option('dodval2.filename').value.get() is None # assert not list_sessions() @@ -1099,52 +1099,52 @@ def test_leadership_dyndescription(): cfg = Config(od1) owner = cfg.owner.get() # - assert cfg.value.dict() == {'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': []} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + assert cfg.value.get() == {'od.stval2.st1.st1': [], 'od.stval1.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'yes', 'od.stval1.st1val1.st2val1': None}], 'od.stval2.st1val2.st1val2': []} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == None - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.value.get() == {'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'yes', 'od.stval1.st1.st2': None}], 'od.stval2.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == None + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('no') - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'no' - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st2', 0).value.set('no') + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'no' + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.pop(0) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.pop(0) + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - cfg.option('od.stval1.st1val1.st2val1', 0).value.reset() - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.isdefault() + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + cfg.option('od.stval1.st1.st2', 0).value.reset() + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - cfg.option('od.stval1.st1val1.st1val1').value.reset() - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + cfg.option('od.stval1.st1.st1').value.reset() + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # assert not list_sessions() @@ -1158,26 +1158,26 @@ def test_leadership_dyndescription_force_store_value_leader(): od1 = OptionDescription('od', '', [od]) cfg = Config(od1) cfg.property.read_write() - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() == False - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() == False - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() == True - assert cfg.option('od.stval1.st1val1.st2val1', 1).owner.isdefault() == True - assert cfg.option('od.stval2.st1val2.st2val2', 0).owner.isdefault() == True - assert cfg.option('od.stval2.st1val2.st2val2', 1).owner.isdefault() == True - assert cfg.value.dict() == {'od.val1': ['val1', 'val2'], 'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'val1', 'od.stval1.st1val1.st2val1': 'val1'}, {'od.stval1.st1val1.st1val1': 'val2', 'od.stval1.st1val1.st2val1': 'val2'}], 'od.stval2.st1val2.st1val2': [{'od.stval2.st1val2.st1val2': 'val1', 'od.stval2.st1val2.st2val2': 'val1'}, {'od.stval2.st1val2.st1val2': 'val2', 'od.stval2.st1val2.st2val2': 'val2'}]} + assert cfg.option('od.stval1.st1.st1').owner.isdefault() == False + assert cfg.option('od.stval2.st1.st1').owner.isdefault() == False + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() == True + assert cfg.option('od.stval1.st1.st2', 1).owner.isdefault() == True + assert cfg.option('od.stval2.st1.st2', 0).owner.isdefault() == True + assert cfg.option('od.stval2.st1.st2', 1).owner.isdefault() == True + assert cfg.value.get() == {'od.val1': ['val1', 'val2'], 'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'val1', 'od.stval1.st1.st2': 'val1'}, {'od.stval1.st1.st1': 'val2', 'od.stval1.st1.st2': 'val2'}], 'od.stval2.st1.st1': [{'od.stval2.st1.st1': 'val1', 'od.stval2.st1.st2': 'val1'}, {'od.stval2.st1.st1': 'val2', 'od.stval2.st1.st2': 'val2'}]} # cfg.option('od.val1').value.set(['val1', 'val2', 'val3']) - assert cfg.option('od.stval3.st1val3.st1val3').owner.isdefault() == False - assert cfg.option('od.stval3.st1val3.st2val3', 0).owner.isdefault() == True - assert cfg.option('od.stval3.st1val3.st2val3', 1).owner.isdefault() == True - assert cfg.value.dict() == {'od.val1': ['val1', 'val2', 'val3'], 'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'val1', 'od.stval1.st1val1.st2val1': 'val1'}, {'od.stval1.st1val1.st1val1': 'val2', 'od.stval1.st1val1.st2val1': 'val2'}], 'od.stval2.st1val2.st1val2': [{'od.stval2.st1val2.st1val2': 'val1', 'od.stval2.st1val2.st2val2': 'val1'}, {'od.stval2.st1val2.st1val2': 'val2', 'od.stval2.st1val2.st2val2': 'val2'}], 'od.stval3.st1val3.st1val3': [{'od.stval3.st1val3.st1val3': 'val1', 'od.stval3.st1val3.st2val3': 'val1'}, {'od.stval3.st1val3.st1val3': 'val2', 'od.stval3.st1val3.st2val3': 'val2'}]} + assert cfg.option('od.stval3.st1.st1').owner.isdefault() == False + assert cfg.option('od.stval3.st1.st2', 0).owner.isdefault() == True + assert cfg.option('od.stval3.st1.st2', 1).owner.isdefault() == True + assert cfg.value.get() == {'od.val1': ['val1', 'val2', 'val3'], 'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'val1', 'od.stval1.st1.st2': 'val1'}, {'od.stval1.st1.st1': 'val2', 'od.stval1.st1.st2': 'val2'}], 'od.stval2.st1.st1': [{'od.stval2.st1.st1': 'val1', 'od.stval2.st1.st2': 'val1'}, {'od.stval2.st1.st1': 'val2', 'od.stval2.st1.st2': 'val2'}], 'od.stval3.st1.st1': [{'od.stval3.st1.st1': 'val1', 'od.stval3.st1.st2': 'val1'}, {'od.stval3.st1.st1': 'val2', 'od.stval3.st1.st2': 'val2'}]} # - cfg.option('od.stval3.st1val3.st1val3').value.set(['val1', 'val2', 'val3']) - assert cfg.option('od.stval3.st1val3.st1val3').owner.isdefault() == False - assert cfg.option('od.stval3.st1val3.st2val3', 0).owner.isdefault() == True - assert cfg.option('od.stval3.st1val3.st2val3', 1).owner.isdefault() == True - assert cfg.option('od.stval3.st1val3.st2val3', 2).owner.isdefault() == True - assert cfg.value.dict() == {'od.val1': ['val1', 'val2', 'val3'], 'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'val1', 'od.stval1.st1val1.st2val1': 'val1'}, {'od.stval1.st1val1.st1val1': 'val2', 'od.stval1.st1val1.st2val1': 'val2'}], 'od.stval2.st1val2.st1val2': [{'od.stval2.st1val2.st1val2': 'val1', 'od.stval2.st1val2.st2val2': 'val1'}, {'od.stval2.st1val2.st1val2': 'val2', 'od.stval2.st1val2.st2val2': 'val2'}], 'od.stval3.st1val3.st1val3': [{'od.stval3.st1val3.st1val3': 'val1', 'od.stval3.st1val3.st2val3': 'val1'}, {'od.stval3.st1val3.st1val3': 'val2', 'od.stval3.st1val3.st2val3': 'val2'}, {'od.stval3.st1val3.st1val3': 'val3', 'od.stval3.st1val3.st2val3': 'val3'}]} + cfg.option('od.stval3.st1.st1').value.set(['val1', 'val2', 'val3']) + assert cfg.option('od.stval3.st1.st1').owner.isdefault() == False + assert cfg.option('od.stval3.st1.st2', 0).owner.isdefault() == True + assert cfg.option('od.stval3.st1.st2', 1).owner.isdefault() == True + assert cfg.option('od.stval3.st1.st2', 2).owner.isdefault() == True + assert cfg.value.get() == {'od.val1': ['val1', 'val2', 'val3'], 'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'val1', 'od.stval1.st1.st2': 'val1'}, {'od.stval1.st1.st1': 'val2', 'od.stval1.st1.st2': 'val2'}], 'od.stval2.st1.st1': [{'od.stval2.st1.st1': 'val1', 'od.stval2.st1.st2': 'val1'}, {'od.stval2.st1.st1': 'val2', 'od.stval2.st1.st2': 'val2'}], 'od.stval3.st1.st1': [{'od.stval3.st1.st1': 'val1', 'od.stval3.st1.st2': 'val1'}, {'od.stval3.st1.st1': 'val2', 'od.stval3.st1.st2': 'val2'}, {'od.stval3.st1.st1': 'val3', 'od.stval3.st1.st2': 'val3'}]} # assert not list_sessions() @@ -1191,26 +1191,26 @@ def test_leadership_dyndescription_force_store_value(): od1 = OptionDescription('od', '', [od]) cfg = Config(od1) cfg.property.read_write() - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() == True - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() == True - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() == False - assert cfg.option('od.stval1.st1val1.st2val1', 1).owner.isdefault() == False - assert cfg.option('od.stval2.st1val2.st2val2', 0).owner.isdefault() == False - assert cfg.option('od.stval2.st1val2.st2val2', 1).owner.isdefault() == False - assert cfg.value.dict() == {'od.val1': ['val1', 'val2'], 'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'val1', 'od.stval1.st1val1.st2val1': 'val1'}, {'od.stval1.st1val1.st1val1': 'val2', 'od.stval1.st1val1.st2val1': 'val2'}], 'od.stval2.st1val2.st1val2': [{'od.stval2.st1val2.st1val2': 'val1', 'od.stval2.st1val2.st2val2': 'val1'}, {'od.stval2.st1val2.st1val2': 'val2', 'od.stval2.st1val2.st2val2': 'val2'}]} + assert cfg.option('od.stval1.st1.st1').owner.isdefault() == True + assert cfg.option('od.stval2.st1.st1').owner.isdefault() == True + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() == False + assert cfg.option('od.stval1.st1.st2', 1).owner.isdefault() == False + assert cfg.option('od.stval2.st1.st2', 0).owner.isdefault() == False + assert cfg.option('od.stval2.st1.st2', 1).owner.isdefault() == False + assert cfg.value.get() == {'od.val1': ['val1', 'val2'], 'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'val1', 'od.stval1.st1.st2': 'val1'}, {'od.stval1.st1.st1': 'val2', 'od.stval1.st1.st2': 'val2'}], 'od.stval2.st1.st1': [{'od.stval2.st1.st1': 'val1', 'od.stval2.st1.st2': 'val1'}, {'od.stval2.st1.st1': 'val2', 'od.stval2.st1.st2': 'val2'}]} # cfg.option('od.val1').value.set(['val1', 'val2', 'val3']) - assert cfg.option('od.stval3.st1val3.st1val3').owner.isdefault() == True - assert cfg.option('od.stval3.st1val3.st2val3', 0).owner.isdefault() == False - assert cfg.option('od.stval3.st1val3.st2val3', 1).owner.isdefault() == False - assert cfg.value.dict() == {'od.val1': ['val1', 'val2', 'val3'], 'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'val1', 'od.stval1.st1val1.st2val1': 'val1'}, {'od.stval1.st1val1.st1val1': 'val2', 'od.stval1.st1val1.st2val1': 'val2'}], 'od.stval2.st1val2.st1val2': [{'od.stval2.st1val2.st1val2': 'val1', 'od.stval2.st1val2.st2val2': 'val1'}, {'od.stval2.st1val2.st1val2': 'val2', 'od.stval2.st1val2.st2val2': 'val2'}], 'od.stval3.st1val3.st1val3': [{'od.stval3.st1val3.st1val3': 'val1', 'od.stval3.st1val3.st2val3': 'val1'}, {'od.stval3.st1val3.st1val3': 'val2', 'od.stval3.st1val3.st2val3': 'val2'}]} + assert cfg.option('od.stval3.st1.st1').owner.isdefault() == True + assert cfg.option('od.stval3.st1.st2', 0).owner.isdefault() == False + assert cfg.option('od.stval3.st1.st2', 1).owner.isdefault() == False + assert cfg.value.get() == {'od.val1': ['val1', 'val2', 'val3'], 'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'val1', 'od.stval1.st1.st2': 'val1'}, {'od.stval1.st1.st1': 'val2', 'od.stval1.st1.st2': 'val2'}], 'od.stval2.st1.st1': [{'od.stval2.st1.st1': 'val1', 'od.stval2.st1.st2': 'val1'}, {'od.stval2.st1.st1': 'val2', 'od.stval2.st1.st2': 'val2'}], 'od.stval3.st1.st1': [{'od.stval3.st1.st1': 'val1', 'od.stval3.st1.st2': 'val1'}, {'od.stval3.st1.st1': 'val2', 'od.stval3.st1.st2': 'val2'}]} # - cfg.option('od.stval3.st1val3.st1val3').value.set(['val1', 'val2', 'val3']) - assert cfg.option('od.stval3.st1val3.st1val3').owner.isdefault() == False - assert cfg.option('od.stval3.st1val3.st2val3', 0).owner.isdefault() == False - assert cfg.option('od.stval3.st1val3.st2val3', 1).owner.isdefault() == False - assert cfg.option('od.stval3.st1val3.st2val3', 2).owner.isdefault() == False - assert cfg.value.dict() == {'od.val1': ['val1', 'val2', 'val3'], 'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'val1', 'od.stval1.st1val1.st2val1': 'val1'}, {'od.stval1.st1val1.st1val1': 'val2', 'od.stval1.st1val1.st2val1': 'val2'}], 'od.stval2.st1val2.st1val2': [{'od.stval2.st1val2.st1val2': 'val1', 'od.stval2.st1val2.st2val2': 'val1'}, {'od.stval2.st1val2.st1val2': 'val2', 'od.stval2.st1val2.st2val2': 'val2'}], 'od.stval3.st1val3.st1val3': [{'od.stval3.st1val3.st1val3': 'val1', 'od.stval3.st1val3.st2val3': 'val1'}, {'od.stval3.st1val3.st1val3': 'val2', 'od.stval3.st1val3.st2val3': 'val2'}, {'od.stval3.st1val3.st1val3': 'val3', 'od.stval3.st1val3.st2val3': 'val3'}]} + cfg.option('od.stval3.st1.st1').value.set(['val1', 'val2', 'val3']) + assert cfg.option('od.stval3.st1.st1').owner.isdefault() == False + assert cfg.option('od.stval3.st1.st2', 0).owner.isdefault() == False + assert cfg.option('od.stval3.st1.st2', 1).owner.isdefault() == False + assert cfg.option('od.stval3.st1.st2', 2).owner.isdefault() == False + assert cfg.value.get() == {'od.val1': ['val1', 'val2', 'val3'], 'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'val1', 'od.stval1.st1.st2': 'val1'}, {'od.stval1.st1.st1': 'val2', 'od.stval1.st1.st2': 'val2'}], 'od.stval2.st1.st1': [{'od.stval2.st1.st1': 'val1', 'od.stval2.st1.st2': 'val1'}, {'od.stval2.st1.st1': 'val2', 'od.stval2.st1.st2': 'val2'}], 'od.stval3.st1.st1': [{'od.stval3.st1.st1': 'val1', 'od.stval3.st1.st2': 'val1'}, {'od.stval3.st1.st1': 'val2', 'od.stval3.st1.st2': 'val2'}, {'od.stval3.st1.st1': 'val3', 'od.stval3.st1.st2': 'val3'}]} # assert not list_sessions() @@ -1224,18 +1224,18 @@ def test_leadership_default_multi_dyndescription(): cfg = Config(od1) owner = cfg.owner.get() # - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'no' - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'no' + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # assert not list_sessions() @@ -1250,53 +1250,53 @@ def test_leadership_dyndescription_param(): od1 = OptionDescription('od', '', [od]) cfg = Config(od1) owner = cfg.owner.get() - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [], 'od.stval2.st1val2.st1val2': [], 'od.odval1.val1': ['val1', 'val2']} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owners.default - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + assert cfg.value.get() == {'od.stval1.st1.st1': [], 'od.stval2.st1.st1': [], 'od.odval1.val1': ['val1', 'val2']} + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owners.default + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'yes', 'od.stval1.st1val1.st2val1': None}], 'od.stval2.st1val2.st1val2': [], 'od.odval1.val1': ['val1', 'val2']} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == None - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owners.default - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.value.get() == {'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'yes', 'od.stval1.st1.st2': None}], 'od.stval2.st1.st1': [], 'od.odval1.val1': ['val1', 'val2']} + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == None + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owners.default + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('no') - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'no' - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st2', 0).value.set('no') + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'no' + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st1val1').value.pop(0) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st1').value.pop(0) + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st1').value.set(['yes']) + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st2val1', 0).value.reset() - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owners.default - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st2', 0).value.reset() + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owners.default + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - cfg.option('od.stval1.st1val1.st1val1').value.reset() - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owners.default - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st1').value.set(['yes']) + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + cfg.option('od.stval1.st1.st1').value.reset() + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owners.default + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # assert not list_sessions() @@ -1310,18 +1310,18 @@ def test_leadership_default_multi_dyndescription(): cfg = Config(od1) owner = cfg.owner.get() # - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'no' - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'no' + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # assert not list_sessions() @@ -1330,53 +1330,53 @@ def _test_leadership(cfg): cfg.option('od.val1.val1').value.set(['val1', 'val2']) cfg.option('od.val1.val2', 0).value.set('val1') cfg.option('od.val1.val2', 1).value.set('val2') - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [], 'od.stval2.st1val2.st1val2': [], 'od.val1.val1': [{'od.val1.val1': 'val1', 'od.val1.val2': 'val1'}, {'od.val1.val1': 'val2', 'od.val1.val2': 'val2'}]} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owners.default - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + assert cfg.value.get() == {'od.stval1.st1.st1': [], 'od.stval2.st1.st1': [], 'od.val1.val1': [{'od.val1.val1': 'val1', 'od.val1.val2': 'val1'}, {'od.val1.val1': 'val2', 'od.val1.val2': 'val2'}]} + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owners.default + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'yes', 'od.stval1.st1val1.st2val1': None}], 'od.stval2.st1val2.st1val2': [], 'od.val1.val1': [{'od.val1.val1': 'val1', 'od.val1.val2': 'val1'}, {'od.val1.val1': 'val2', 'od.val1.val2': 'val2'}]} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == None - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owners.default - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.value.get() == {'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'yes', 'od.stval1.st1.st2': None}], 'od.stval2.st1.st1': [], 'od.val1.val1': [{'od.val1.val1': 'val1', 'od.val1.val2': 'val1'}, {'od.val1.val1': 'val2', 'od.val1.val2': 'val2'}]} + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == None + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owners.default + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('no') - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'no' - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st2', 0).value.set('no') + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'no' + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st1val1').value.pop(0) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st1').value.pop(0) + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st1').value.set(['yes']) + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st2val1', 0).value.reset() - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owners.default - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st2', 0).value.reset() + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owners.default + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - cfg.option('od.stval1.st1val1.st1val1').value.reset() - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owners.default - assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default + cfg.option('od.stval1.st1.st1').value.set(['yes']) + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + cfg.option('od.stval1.st1.st1').value.reset() + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owners.default + assert cfg.option('od.stval2.st1.st1').owner.get() == owners.default def test_leadership_dyndescription_param_leader(): @@ -1404,18 +1404,18 @@ def test_leadership_default_multi_dyndescription(): with Config(od2) as cfg: owner = cfg.owner.get() # - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'no' - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'no' + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # assert not list_sessions() @@ -1444,18 +1444,18 @@ def test_leadership_default_multi_dyndescription(): cfg = Config(od1) owner = cfg.owner.get() # - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'no' - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'no' + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # assert not list_sessions() @@ -1469,26 +1469,26 @@ def test_leadership_submulti_dyndescription(): cfg = Config(od2) owner = cfg.owner.get() # - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st2val1', 0).value.set(['no']) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == ['no'] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st2', 0).value.set(['no']) + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == ['no'] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # assert not list_sessions() @@ -1501,56 +1501,56 @@ def test_leadership_callback_dyndescription(): od2 = OptionDescription('od', '', [od1]) cfg = Config(od2) owner = cfg.owner.get() - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [], 'od.stval2.st1val2.st1val2': []} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() ==[] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + assert cfg.value.get() == {'od.stval1.st1.st1': [], 'od.stval2.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').value.get() ==[] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'yes', 'od.stval1.st1val1.st2val1': 'yes'}], 'od.stval2.st1val2.st1val2': []} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'yes' - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.value.get() == {'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'yes', 'od.stval1.st1.st2': 'yes'}], 'od.stval2.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'yes' + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('no') - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'no' - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st2', 0).value.set('no') + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'no' + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.pop(0) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.pop(0) + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() - cfg.option('od.stval1.st1val1.st2val1', 0).value.reset() - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.isdefault() + cfg.option('od.stval1.st1.st2', 0).value.reset() + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - cfg.option('od.stval1.st1val1.st1val1').value.reset() - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + cfg.option('od.stval1.st1.st1').value.reset() + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'yes' + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'yes' # assert not list_sessions() @@ -1562,11 +1562,11 @@ def test_leadership_callback_value_dyndescription(): od = OptionDescription('od', '', [st]) od1 = OptionDescription('od', '', [od]) cfg = Config(od1) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('val') - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'val' + assert cfg.option('od.stval1.st1.st1').value.get() == [] + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + cfg.option('od.stval1.st1.st2', 0).value.set('val') + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'val' # assert not list_sessions() @@ -1579,10 +1579,10 @@ def test_leadership_callback_nomulti_dyndescription(): od1 = OptionDescription('od', '', [stt]) od2 = OptionDescription('od', '', [od1, v11]) cfg = Config(od2) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'val' + assert cfg.option('od.stval1.st1.st1').value.get() == [] + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'val' # assert not list_sessions() @@ -1596,25 +1596,25 @@ def test_leadership_callback_samegroup_dyndescription(): od2 = OptionDescription('od', '', [od1]) cfg = Config(od2) owner = cfg.owner.get() - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [], 'od.stval2.st1val2.st1val2': []} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + assert cfg.value.get() == {'od.stval1.st1.st1': [], 'od.stval2.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'yes', 'od.stval1.st1val1.st2val1': None, 'od.stval1.st1val1.st3val1': None}], 'od.stval2.st1val2.st1val2': []} - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() - assert cfg.option('od.stval1.st1val1.st3val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.value.get() == {'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'yes', 'od.stval1.st1.st2': None, 'od.stval1.st1.st3': None}], 'od.stval2.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() + assert cfg.option('od.stval1.st1.st3', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'yes', 'od.stval1.st1val1.st2val1': 'yes', 'od.stval1.st1val1.st3val1': 'yes'}], 'od.stval2.st1val2.st1val2': []} - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval1.st1val1.st3val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + assert cfg.value.get() == {'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'yes', 'od.stval1.st1.st2': 'yes', 'od.stval1.st1.st3': 'yes'}], 'od.stval2.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval1.st1.st3', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # assert not list_sessions() @@ -1668,7 +1668,7 @@ def test_invalid_samevalue_dyndescription(): od1 = OptionDescription('od', '', [dod]) cfg = Config(od1) with pytest.raises(ValueError): - cfg.value.dict() + cfg.value.get() # assert not list_sessions() @@ -1678,7 +1678,7 @@ def test_invalid_name_dyndescription(): od1 = OptionDescription('od', '', [dod]) cfg = Config(od1) with pytest.raises(ValueError): - cfg.value.dict() + cfg.value.get() # assert not list_sessions() @@ -1692,52 +1692,52 @@ def test_leadership_dyndescription_convert(): cfg = Config(od1) owner = cfg.owner.get() # - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [], 'od.stval2.st1val2.st1val2': []} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + assert cfg.value.get() == {'od.stval1.st1.st1': [], 'od.stval2.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'yes', 'od.stval1.st1val1.st2val1': None}], 'od.stval2.st1val2.st1val2': []} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == None - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.value.get() == {'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'yes', 'od.stval1.st1.st2': None}], 'od.stval2.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == None + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('no') - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == ['yes'] - assert cfg.option('od.stval1.st1val1.st2val1', 0).value.get() == 'no' - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st2', 0).value.set('no') + assert cfg.option('od.stval1.st1.st1').value.get() == ['yes'] + assert cfg.option('od.stval1.st1.st2', 0).value.get() == 'no' + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.pop(0) - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.pop(0) + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - cfg.option('od.stval1.st1val1.st2val1', 0).value.reset() - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval2.st1.st1').owner.isdefault() + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + cfg.option('od.stval1.st1.st2', 0).value.reset() + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - cfg.option('od.stval1.st1val1.st1val1').value.reset() - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + cfg.option('od.stval1.st1.st1').value.reset() + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # assert not list_sessions() @@ -1751,25 +1751,25 @@ def test_leadership_callback_samegroup_dyndescription_convert(): od2 = OptionDescription('od', '', [od1]) cfg = Config(od2) owner = cfg.owner.get() - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [], 'od.stval2.st1val2.st1val2': []} - assert cfg.option('od.stval1.st1val1.st1val1').value.get() == [] - assert cfg.option('od.stval2.st1val2.st1val2').value.get() == [] - assert cfg.option('od.stval1.st1val1.st1val1').owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + assert cfg.value.get() == {'od.stval1.st1.st1': [], 'od.stval2.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').value.get() == [] + assert cfg.option('od.stval2.st1.st1').value.get() == [] + assert cfg.option('od.stval1.st1.st1').owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st1val1').value.set(['yes']) - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'yes', 'od.stval1.st1val1.st2val1': None, 'od.stval1.st1val1.st3val1': None}], 'od.stval2.st1val2.st1val2': []} - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.isdefault() - assert cfg.option('od.stval1.st1val1.st3val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st1').value.set(['yes']) + assert cfg.value.get() == {'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'yes', 'od.stval1.st1.st2': None, 'od.stval1.st1.st3': None}], 'od.stval2.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.isdefault() + assert cfg.option('od.stval1.st1.st3', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # - cfg.option('od.stval1.st1val1.st2val1', 0).value.set('yes') - assert cfg.value.dict() == {'od.stval1.st1val1.st1val1': [{'od.stval1.st1val1.st1val1': 'yes', 'od.stval1.st1val1.st2val1': 'yes', 'od.stval1.st1val1.st3val1': 'yes'}], 'od.stval2.st1val2.st1val2': []} - assert cfg.option('od.stval1.st1val1.st1val1').owner.get() == owner - assert cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner - assert cfg.option('od.stval1.st1val1.st3val1', 0).owner.isdefault() - assert cfg.option('od.stval2.st1val2.st1val2').owner.isdefault() + cfg.option('od.stval1.st1.st2', 0).value.set('yes') + assert cfg.value.get() == {'od.stval1.st1.st1': [{'od.stval1.st1.st1': 'yes', 'od.stval1.st1.st2': 'yes', 'od.stval1.st1.st3': 'yes'}], 'od.stval2.st1.st1': []} + assert cfg.option('od.stval1.st1.st1').owner.get() == owner + assert cfg.option('od.stval1.st1.st2', 0).owner.get() == owner + assert cfg.option('od.stval1.st1.st3', 0).owner.isdefault() + assert cfg.option('od.stval2.st1.st1').owner.isdefault() # assert not list_sessions() @@ -1782,15 +1782,15 @@ def test_dyn_with_leader_hidden_in_config(): cfg = Config(od1) cfg.property.read_write() cfg.permissive.add('hidden') - assert cfg.forcepermissive.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get() == [] - cfg.forcepermissive.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.1']) - assert cfg.forcepermissive.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None + assert cfg.forcepermissive.option('leaderval1.ip_admin_eth0.ip_admin_eth0').value.get() == [] + cfg.forcepermissive.option('leaderval1.ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1']) + assert cfg.forcepermissive.option('leaderval1.ip_admin_eth0.netmask_admin_eth0', 0).value.get() is None with pytest.raises(PropertiesOptionError): - cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get() + cfg.option('leaderval1.ip_admin_eth0.ip_admin_eth0').value.get() with pytest.raises(PropertiesOptionError): - cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() - cfg.value.dict() == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': [{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.1'}], - 'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': [{'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': '192.168.1.1'}]} + cfg.option('leaderval1.ip_admin_eth0.netmask_admin_eth0', 0).value.get() + cfg.value.get() == {'leaderval1.ip_admin_eth0.ip_admin_eth0': [{'leaderval1.ip_admin_eth0.ip_admin_eth0': '192.168.1.1'}], + 'leaderval2.ip_admin_eth0.ip_admin_eth0': [{'leaderval2.ip_admin_eth0.ip_admin_eth0': '192.168.1.1'}]} # assert not list_sessions() @@ -1808,32 +1808,32 @@ def test_dyn_leadership_requires(): od1 = OptionDescription('toto', '', [dyn]) cfg = Config(od1) cfg.property.read_write() - assert cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get() == [] - cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2']) - assert cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None - assert cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get() == ['192.168.1.2'] + assert cfg.option('leaderval1.ip_admin_eth0.ip_admin_eth0').value.get() == [] + cfg.option('leaderval1.ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2']) + assert cfg.option('leaderval1.ip_admin_eth0.netmask_admin_eth0', 0).value.get() is None + assert cfg.option('leaderval1.ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2'] # - cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2', '192.168.1.1']) - assert cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None + cfg.option('leaderval1.ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2', '192.168.1.1']) + assert cfg.option('leaderval1.ip_admin_eth0.netmask_admin_eth0', 0).value.get() is None with pytest.raises(PropertiesOptionError): - cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get() + cfg.option('leaderval1.ip_admin_eth0.netmask_admin_eth0', 1).value.get() # - cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2', '192.168.1.2']) - assert cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None - assert cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get() is None - cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.set('255.255.255.255') - assert cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get() == '255.255.255.255' - ret = cfg.value.dict() - assert ret == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': [{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.2', 'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': None}, - {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.2', 'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': '255.255.255.255'}], - 'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': []} + cfg.option('leaderval1.ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2', '192.168.1.2']) + assert cfg.option('leaderval1.ip_admin_eth0.netmask_admin_eth0', 0).value.get() is None + assert cfg.option('leaderval1.ip_admin_eth0.netmask_admin_eth0', 1).value.get() is None + cfg.option('leaderval1.ip_admin_eth0.netmask_admin_eth0', 1).value.set('255.255.255.255') + assert cfg.option('leaderval1.ip_admin_eth0.netmask_admin_eth0', 1).value.get() == '255.255.255.255' + ret = cfg.value.get() + assert ret == {'leaderval1.ip_admin_eth0.ip_admin_eth0': [{'leaderval1.ip_admin_eth0.ip_admin_eth0': '192.168.1.2', 'leaderval1.ip_admin_eth0.netmask_admin_eth0': None}, + {'leaderval1.ip_admin_eth0.ip_admin_eth0': '192.168.1.2', 'leaderval1.ip_admin_eth0.netmask_admin_eth0': '255.255.255.255'}], + 'leaderval2.ip_admin_eth0.ip_admin_eth0': []} # - cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2', '192.168.1.1']) - assert cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None + cfg.option('leaderval1.ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2', '192.168.1.1']) + assert cfg.option('leaderval1.ip_admin_eth0.netmask_admin_eth0', 0).value.get() is None with pytest.raises(PropertiesOptionError): - cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get() - assert cfg.value.dict() == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': [{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.2', 'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': None}, {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.1'}], 'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': []} + cfg.option('leaderval1.ip_admin_eth0.netmask_admin_eth0', 1).value.get() + assert cfg.value.get() == {'leaderval1.ip_admin_eth0.ip_admin_eth0': [{'leaderval1.ip_admin_eth0.ip_admin_eth0': '192.168.1.2', 'leaderval1.ip_admin_eth0.netmask_admin_eth0': None}, {'leaderval1.ip_admin_eth0.ip_admin_eth0': '192.168.1.1'}], 'leaderval2.ip_admin_eth0.ip_admin_eth0': []} # # assert not list_sessions() @@ -1861,7 +1861,7 @@ def test_dyn_symlink(): assert cfg.option('name').value.get() == ['a', 'b', 'c'] assert cfg.option('name').ismulti() == True assert cfg.option('name').issubmulti() == False - assert cfg.value.dict() == {'remotes': ['a', 'b', 'c'], 'remote_a.remote_ip_a': 'a', 'remote_b.remote_ip_b': 'b', 'remote_c.remote_ip_c': 'c', 'name': ['a', 'b', 'c']} + assert cfg.value.get() == {'remotes': ['a', 'b', 'c'], 'remote_a.remote_ip_': 'a', 'remote_b.remote_ip_': 'b', 'remote_c.remote_ip_': 'c', 'name': ['a', 'b', 'c']} # assert not list_sessions() @@ -1875,5 +1875,5 @@ def test_dyn_callback_with_not_dyn(): assert cfg.option('names').value.get() == ['a', 'b', 'c'] assert cfg.option('names').ismulti() == True assert cfg.option('names').issubmulti() == False - assert cfg.value.dict() == {'remotes': ['a', 'b', 'c'], 'remote_a.remote_ip_a': 'a', 'remote_b.remote_ip_b': 'b', 'remote_c.remote_ip_c': 'c', 'names': ['a', 'b', 'c']} + assert cfg.value.get() == {'remotes': ['a', 'b', 'c'], 'remote_a.remote_ip_': 'a', 'remote_b.remote_ip_': 'b', 'remote_c.remote_ip_': 'c', 'names': ['a', 'b', 'c']} # assert not list_sessions() diff --git a/tests/test_mandatory.py b/tests/test_mandatory.py index bfb889c..a5624b3 100644 --- a/tests/test_mandatory.py +++ b/tests/test_mandatory.py @@ -699,7 +699,7 @@ def test_mandatory_dyndescription(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) cfg.property.read_only() - compare(cfg.value.mandatory(), ['od.dodval1.stval1', 'od.dodval2.stval2']) + compare(cfg.value.mandatory(), ['od.dodval1.st', 'od.dodval2.st']) def test_mandatory_dyndescription_context(): @@ -710,7 +710,7 @@ def test_mandatory_dyndescription_context(): od2 = OptionDescription('od', '', [od]) cfg = Config(od2) cfg.property.read_only() - compare(cfg.value.mandatory(), ['od.dodval1.stval1', 'od.dodval2.stval2']) + compare(cfg.value.mandatory(), ['od.dodval1.st', 'od.dodval2.st']) def test_mandatory_callback_leader_and_followers_leader(): diff --git a/tiramisu/config.py b/tiramisu/config.py index 7dd1082..e12387d 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -197,33 +197,15 @@ class _SubConfig: resetted_opts, ): option = option_bag.option - if isinstance(option, (Option, Leadership)): - dynoption = option.getsubdyn() - if isinstance(option, Option): - rootpath = dynoption.impl_getpath() - subpaths = [rootpath] + option.impl_getpath()[len(rootpath) + 1:].split('.')[:-1] - elif isinstance(option, DynOptionDescription): - path = option.impl_getpath() - if '.' in path: - subpath = path.rsplit('.', 1)[0] - else: - subpath = '' + if isinstance(option, DynOptionDescription): dynoption = option - for suffix in dynoption.get_suffixes(option_bag.config_bag): - path_suffix = dynoption.convert_suffix_to_path(suffix) - if isinstance(option, Option): - subpath = '.'.join([subp + path_suffix for subp in subpaths]) - elif isinstance(option, Leadership): - subpath = option.impl_getpath() + path_suffix - doption = option.to_dynoption(subpath, - suffix, - dynoption, - ) - doption_bag = OptionBag(doption, - option_bag.index, - option_bag.config_bag, - properties=None, - ) + else: + dynoption = option.getsubdyn() + for doption_bag in dynoption.get_sub_children(option, + option_bag.config_bag, + option_bag.index, + properties=None + ): self.reset_one_option_cache(resetted_opts, doption_bag, ) @@ -493,23 +475,10 @@ class _SubConfig: suboption = option.impl_getopt() if suboption.issubdyn(): dynopt = suboption.getsubdyn() - rootpath = dynopt.impl_getpath() - subpaths = [rootpath] + suboption.impl_getpath()[len(rootpath) + 1:].split('.')[:-1] - ret = [] - for suffix in dynopt.get_suffixes(option_bag.config_bag): - path_suffix = dynopt.convert_suffix_to_path(suffix) - subpath = '.'.join([subp + path_suffix for subp in subpaths]) - doption = suboption.to_dynoption(subpath, - suffix, - dynopt, - ) - doption_bag = OptionBag(doption, - option_bag.index, - option_bag.config_bag, - ori_option=option - ) - ret.append(doption_bag) - return ret + return list(dynopt.get_sub_children(suboption, + option_bag.config_bag, + option_bag.index, + )) if suboption.impl_is_follower(): options_bag = self.get_sub_option_bag(option_bag.config_bag, # pylint: disable=no-member suboption.impl_getpath(), diff --git a/tiramisu/option/dynoptiondescription.py b/tiramisu/option/dynoptiondescription.py index 07b294e..86c7a34 100644 --- a/tiramisu/option/dynoptiondescription.py +++ b/tiramisu/option/dynoptiondescription.py @@ -30,7 +30,7 @@ from ..autolib import ParamOption from ..i18n import _ from .optiondescription import OptionDescription from .baseoption import BaseOption -from ..setting import OptionBag, ConfigBag +from ..setting import OptionBag, ConfigBag, undefined from ..error import ConfigError from ..autolib import Calculation @@ -118,3 +118,31 @@ class DynOptionDescription(OptionDescription): def impl_is_dynoptiondescription(self) -> bool: return True + + def get_sub_children(self, + option, + config_bag, + index=None, + properties=undefined, + ): + if option == self: + rootpath = self.impl_getpath().rsplit('.', 1)[0] + else: + rootpath = self.impl_getpath() + subpath = option.impl_getpath()[len(rootpath):].rsplit('.', 1)[0] + for suffix in self.get_suffixes(config_bag): + path_suffix = self.convert_suffix_to_path(suffix) + if option == self: + parent_path = rootpath + else: + parent_path = rootpath + path_suffix + subpath + doption_bag = OptionBag(option.to_dynoption(parent_path, + suffix, + self, + ), + index, + config_bag, + properties=properties, + ori_option=option + ) + yield doption_bag diff --git a/tiramisu/option/optiondescription.py b/tiramisu/option/optiondescription.py index 37ad394..0d31088 100644 --- a/tiramisu/option/optiondescription.py +++ b/tiramisu/option/optiondescription.py @@ -125,21 +125,10 @@ class CacheOptionDescription(BaseOption): def do_option_bags(option): if option.issubdyn(): dynopt = option.getsubdyn() - rootpath = dynopt.impl_getpath() - subpaths = [rootpath] + option.impl_getpath()[len(rootpath) + 1:].split('.')[1:] - for suffix in dynopt.get_suffixes(config_bag): - path_suffix = dynopt.convert_suffix_to_path(suffix) - subpath = '.'.join([subp + path_suffix for subp in subpaths]) - doption = option.to_dynoption(subpath, - suffix, - dynopt, - ) - doption_bag = OptionBag(doption, - None, - config_bag, - properties=None, - ) - yield doption_bag + yield from dynopt.get_sub_children(option, + config_bag, + None, + ) else: option_bag = OptionBag(option, None, @@ -211,7 +200,7 @@ class OptionDescriptionWalk(CacheOptionDescription): # if not dyn if name in self._children[0]: # pylint: disable=no-member option = self._children[1][self._children[0].index(name)] # pylint: disable=no-member - if option.issubdyn(): + if option.impl_is_dynoptiondescription(): raise AttributeError(_(f'unknown option "{name}" ' "in root optiondescription (it's a dynamic option)" )) diff --git a/tiramisu/option/syndynoption.py b/tiramisu/option/syndynoption.py index 17c616d..71a72aa 100644 --- a/tiramisu/option/syndynoption.py +++ b/tiramisu/option/syndynoption.py @@ -53,7 +53,8 @@ class SynDynOption: def impl_getname(self) -> str: """get option name """ - return self.opt.impl_getname() + self.dyn_parent.convert_suffix_to_path(self.suffix) + return self.opt.impl_getname() + #return self.opt.impl_getname() + self.dyn_parent.convert_suffix_to_path(self.suffix) def impl_get_display_name(self) -> str: """get option display name diff --git a/tiramisu/option/syndynoptiondescription.py b/tiramisu/option/syndynoptiondescription.py index ae2cf50..242f8ee 100644 --- a/tiramisu/option/syndynoptiondescription.py +++ b/tiramisu/option/syndynoptiondescription.py @@ -65,18 +65,15 @@ class SynDynOptionDescription: """get child by name """ # pylint: disable=unused-argument - suffix = self.ori_dyn.convert_suffix_to_path(self._suffix) - if name.endswith(suffix): - oname = name[:-len(suffix)] - try: - child = self._children[1][self._children[0].index(oname)] - except ValueError: - # when oname not in self._children - pass - else: - return child.to_dynoption(subpath, - self._suffix, - self.ori_dyn) + try: + child = self._children[1][self._children[0].index(name)] + except ValueError: + # when name not in self._children + pass + else: + return child.to_dynoption(subpath, + self._suffix, + self.ori_dyn) raise AttributeError(_('unknown option "{0}" ' 'in dynamic optiondescription "{1}"' '').format(name, self.impl_get_display_name())) @@ -84,6 +81,8 @@ class SynDynOptionDescription: def impl_getname(self) -> str: """get name """ + if isinstance(self, SynDynLeadership): + return self.opt.impl_getname() return self.opt.impl_getname() + self.ori_dyn.convert_suffix_to_path(self._suffix) def get_children(self, diff --git a/tiramisu/value.py b/tiramisu/value.py index 27f6302..d16c52b 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -350,11 +350,8 @@ class Values: rootpath = option.impl_getpath() for suffix in option.get_suffixes(option_bag.config_bag): for coption in force_store_options: - subpaths = [rootpath] + \ - coption.impl_getpath()[len(rootpath) + 1:].split('.')[:-1] - path_suffix = option.convert_suffix_to_path(suffix) - subpath = '.'.join([subp + path_suffix for subp in subpaths]) - doption = coption.to_dynoption(subpath, + parent_subpath = rootpath + suffix + coption.impl_getpath()[len(rootpath):].rsplit('.', 1)[0] + doption = coption.to_dynoption(parent_subpath, suffix, option, )