make_dict => dict, option.dict => config.dict
This commit is contained in:
parent
6ceeb43962
commit
726d6c8bfd
|
@ -631,13 +631,13 @@ def autocheck_display(cfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
|||
return
|
||||
make_dict = kwargs['make_dict']
|
||||
make_dict_value = kwargs['make_dict_value']
|
||||
assert cfg.config(confread).option.make_dict() == make_dict
|
||||
assert cfg.config(confread).config.dict() == make_dict
|
||||
if confread != confwrite:
|
||||
assert(cfg.config(confwrite).option.make_dict()) == make_dict
|
||||
assert(cfg.config(confwrite).config.dict()) == make_dict
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
assert cfg.config(confread).option.make_dict() == make_dict_value
|
||||
assert cfg.config(confread).config.dict() == make_dict_value
|
||||
if confread != confwrite:
|
||||
assert(cfg.config(confwrite).option.make_dict()) == make_dict_value
|
||||
assert(cfg.config(confwrite).config.dict()) == make_dict_value
|
||||
|
||||
|
||||
def _getproperties(multi, isslave, kwargs):
|
||||
|
|
|
@ -64,11 +64,11 @@ def test_cache_importation():
|
|||
cfg = Config(od1)
|
||||
cfg.option('u2').value.set(1)
|
||||
export = cfg.value.exportation()
|
||||
assert cfg.option.make_dict() == {'u1': [], 'u2': 1, 'u3': []}
|
||||
assert cfg.config.dict() == {'u1': [], 'u2': 1, 'u3': []}
|
||||
cfg.option('u2').value.set(2)
|
||||
assert cfg.option.make_dict() == {'u1': [], 'u2': 2, 'u3': []}
|
||||
assert cfg.config.dict() == {'u1': [], 'u2': 2, 'u3': []}
|
||||
cfg.value.importation(export)
|
||||
assert cfg.option.make_dict() == {'u1': [], 'u2': 1, 'u3': []}
|
||||
assert cfg.config.dict() == {'u1': [], 'u2': 1, 'u3': []}
|
||||
|
||||
|
||||
def test_cache_importation_property():
|
||||
|
@ -328,7 +328,7 @@ def test_cache_callback():
|
|||
cfg.property.read_write()
|
||||
if TIRAMISU_VERSION == 2:
|
||||
cfg.property.pop('expire')
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)}}
|
||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('val', None)},
|
||||
|
@ -341,7 +341,7 @@ def test_cache_callback():
|
|||
# 'val1': {None: (set([]), None)}}
|
||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val3': {None: ('yes', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)}}
|
||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||
|
@ -357,7 +357,7 @@ def test_cache_callback():
|
|||
'val2': {None: ('new', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)},
|
||||
# 'val3': {None: (set([]), None)}}
|
||||
|
@ -375,7 +375,7 @@ def test_cache_callback():
|
|||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)},
|
||||
# 'val3': {None: (set([]), None)},
|
||||
|
@ -395,7 +395,7 @@ def test_cache_callback():
|
|||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)}})
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)},
|
||||
# 'val3': {None: (set([]), None)},
|
||||
|
@ -416,7 +416,7 @@ def test_cache_master_and_slaves_master():
|
|||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.property.read_write()
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
global_props = ['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']
|
||||
val1_props = []
|
||||
val1_val1_props = ['empty']
|
||||
|
@ -449,7 +449,7 @@ def test_cache_master_and_slaves_master():
|
|||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)}})
|
||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
if TIRAMISU_VERSION == 2:
|
||||
val_val2 = [None]
|
||||
val_val2_props = {None: (set(), None), 0: (set(), None)}
|
||||
|
@ -465,7 +465,7 @@ def test_cache_master_and_slaves_master():
|
|||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([None], None)},
|
||||
'val1.val2': {idx_val2: (val_val2, None)}})
|
||||
cfg.option('val1.val1').value.set([undefined, undefined])
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
cfg.option('val1.val2', 1).value.set('oui')
|
||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)}})
|
||||
|
@ -494,7 +494,7 @@ def test_cache_master_callback():
|
|||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.property.read_write()
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
global_props = ['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']
|
||||
val1_props = []
|
||||
val1_val1_props = ['empty']
|
||||
|
@ -524,7 +524,7 @@ def test_cache_master_callback():
|
|||
'val1': {None: (set([]), None)}})
|
||||
|
||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
#FIXMEassert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)}}
|
||||
#FIXMEassert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None], None)},
|
||||
|
@ -552,7 +552,7 @@ def test_cache_requires():
|
|||
else:
|
||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
||||
'activate_service': {None: (True, None)}})
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set([]), None)}})
|
||||
|
@ -564,7 +564,7 @@ def test_cache_requires():
|
|||
'activate_service': {None: (set([]), None)}})
|
||||
|
||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (True, None)}})
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set([]), None)}})
|
||||
|
@ -575,7 +575,7 @@ def test_cache_requires():
|
|||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}})
|
||||
|
||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||
cfg.option.make_dict()
|
||||
cfg.config.dict()
|
||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set(['disabled']), None)}})
|
||||
|
|
|
@ -64,16 +64,16 @@ def test_make_dict():
|
|||
config = Config(descr)
|
||||
config.property.read_write()
|
||||
config.permissive.set(frozenset(['hidden']))
|
||||
d = config.option.make_dict()
|
||||
d = config.config.dict()
|
||||
assert d == {"s1.a": False, "int": 42}
|
||||
config.option('int').value.set(43)
|
||||
config.option('s1.a').value.set(True)
|
||||
d = config.option.make_dict()
|
||||
d = config.config.dict()
|
||||
assert d == {"s1.a": True, "int": 43}
|
||||
d2 = config.option.make_dict(flatten=True)
|
||||
d2 = config.config.dict(flatten=True)
|
||||
assert d2 == {'a': True, 'int': 43}
|
||||
raises(ValueError, 'd2 = config.option.make_dict(withvalue="3")')
|
||||
d = config.forcepermissive.option.make_dict()
|
||||
raises(ValueError, 'd2 = config.config.dict(withvalue="3")')
|
||||
d = config.forcepermissive.config.dict()
|
||||
assert d == {"s1.a": True, "s1.b": False, "int": 43}
|
||||
|
||||
|
||||
|
@ -88,9 +88,9 @@ def test_make_dict_with_disabled():
|
|||
IntOption("int", "", default=42)])
|
||||
config = Config(descr)
|
||||
config.property.read_only()
|
||||
assert config.option.make_dict() == {"s1.a": False, "int": 42}
|
||||
assert config.forcepermissive.option.make_dict() == {"s1.a": False, "int": 42}
|
||||
assert config.unrestraint.option.make_dict() == {"int": 42, "s1.a": False, "s1.b": False, "s2.a": False, "s2.b": False}
|
||||
assert config.config.dict() == {"s1.a": False, "int": 42}
|
||||
assert config.forcepermissive.config.dict() == {"s1.a": False, "int": 42}
|
||||
assert config.unrestraint.config.dict() == {"int": 42, "s1.a": False, "s1.b": False, "s2.a": False, "s2.b": False}
|
||||
|
||||
|
||||
def test_make_dict_with_disabled_withoption():
|
||||
|
@ -104,9 +104,9 @@ def test_make_dict_with_disabled_withoption():
|
|||
IntOption("int", "", default=42)])
|
||||
config = Config(descr)
|
||||
config.property.read_only()
|
||||
assert config.option.make_dict(withoption="a") == {"s1.a": False}
|
||||
assert config.forcepermissive.option.make_dict(withoption="a") == {"s1.a": False}
|
||||
assert config.unrestraint.option.make_dict(withoption="a") == {"s1.a": False, "s1.b": False, "s2.a": False, "s2.b": False}
|
||||
assert config.config.dict(withoption="a") == {"s1.a": False}
|
||||
assert config.forcepermissive.config.dict(withoption="a") == {"s1.a": False}
|
||||
assert config.unrestraint.config.dict(withoption="a") == {"s1.a": False, "s1.b": False, "s2.a": False, "s2.b": False}
|
||||
|
||||
|
||||
def test_make_dict_with_disabled_in_callback():
|
||||
|
@ -120,7 +120,7 @@ def test_make_dict_with_disabled_in_callback():
|
|||
IntOption("int", "", default=42)])
|
||||
config = Config(descr)
|
||||
config.property.read_only()
|
||||
d = config.option.make_dict()
|
||||
d = config.config.dict()
|
||||
assert d == {"s1.a": False, "int": 42}
|
||||
|
||||
|
||||
|
@ -137,10 +137,10 @@ def test_make_dict_fullpath():
|
|||
IntOption("introot", "", default=42)])
|
||||
config = Config(descr)
|
||||
config.property.read_only()
|
||||
assert config.option.make_dict() == {"opt.s1.a": False, "opt.int": 42, "introot": 42}
|
||||
assert config.option('opt').make_dict() == {"s1.a": False, "int": 42}
|
||||
assert config.option.make_dict(fullpath=True) == {"opt.s1.a": False, "opt.int": 42, "introot": 42}
|
||||
assert config.option('opt').make_dict(fullpath=True) == {"opt.s1.a": False, "opt.int": 42}
|
||||
assert config.config.dict() == {"opt.s1.a": False, "opt.int": 42, "introot": 42}
|
||||
assert config.option('opt').dict() == {"s1.a": False, "int": 42}
|
||||
assert config.config.dict(fullpath=True) == {"opt.s1.a": False, "opt.int": 42, "introot": 42}
|
||||
assert config.option('opt').dict(fullpath=True) == {"opt.s1.a": False, "opt.int": 42}
|
||||
|
||||
|
||||
def test_find_in_config():
|
||||
|
|
|
@ -57,7 +57,7 @@ def test_build_dyndescription():
|
|||
dod = DynOptionDescription('dod', '', [st1], callback=return_list)
|
||||
od1 = OptionDescription('od', '', [dod])
|
||||
cfg = Config(od1)
|
||||
assert cfg.option.make_dict() == {'dodval1.stval1': None, 'dodval2.stval2': None}
|
||||
assert cfg.config.dict() == {'dodval1.stval1': None, 'dodval2.stval2': None}
|
||||
|
||||
|
||||
def test_build_dyndescription_raise():
|
||||
|
@ -65,7 +65,7 @@ def test_build_dyndescription_raise():
|
|||
dod = DynOptionDescription('dod', '', [st1], callback=return_raise)
|
||||
od1 = OptionDescription('od', '', [dod])
|
||||
cfg = Config(od1)
|
||||
raises(ConfigError, "cfg.option.make_dict()")
|
||||
raises(ConfigError, "cfg.config.dict()")
|
||||
|
||||
|
||||
def test_build_dyndescription_not_list():
|
||||
|
@ -73,7 +73,7 @@ def test_build_dyndescription_not_list():
|
|||
dod = DynOptionDescription('dod', '', [st1], callback=return_str)
|
||||
od1 = OptionDescription('od', '', [dod])
|
||||
cfg = Config(od1)
|
||||
raises(ValueError, "cfg.option.make_dict()")
|
||||
raises(ValueError, "cfg.config.dict()")
|
||||
|
||||
|
||||
def test_subpath_dyndescription():
|
||||
|
@ -82,7 +82,7 @@ def test_subpath_dyndescription():
|
|||
od1 = OptionDescription('od', '', [dod])
|
||||
od2 = OptionDescription('od', '', [od1])
|
||||
api = Config(od2)
|
||||
assert api.option.make_dict() == {'od.dodval1.stval1': None, 'od.dodval2.stval2': None}
|
||||
assert api.config.dict() == {'od.dodval1.stval1': None, 'od.dodval2.stval2': None}
|
||||
|
||||
|
||||
def test_list_dyndescription():
|
||||
|
@ -290,7 +290,7 @@ def test_build_dyndescription_context():
|
|||
dod = DynOptionDescription('dod', '', [st1], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od1 = OptionDescription('od', '', [dod, val1])
|
||||
cfg = Config(od1)
|
||||
assert cfg.option.make_dict() == {'dodval1.stval1': None, 'dodval2.stval2': None, 'val1': ['val1', 'val2']}
|
||||
assert cfg.config.dict() == {'dodval1.stval1': None, 'dodval2.stval2': None, 'val1': ['val1', 'val2']}
|
||||
|
||||
|
||||
def test_subpath_dyndescription_context():
|
||||
|
@ -300,7 +300,7 @@ def test_subpath_dyndescription_context():
|
|||
od1 = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od1])
|
||||
api = Config(od2)
|
||||
assert api.option.make_dict() == {'od.dodval1.stval1': None, 'od.dodval2.stval2': None, 'od.val1': ['val1', 'val2']}
|
||||
assert api.config.dict() == {'od.dodval1.stval1': None, 'od.dodval2.stval2': None, 'od.val1': ['val1', 'val2']}
|
||||
|
||||
|
||||
def test_list_dyndescription_context():
|
||||
|
@ -637,11 +637,11 @@ def test_makedict_dyndescription_context():
|
|||
od2 = OptionDescription('od', '', [od])
|
||||
api = Config(od2)
|
||||
api.option('od.dodval1.stval1').value.set('yes')
|
||||
assert api.option.make_dict() == {'od.val1': ['val1', 'val2'], 'od.dodval1.stval1': 'yes', 'od.dodval2.stval2': None}
|
||||
assert api.option.make_dict(flatten=True) == {'val1': ['val1', 'val2'], 'stval1': 'yes', 'stval2': None}
|
||||
assert api.option.make_dict(withoption='stval1') == {'od.dodval1.stval1': 'yes'}
|
||||
assert api.option('od').make_dict(withoption='stval1') == {'dodval1.stval1': 'yes'}
|
||||
assert api.option('od.dodval1').make_dict(withoption='stval1') == {'stval1': 'yes'}
|
||||
assert api.config.dict() == {'od.val1': ['val1', 'val2'], 'od.dodval1.stval1': 'yes', 'od.dodval2.stval2': None}
|
||||
assert api.config.dict(flatten=True) == {'val1': ['val1', 'val2'], 'stval1': 'yes', 'stval2': None}
|
||||
assert api.config.dict(withoption='stval1') == {'od.dodval1.stval1': 'yes'}
|
||||
assert api.option('od').dict(withoption='stval1') == {'dodval1.stval1': 'yes'}
|
||||
assert api.option('od.dodval1').dict(withoption='stval1') == {'stval1': 'yes'}
|
||||
|
||||
|
||||
def test_find_dyndescription_context():
|
||||
|
@ -901,14 +901,14 @@ def test_masterslaves_dyndescription():
|
|||
api = Config(od2)
|
||||
owner = api.owner.get()
|
||||
#
|
||||
assert api.option.make_dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': []}
|
||||
assert api.config.dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': []}
|
||||
assert api.option('od.stval1.st1val1.st1val1').value.get() == []
|
||||
assert api.option('od.stval2.st1val2.st1val2').value.get() == []
|
||||
assert api.option('od.stval1.st1val1.st1val1').owner.isdefault()
|
||||
assert api.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||
#
|
||||
api.option('od.stval1.st1val1.st1val1').value.set(['yes'])
|
||||
assert api.option.make_dict() == {'od.stval1.st1val1.st2val1': [None], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes']}
|
||||
assert api.config.dict() == {'od.stval1.st1val1.st2val1': [None], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes']}
|
||||
assert api.option('od.stval1.st1val1.st1val1').value.get() == ['yes']
|
||||
assert api.option('od.stval1.st1val1.st2val1', 0).value.get() == None
|
||||
assert api.option('od.stval2.st1val2.st1val2').value.get() == []
|
||||
|
@ -983,14 +983,14 @@ def test_masterslaves_dyndescription_param():
|
|||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
owner = cfg.owner.get()
|
||||
assert cfg.option.make_dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': [], 'od.odval1.val1': ['val1', 'val2']}
|
||||
assert cfg.config.dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': [], '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
|
||||
#
|
||||
cfg.option('od.stval1.st1val1.st1val1').value.set(['yes'])
|
||||
assert cfg.option.make_dict() == {'od.stval1.st1val1.st2val1': [None], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes'], 'od.odval1.val1': ['val1', 'val2']}
|
||||
assert cfg.config.dict() == {'od.stval1.st1val1.st2val1': [None], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes'], '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() == []
|
||||
|
@ -1061,14 +1061,14 @@ def _test_masterslaves(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.option.make_dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': [], 'od.val1.val1': ['val1', 'val2'], 'od.val1.val2': ['val1', 'val2']}
|
||||
assert cfg.config.dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': [], 'od.val1.val1': ['val1', 'val2'], 'od.val1.val2': ['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
|
||||
#
|
||||
cfg.option('od.stval1.st1val1.st1val1').value.set(['yes'])
|
||||
assert cfg.option.make_dict() == {'od.stval1.st1val1.st2val1': [None], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes'], 'od.val1.val1': ['val1', 'val2'], 'od.val1.val2': ['val1', 'val2']}
|
||||
assert cfg.config.dict() == {'od.stval1.st1val1.st2val1': [None], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes'], 'od.val1.val1': ['val1', 'val2'], 'od.val1.val2': ['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() == []
|
||||
|
@ -1270,14 +1270,14 @@ def test_masterslaves_callback_dyndescription():
|
|||
od2 = OptionDescription('od', '', [od1])
|
||||
api = Config(od2)
|
||||
owner = api.owner.get()
|
||||
assert api.option.make_dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': []}
|
||||
assert api.config.dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': []}
|
||||
assert api.option('od.stval1.st1val1.st1val1').value.get() ==[]
|
||||
assert api.option('od.stval2.st1val2.st1val2').value.get() == []
|
||||
assert api.option('od.stval1.st1val1.st1val1').owner.isdefault()
|
||||
assert api.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||
#
|
||||
api.option('od.stval1.st1val1.st1val1').value.set(['yes'])
|
||||
assert api.option.make_dict() == {'od.stval1.st1val1.st2val1': ['yes'], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes']}
|
||||
assert api.config.dict() == {'od.stval1.st1val1.st2val1': ['yes'], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes']}
|
||||
assert api.option('od.stval1.st1val1.st1val1').value.get() == ['yes']
|
||||
assert api.option('od.stval1.st1val1.st2val1', 0).value.get() == 'yes'
|
||||
assert api.option('od.stval2.st1val2.st1val2').value.get() == []
|
||||
|
@ -1362,7 +1362,7 @@ def test_masterslaves_callback_samegroup_dyndescription():
|
|||
od2 = OptionDescription('od', '', [od1])
|
||||
api = Config(od2)
|
||||
owner = api.owner.get()
|
||||
assert api.option.make_dict() == {'od.stval1.st1val1.st1val1': [],
|
||||
assert api.config.dict() == {'od.stval1.st1val1.st1val1': [],
|
||||
'od.stval1.st1val1.st2val1': [],
|
||||
'od.stval1.st1val1.st3val1': [],
|
||||
'od.stval2.st1val2.st1val2': [],
|
||||
|
@ -1374,7 +1374,7 @@ def test_masterslaves_callback_samegroup_dyndescription():
|
|||
assert api.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||
#
|
||||
api.option('od.stval1.st1val1.st1val1').value.set(['yes'])
|
||||
assert api.option.make_dict() == {'od.stval1.st1val1.st1val1': ['yes'],
|
||||
assert api.config.dict() == {'od.stval1.st1val1.st1val1': ['yes'],
|
||||
'od.stval1.st1val1.st2val1': [None],
|
||||
'od.stval1.st1val1.st3val1': [None],
|
||||
'od.stval2.st1val2.st1val2': [],
|
||||
|
@ -1386,7 +1386,7 @@ def test_masterslaves_callback_samegroup_dyndescription():
|
|||
assert api.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||
#
|
||||
api.option('od.stval1.st1val1.st2val1', 0).value.set('yes')
|
||||
assert api.option.make_dict() == {'od.stval1.st1val1.st1val1': ['yes'],
|
||||
assert api.config.dict() == {'od.stval1.st1val1.st1val1': ['yes'],
|
||||
'od.stval1.st1val1.st2val1': ['yes'],
|
||||
'od.stval1.st1val1.st3val1': ['yes'],
|
||||
'od.stval2.st1val2.st1val2': [],
|
||||
|
@ -1439,7 +1439,7 @@ def test_invalid_samevalue_dyndescription():
|
|||
dod = DynOptionDescription('dod', '', [st1], callback=return_same_list)
|
||||
od1 = OptionDescription('od', '', [dod])
|
||||
cfg = Config(od1)
|
||||
raises(ValueError, "cfg.option.make_dict()")
|
||||
raises(ValueError, "cfg.config.dict()")
|
||||
|
||||
|
||||
def test_invalid_name_dyndescription():
|
||||
|
@ -1447,4 +1447,4 @@ def test_invalid_name_dyndescription():
|
|||
dod = DynOptionDescription('dod', '', [st1], callback=return_wrong_list)
|
||||
od1 = OptionDescription('od', '', [dod])
|
||||
cfg = Config(od1)
|
||||
raises(ValueError, "cfg.option.make_dict()")
|
||||
raises(ValueError, "cfg.config.dict()")
|
||||
|
|
|
@ -70,12 +70,12 @@ def test_base_config():
|
|||
'general.mode_conteneur_actif': False, 'general.time_zone': 'Paris',
|
||||
'interface1.ip_admin_eth0.netmask_admin_eth0': None, 'general.nom_machine':
|
||||
'eoleng', 'general.activer_proxy_client': False}
|
||||
assert api.option('creole').make_dict() == result
|
||||
assert api.option('creole').dict() == result
|
||||
result = {'serveur_ntp': [], 'mode_conteneur_actif': False,
|
||||
'ip_admin_eth0': None, 'time_zone': 'Paris', 'numero_etab': None,
|
||||
'netmask_admin_eth0': None, 'nom_machine': 'eoleng', 'activer_proxy_client':
|
||||
False, 'nombre_interfaces': 1}
|
||||
assert api.option('creole').make_dict(flatten=True) == result
|
||||
assert api.option('creole').dict(flatten=True) == result
|
||||
|
||||
|
||||
def test_make_dict_filter():
|
||||
|
@ -89,10 +89,10 @@ def test_make_dict_filter():
|
|||
result = {}
|
||||
for key, value in subresult.items():
|
||||
result['general.' + key] = value
|
||||
assert api.option('creole').make_dict(withoption='numero_etab') == result
|
||||
raises(AttributeError, "api.option('creole').make_dict(withoption='numero_etab', withvalue='toto')")
|
||||
assert api.option('creole').make_dict(withoption='numero_etab', withvalue=None) == result
|
||||
assert api.option('creole.general').make_dict(withoption='numero_etab') == subresult
|
||||
assert api.option('creole').dict(withoption='numero_etab') == result
|
||||
raises(AttributeError, "api.option('creole').dict(withoption='numero_etab', withvalue='toto')")
|
||||
assert api.option('creole').dict(withoption='numero_etab', withvalue=None) == result
|
||||
assert api.option('creole.general').dict(withoption='numero_etab') == subresult
|
||||
|
||||
|
||||
def test_get_group_type():
|
||||
|
@ -220,9 +220,9 @@ def test_groups_with_master_make_dict():
|
|||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od = OptionDescription('root', '', [interface1])
|
||||
api = Config(od)
|
||||
assert api.option.make_dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': []}
|
||||
assert api.config.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': []}
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['ip1', 'ip2'])
|
||||
assert api.option.make_dict() == {'ip_admin_eth0.ip_admin_eth0': ['ip1', 'ip2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None]}
|
||||
assert api.config.dict() == {'ip_admin_eth0.ip_admin_eth0': ['ip1', 'ip2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None]}
|
||||
|
||||
|
||||
def test_groups_with_master_hidden_in_config():
|
||||
|
|
|
@ -133,7 +133,7 @@ def test_find():
|
|||
assert len(ret) == 1
|
||||
assert 1 == ret[0].value.get()
|
||||
assert 1 == meta.option.find('i2', first=True).value.get()
|
||||
assert meta.option.make_dict() == {'od1.i4': 2, 'od1.i1': None, 'od1.i3': None,
|
||||
assert meta.config.dict() == {'od1.i4': 2, 'od1.i1': None, 'od1.i3': None,
|
||||
'od1.i2': 1, 'od1.i5': [2]}
|
||||
|
||||
|
||||
|
@ -580,7 +580,7 @@ def test_meta_properties_meta():
|
|||
conf2 = Config(od, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.property.read_write()
|
||||
assert meta.config('conf1').option.make_dict() == {}
|
||||
assert meta.config('conf1').config.dict() == {}
|
||||
|
||||
|
||||
def test_meta_exception_meta():
|
||||
|
@ -606,17 +606,17 @@ def test_meta_callback():
|
|||
cfg = Config(maconfig, session_id='cfg')
|
||||
meta = MetaConfig([cfg])
|
||||
meta.property.read_write()
|
||||
assert meta.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'val', 'val1': 'val', 'val5': 'yes', 'val4': 'val'}
|
||||
assert meta.config('cfg').config.dict() == {'val3': 'yes', 'val2': 'val', 'val1': 'val', 'val5': 'yes', 'val4': 'val'}
|
||||
meta.config('cfg').option('val1').value.set('new')
|
||||
#assert meta.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||
#assert meta.config('cfg').config.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||
#meta.config('cfg').option('val1').value.reset()
|
||||
#meta.option('val1').value.set('new')
|
||||
#assert meta.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||
#assert meta.config('cfg').config.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||
#meta.config('cfg').option('val4').value.set('new1')
|
||||
#assert meta.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||
#assert meta.config('cfg').config.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||
#meta.config('cfg').option('val4').value.reset()
|
||||
#meta.option('val4').value.set('new1')
|
||||
#assert meta.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||
#assert meta.config('cfg').config.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||
#meta.option('val4').value.reset()
|
||||
|
||||
|
||||
|
@ -631,36 +631,36 @@ def test_meta_callback_slave():
|
|||
cfg = Config(maconfig, session_id='cfg1')
|
||||
meta = MetaConfig([cfg])
|
||||
meta.property.read_write()
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.config('cfg1').option('val').value.set('val1')
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||
meta.config('cfg1').option('val').value.reset()
|
||||
meta.option('val').value.set('val1')
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||
meta.option('val').value.reset()
|
||||
meta.config('cfg1').option('val1.val2', 0).value.set('val2')
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.config('cfg1').option('val1.val2', 0).value.reset()
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.option('val1.val2', 0).value.set('val2')
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.config('cfg1').option('val1.val3', 0).value.set('val6')
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val6'], 'val': 'val'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val6'], 'val': 'val'}
|
||||
meta.option('val1.val2', 0).value.reset()
|
||||
meta.config('cfg1').option('val1.val3', 0).value.reset()
|
||||
meta.config('cfg1').option('val1.val1').value.set(['val3'])
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
meta.config('cfg1').option('val1.val1').value.reset()
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.option('val1.val1').value.set(['val3'])
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
meta.config('cfg1').option('val1.val2', 0).value.set('val2')
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
meta.option('val1.val1').value.set(['val3', 'rah'])
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
||||
meta.option('val1.val1').value.pop(1)
|
||||
meta.option('val1.val1').value.set(['val4'])
|
||||
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val4'], 'val1.val3': ['val4'], 'val': 'val'}
|
||||
assert meta.config('cfg1').config.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val4'], 'val1.val3': ['val4'], 'val': 'val'}
|
||||
|
||||
|
||||
def test_meta_reset():
|
||||
|
@ -699,7 +699,7 @@ def test_meta_properties_meta_set_value():
|
|||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.property.read_write()
|
||||
assert meta.config('conf1').option.make_dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||
assert meta.config('conf1').config.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||
ret = meta.value.set('netmask_admin_eth0', ['255.255.255.255'], only_config=True)
|
||||
assert len(ret) == 2
|
||||
assert isinstance(ret[0], PropertiesOptionError)
|
||||
|
|
|
@ -244,7 +244,7 @@ def test_consistency_not_equal_masterslave():
|
|||
api.option('a.b', 0).value.set(2)
|
||||
api.option('a.a').value.reset()
|
||||
api.option('a.a').value.set([1])
|
||||
api.option.make_dict()
|
||||
api.config.dict()
|
||||
|
||||
|
||||
def test_consistency_not_equal_masterslave_error_multi1():
|
||||
|
@ -839,7 +839,7 @@ def test_consistency_network_netmask_mandatory():
|
|||
api = Config(od2)
|
||||
api.property.read_only()
|
||||
api.property.pop('mandatory')
|
||||
api.option.make_dict()
|
||||
api.config.dict()
|
||||
|
||||
|
||||
def test_consistency_has_dependency():
|
||||
|
|
|
@ -99,7 +99,7 @@ def test_default_with_multi():
|
|||
def test_idontexist():
|
||||
descr = make_description()
|
||||
api = Config(descr)
|
||||
api.option.make_dict()
|
||||
api.config.dict()
|
||||
raises(AttributeError, "api.option('idontexist').value.get()")
|
||||
|
||||
|
||||
|
|
|
@ -948,13 +948,13 @@ def test_master_slave_requires():
|
|||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() is None
|
||||
api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.set('255.255.255.255')
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() == '255.255.255.255'
|
||||
assert api.option.make_dict() == {'ip_admin_eth0.ip_admin_eth0': ['192.168.1.2', '192.168.1.2'],
|
||||
assert api.config.dict() == {'ip_admin_eth0.ip_admin_eth0': ['192.168.1.2', '192.168.1.2'],
|
||||
'ip_admin_eth0.netmask_admin_eth0': [None, '255.255.255.255']}
|
||||
#
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2', '192.168.1.1'])
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() is None
|
||||
raises(PropertiesOptionError, "api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get()")
|
||||
ret = api.option.make_dict()
|
||||
ret = api.config.dict()
|
||||
assert set(ret.keys()) == set(['ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
||||
assert ret['ip_admin_eth0.ip_admin_eth0'] == ['192.168.1.2', '192.168.1.1']
|
||||
assert len(ret['ip_admin_eth0.netmask_admin_eth0']) == 2
|
||||
|
@ -962,7 +962,7 @@ def test_master_slave_requires():
|
|||
assert isinstance(ret['ip_admin_eth0.netmask_admin_eth0'][1], PropertiesOptionError)
|
||||
#
|
||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.255')
|
||||
ret = api.option.make_dict()
|
||||
ret = api.config.dict()
|
||||
assert set(ret.keys()) == set(['ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
||||
assert ret['ip_admin_eth0.ip_admin_eth0'] == ['192.168.1.2', '192.168.1.1']
|
||||
assert len(ret['ip_admin_eth0.netmask_admin_eth0']) == 2
|
||||
|
@ -997,4 +997,4 @@ def test_master_slave_requires_no_master():
|
|||
api.option('activate').value.set(False)
|
||||
raises(PropertiesOptionError, "api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()")
|
||||
raises(PropertiesOptionError, "api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get()")
|
||||
assert api.option.make_dict() == {'ip_admin_eth0.ip_admin_eth0': ['192.168.1.2', '192.168.1.1'], 'activate': False}
|
||||
assert api.config.dict() == {'ip_admin_eth0.ip_admin_eth0': ['192.168.1.2', '192.168.1.1'], 'activate': False}
|
||||
|
|
|
@ -207,9 +207,9 @@ def test_symlink_with_master():
|
|||
master = SymLinkOption('master', ip_admin_eth0)
|
||||
od = OptionDescription('root', '', [interface1, master])
|
||||
api = Config(od)
|
||||
assert api.option.make_dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': [], 'master': []}
|
||||
assert api.config.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': [], 'master': []}
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['val1', 'val2'])
|
||||
assert api.option.make_dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None], 'master': ['val1', 'val2']}
|
||||
assert api.config.dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None], 'master': ['val1', 'val2']}
|
||||
|
||||
|
||||
def test_symlink_with_slave():
|
||||
|
@ -219,9 +219,9 @@ def test_symlink_with_slave():
|
|||
slave = SymLinkOption('slave', netmask_admin_eth0)
|
||||
od = OptionDescription('root', '', [interface1, slave])
|
||||
api = Config(od)
|
||||
assert api.option.make_dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': [], 'slave': []}
|
||||
assert api.config.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': [], 'slave': []}
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['val1', 'val2'])
|
||||
assert api.option.make_dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None], 'slave': [None, None]}
|
||||
assert api.config.dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None], 'slave': [None, None]}
|
||||
#
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() == None
|
||||
|
@ -229,7 +229,7 @@ def test_symlink_with_slave():
|
|||
assert api.option('slave', 1).value.get() == None
|
||||
#
|
||||
api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.set('val3')
|
||||
assert api.option.make_dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, 'val3'], 'slave': [None, 'val3']}
|
||||
assert api.config.dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, 'val3'], 'slave': [None, 'val3']}
|
||||
#
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() == 'val3'
|
||||
|
@ -255,6 +255,6 @@ def test_symlink_makedict():
|
|||
descr = OptionDescription("opt", "",
|
||||
[linkopt, OptionDescription("s1", "", [boolopt])])
|
||||
api = Config(descr)
|
||||
assert api.option.make_dict() == {'c': False, 's1.b': False}
|
||||
assert api.config.dict() == {'c': False, 's1.b': False}
|
||||
api.option('s1.b').value.set(True)
|
||||
assert api.option.make_dict() == {'c': True, 's1.b': True}
|
||||
assert api.config.dict() == {'c': True, 's1.b': True}
|
||||
|
|
|
@ -517,15 +517,20 @@ class TiramisuOption(CommonTiramisu):
|
|||
return getattr(self, '_' + subfunc)
|
||||
raise APIError(_('please specify a valid sub function ({})').format(subfunc))
|
||||
|
||||
def _make_dict(self,
|
||||
def dict(self,
|
||||
flatten=False,
|
||||
withvalue=undefined,
|
||||
withoption=None,
|
||||
fullpath=False):
|
||||
"""return dict with path as key and value for an optiondescription (only for optiondescription)"""
|
||||
"""return dict with path as key and value (only for optiondescription)"""
|
||||
self._get_option()
|
||||
return self.config_bag.context.get_subconfig(self._path,
|
||||
self.option_bag).make_dict(config_bag=self.config_bag,
|
||||
if not self.config_bag.properties:
|
||||
config_bag = self.config_bag
|
||||
else:
|
||||
config_bag = self.config_bag.copy()
|
||||
config_bag.properties = self.config_bag.properties - {'warnings'}
|
||||
return config_bag.context.get_subconfig(self._path,
|
||||
self.option_bag).make_dict(config_bag=config_bag,
|
||||
flatten=flatten,
|
||||
fullpath=fullpath,
|
||||
withoption=withoption,
|
||||
|
@ -739,7 +744,8 @@ class TiramisuContextProperty(TiramisuContext):
|
|||
settings = self.config_bag.context.cfgimpl_get_settings()
|
||||
settings.read_write()
|
||||
# #FIXME ?
|
||||
settings.set_context_permissives(frozenset(['hidden']))
|
||||
permissives = frozenset(settings.get_context_permissives() | frozenset(['hidden']))
|
||||
settings.set_context_permissives(permissives)
|
||||
try:
|
||||
del self.config_bag.properties
|
||||
except AttributeError:
|
||||
|
@ -843,23 +849,6 @@ class TiramisuContextOption(TiramisuContext):
|
|||
self.config_bag.context,
|
||||
self.config_bag)
|
||||
|
||||
def make_dict(self,
|
||||
flatten=False,
|
||||
withvalue=undefined,
|
||||
withoption=None,
|
||||
fullpath=False):
|
||||
"""return dict with path as key and value"""
|
||||
if not self.config_bag.properties:
|
||||
config_bag = self.config_bag
|
||||
else:
|
||||
config_bag = self.config_bag.copy()
|
||||
config_bag.properties = self.config_bag.properties - {'warnings'}
|
||||
return config_bag.context.make_dict(config_bag,
|
||||
flatten=flatten,
|
||||
fullpath=fullpath,
|
||||
withoption=withoption,
|
||||
withvalue=withvalue)
|
||||
|
||||
def list(self,
|
||||
type='all',
|
||||
group_type=None,
|
||||
|
@ -956,6 +945,23 @@ class TiramisuContextConfig(TiramisuContext):
|
|||
raise APIError(_('{} is unknown').format(name))
|
||||
raise APIError(_('{} is unknown').format(name))
|
||||
|
||||
def dict(self,
|
||||
flatten=False,
|
||||
withvalue=undefined,
|
||||
withoption=None,
|
||||
fullpath=False):
|
||||
"""return dict with path as key and value"""
|
||||
if not self.config_bag.properties:
|
||||
config_bag = self.config_bag
|
||||
else:
|
||||
config_bag = self.config_bag.copy()
|
||||
config_bag.properties = self.config_bag.properties - {'warnings'}
|
||||
return config_bag.context.make_dict(config_bag,
|
||||
flatten=flatten,
|
||||
fullpath=fullpath,
|
||||
withoption=withoption,
|
||||
withvalue=withvalue)
|
||||
|
||||
|
||||
class TiramisuDispatcher:
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue