remove all getapi in tests
This commit is contained in:
parent
6b6fa5e499
commit
f6e963ae38
|
@ -9,7 +9,7 @@ from tiramisu.option import BoolOption, IPOption, IntOption, StrOption, OptionDe
|
||||||
from tiramisu import Config
|
from tiramisu import Config
|
||||||
from tiramisu.error import ConfigError, PropertiesOptionError
|
from tiramisu.error import ConfigError, PropertiesOptionError
|
||||||
from tiramisu.setting import groups
|
from tiramisu.setting import groups
|
||||||
from tiramisu import getapi, undefined, Params, ParamValue, ParamOption
|
from tiramisu import undefined, Params, ParamValue, ParamOption
|
||||||
from tiramisu.api import TIRAMISU_VERSION
|
from tiramisu.api import TIRAMISU_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,14 +46,13 @@ def test_cache_config():
|
||||||
|
|
||||||
def test_cache():
|
def test_cache():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
c = Config(od1)
|
cfg = Config(od1)
|
||||||
api = getapi(c)
|
values = cfg._config.cfgimpl_get_values()
|
||||||
values = c._config.cfgimpl_get_values()
|
settings = cfg._config.cfgimpl_get_settings()
|
||||||
settings = c._config.cfgimpl_get_settings()
|
cfg.option('u1').value.get()
|
||||||
api.option('u1').value.get()
|
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
api.option('u2').value.get()
|
cfg.option('u2').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u2' in values._p_.get_cached()
|
assert 'u2' in values._p_.get_cached()
|
||||||
|
@ -62,175 +61,146 @@ def test_cache():
|
||||||
|
|
||||||
def test_cache_importation():
|
def test_cache_importation():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
api = getapi(Config(od1))
|
cfg = Config(od1)
|
||||||
api.option('u2').value.set(1)
|
cfg.option('u2').value.set(1)
|
||||||
export = api.value.exportation()
|
export = cfg.value.exportation()
|
||||||
assert api.option.make_dict() == {'u1': [], 'u2': 1, 'u3': []}
|
assert cfg.option.make_dict() == {'u1': [], 'u2': 1, 'u3': []}
|
||||||
api.option('u2').value.set(2)
|
cfg.option('u2').value.set(2)
|
||||||
assert api.option.make_dict() == {'u1': [], 'u2': 2, 'u3': []}
|
assert cfg.option.make_dict() == {'u1': [], 'u2': 2, 'u3': []}
|
||||||
api.value.importation(export)
|
cfg.value.importation(export)
|
||||||
assert api.option.make_dict() == {'u1': [], 'u2': 1, 'u3': []}
|
assert cfg.option.make_dict() == {'u1': [], 'u2': 1, 'u3': []}
|
||||||
|
|
||||||
|
|
||||||
def test_cache_importation_property():
|
def test_cache_importation_property():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
api = getapi(Config(od1))
|
cfg = Config(od1)
|
||||||
api.option('u2').property.add('prop')
|
cfg.option('u2').property.add('prop')
|
||||||
export = api.property.exportation()
|
export = cfg.property.exportation()
|
||||||
assert api.option('u2').property.get() == {'prop'}
|
assert cfg.option('u2').property.get() == {'prop'}
|
||||||
api.option('u2').property.add('prop2')
|
cfg.option('u2').property.add('prop2')
|
||||||
assert api.option('u2').property.get() == {'prop', 'prop2'}
|
assert cfg.option('u2').property.get() == {'prop', 'prop2'}
|
||||||
api.property.importation(export)
|
cfg.property.importation(export)
|
||||||
assert api.option('u2').property.get() == {'prop'}
|
assert cfg.option('u2').property.get() == {'prop'}
|
||||||
|
|
||||||
|
|
||||||
def test_cache_importation_permissive():
|
def test_cache_importation_permissive():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
api = getapi(Config(od1))
|
cfg = Config(od1)
|
||||||
api.option('u2').permissive.set(frozenset(['prop']))
|
cfg.option('u2').permissive.set(frozenset(['prop']))
|
||||||
export = api.permissive.exportation()
|
export = cfg.permissive.exportation()
|
||||||
assert api.option('u2').permissive.get() == {'prop'}
|
assert cfg.option('u2').permissive.get() == {'prop'}
|
||||||
api.option('u2').permissive.set(frozenset(['prop', 'prop2']))
|
cfg.option('u2').permissive.set(frozenset(['prop', 'prop2']))
|
||||||
assert api.option('u2').permissive.get() == {'prop', 'prop2'}
|
assert cfg.option('u2').permissive.get() == {'prop', 'prop2'}
|
||||||
api.permissive.importation(export)
|
cfg.permissive.importation(export)
|
||||||
assert api.option('u2').permissive.get() == {'prop'}
|
assert cfg.option('u2').permissive.get() == {'prop'}
|
||||||
|
|
||||||
|
|
||||||
#def test_get_cache():
|
|
||||||
# # force a value in cache, try if reget corrupted value
|
|
||||||
# od1 = make_description()
|
|
||||||
# c = Config(od1)
|
|
||||||
# api = getapi(c)
|
|
||||||
# values = c._config.cfgimpl_get_values()
|
|
||||||
# settings = c._config.cfgimpl_get_settings()
|
|
||||||
# ntime = time() + 1
|
|
||||||
# settings._p_.setcache('u1', set(['inject']), ntime, None)
|
|
||||||
# assert 'inject' in settings[od1.u1]
|
|
||||||
# values._p_.setcache('u1', 100, ntime, None)
|
|
||||||
# assert api.option('u1').value.get() == [100]
|
|
||||||
|
|
||||||
|
|
||||||
#def test_get_cache_no_expire():
|
|
||||||
# # force a value in cache, try if reget corrupted value
|
|
||||||
# od1 = make_description()
|
|
||||||
# c = Config(od1)
|
|
||||||
# api = getapi(c)
|
|
||||||
# values = c._config.cfgimpl_get_values()
|
|
||||||
# settings = c._config.cfgimpl_get_settings()
|
|
||||||
# settings._p_.setcache('u1', set(['inject2']), None, None)
|
|
||||||
# assert 'inject2' in settings[od1.u1]
|
|
||||||
# values._p_.setcache('u1', 200, None, None)
|
|
||||||
# assert api.option('u1').value.get() == [200]
|
|
||||||
|
|
||||||
|
|
||||||
def test_cache_reset():
|
def test_cache_reset():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
c = Config(od1)
|
cfg = Config(od1)
|
||||||
api = getapi(c)
|
values = cfg._config.cfgimpl_get_values()
|
||||||
values = c._config.cfgimpl_get_values()
|
settings = cfg._config.cfgimpl_get_settings()
|
||||||
settings = c._config.cfgimpl_get_settings()
|
|
||||||
#when change a value
|
#when change a value
|
||||||
api.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
api.option('u2').value.get()
|
cfg.option('u2').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u2' in values._p_.get_cached()
|
assert 'u2' in values._p_.get_cached()
|
||||||
assert 'u2' in settings._p_.get_cached()
|
assert 'u2' in settings._p_.get_cached()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
api.option('u2').value.set(1)
|
cfg.option('u2').value.set(1)
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u2' not in values._p_.get_cached()
|
assert 'u2' not in values._p_.get_cached()
|
||||||
assert 'u2' not in settings._p_.get_cached()
|
assert 'u2' not in settings._p_.get_cached()
|
||||||
#when remove a value
|
#when remove a value
|
||||||
api.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
api.option('u2').value.reset()
|
cfg.option('u2').value.reset()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u2' not in values._p_.get_cached()
|
assert 'u2' not in values._p_.get_cached()
|
||||||
assert 'u2' not in settings._p_.get_cached()
|
assert 'u2' not in settings._p_.get_cached()
|
||||||
#when add/del property
|
#when add/del property
|
||||||
api.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
api.option('u2').property.add('test')
|
cfg.option('u2').property.add('test')
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u2' not in values._p_.get_cached()
|
assert 'u2' not in values._p_.get_cached()
|
||||||
assert 'u2' not in settings._p_.get_cached()
|
assert 'u2' not in settings._p_.get_cached()
|
||||||
api.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
api.option('u2').property.pop('test')
|
cfg.option('u2').property.pop('test')
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u2' not in values._p_.get_cached()
|
assert 'u2' not in values._p_.get_cached()
|
||||||
assert 'u2' not in settings._p_.get_cached()
|
assert 'u2' not in settings._p_.get_cached()
|
||||||
#when enable/disabled property
|
#when enable/disabled property
|
||||||
api.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
api.property.add('test')
|
cfg.property.add('test')
|
||||||
assert 'u1' not in values._p_.get_cached()
|
assert 'u1' not in values._p_.get_cached()
|
||||||
assert 'u1' not in settings._p_.get_cached()
|
assert 'u1' not in settings._p_.get_cached()
|
||||||
api.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
api.property.pop('test')
|
cfg.property.pop('test')
|
||||||
assert 'u1' not in values._p_.get_cached()
|
assert 'u1' not in values._p_.get_cached()
|
||||||
assert 'u1' not in settings._p_.get_cached()
|
assert 'u1' not in settings._p_.get_cached()
|
||||||
|
|
||||||
|
|
||||||
def test_cache_reset_multi():
|
def test_cache_reset_multi():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
c = Config(od1)
|
cfg = Config(od1)
|
||||||
api = getapi(c)
|
values = cfg._config.cfgimpl_get_values()
|
||||||
values = c._config.cfgimpl_get_values()
|
settings = cfg._config.cfgimpl_get_settings()
|
||||||
settings = c._config.cfgimpl_get_settings()
|
cfg.option('u1').value.get()
|
||||||
api.option('u1').value.get()
|
cfg.option('u3').value.get()
|
||||||
api.option('u3').value.get()
|
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u3' in values._p_.get_cached()
|
assert 'u3' in values._p_.get_cached()
|
||||||
assert 'u3' in settings._p_.get_cached()
|
assert 'u3' in settings._p_.get_cached()
|
||||||
#when change a value
|
#when change a value
|
||||||
api.option('u3').value.set([1])
|
cfg.option('u3').value.set([1])
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u3' not in values._p_.get_cached()
|
assert 'u3' not in values._p_.get_cached()
|
||||||
assert 'u3' not in settings._p_.get_cached()
|
assert 'u3' not in settings._p_.get_cached()
|
||||||
#when append value
|
#when append value
|
||||||
api.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
api.option('u3').value.get()
|
cfg.option('u3').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u3' in values._p_.get_cached()
|
assert 'u3' in values._p_.get_cached()
|
||||||
assert 'u3' in settings._p_.get_cached()
|
assert 'u3' in settings._p_.get_cached()
|
||||||
api.option('u3').value.set([1, 1])
|
cfg.option('u3').value.set([1, 1])
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u3' not in values._p_.get_cached()
|
assert 'u3' not in values._p_.get_cached()
|
||||||
assert 'u3' not in settings._p_.get_cached()
|
assert 'u3' not in settings._p_.get_cached()
|
||||||
#when pop value
|
#when pop value
|
||||||
api.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
api.option('u3').value.get()
|
cfg.option('u3').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u3' in values._p_.get_cached()
|
assert 'u3' in values._p_.get_cached()
|
||||||
assert 'u3' in settings._p_.get_cached()
|
assert 'u3' in settings._p_.get_cached()
|
||||||
api.option('u3').value.set([1])
|
cfg.option('u3').value.set([1])
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u3' not in values._p_.get_cached()
|
assert 'u3' not in values._p_.get_cached()
|
||||||
assert 'u3' not in settings._p_.get_cached()
|
assert 'u3' not in settings._p_.get_cached()
|
||||||
#when remove a value
|
#when remove a value
|
||||||
api.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
api.option('u3').value.reset()
|
cfg.option('u3').value.reset()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u3' not in values._p_.get_cached()
|
assert 'u3' not in values._p_.get_cached()
|
||||||
|
@ -239,168 +209,42 @@ def test_cache_reset_multi():
|
||||||
|
|
||||||
def test_reset_cache():
|
def test_reset_cache():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
c = Config(od1)
|
cfg = Config(od1)
|
||||||
api = getapi(c)
|
values = cfg._config.cfgimpl_get_values()
|
||||||
values = c._config.cfgimpl_get_values()
|
settings = cfg._config.cfgimpl_get_settings()
|
||||||
settings = c._config.cfgimpl_get_settings()
|
cfg.option('u1').value.get()
|
||||||
api.option('u1').value.get()
|
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
c._config.cfgimpl_reset_cache(None, None)
|
cfg._config.cfgimpl_reset_cache(None, None)
|
||||||
assert 'u1' not in values._p_.get_cached()
|
assert 'u1' not in values._p_.get_cached()
|
||||||
assert 'u1' not in settings._p_.get_cached()
|
assert 'u1' not in settings._p_.get_cached()
|
||||||
api.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
sleep(1)
|
sleep(1)
|
||||||
api.option('u1').value.get()
|
cfg.option('u1').value.get()
|
||||||
sleep(1)
|
sleep(1)
|
||||||
api.option('u2').value.get()
|
cfg.option('u2').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
assert 'u1' in settings._p_.get_cached()
|
assert 'u1' in settings._p_.get_cached()
|
||||||
assert 'u2' in values._p_.get_cached()
|
assert 'u2' in values._p_.get_cached()
|
||||||
assert 'u2' in settings._p_.get_cached()
|
assert 'u2' in settings._p_.get_cached()
|
||||||
c._config.cfgimpl_reset_cache(None, None)
|
cfg._config.cfgimpl_reset_cache(None, None)
|
||||||
assert 'u1' not in values._p_.get_cached()
|
assert 'u1' not in values._p_.get_cached()
|
||||||
assert 'u1' not in settings._p_.get_cached()
|
assert 'u1' not in settings._p_.get_cached()
|
||||||
assert 'u2' not in values._p_.get_cached()
|
assert 'u2' not in values._p_.get_cached()
|
||||||
assert 'u2' not in settings._p_.get_cached()
|
assert 'u2' not in settings._p_.get_cached()
|
||||||
|
|
||||||
|
|
||||||
#def test_reset_cache_subconfig():
|
|
||||||
# od1 = make_description()
|
|
||||||
# od2 = OptionDescription('od2', '', [od1])
|
|
||||||
# c = Config(od2)
|
|
||||||
# api = getapi(c)
|
|
||||||
# values = c._config.cfgimpl_get_values()
|
|
||||||
# api.option('od1.u1').value.get()
|
|
||||||
# assert 'od1.u1' in values._p_.get_cached()
|
|
||||||
# c.od1.cfgimpl_reset_cache(None, None)
|
|
||||||
# assert 'od1.u1' not in values._p_.get_cached()
|
|
||||||
|
|
||||||
|
|
||||||
#def test_reset_cache_only_expired():
|
|
||||||
# od1 = make_description()
|
|
||||||
# c = Config(od1)
|
|
||||||
# api = getapi(c)
|
|
||||||
# api.property.add('expire')
|
|
||||||
# values = c._config.cfgimpl_get_values()
|
|
||||||
# settings = c._config.cfgimpl_get_settings()
|
|
||||||
# api.option('u1').value.get()
|
|
||||||
# assert 'u1' in values._p_.get_cached()
|
|
||||||
# assert 'u1' in settings._p_.get_cached()
|
|
||||||
# c._config.cfgimpl_reset_cache(True)
|
|
||||||
# assert 'u1' in values._p_.get_cached()
|
|
||||||
# assert 'u1' in settings._p_.get_cached()
|
|
||||||
# sleep(1)
|
|
||||||
# api.option('u1').value.get()
|
|
||||||
# sleep(1)
|
|
||||||
# api.option('u2').value.get()
|
|
||||||
# assert 'u1' in values._p_.get_cached()
|
|
||||||
# assert 'u1' in settings._p_.get_cached()
|
|
||||||
# assert 'u2' in values._p_.get_cached()
|
|
||||||
# assert 'u2' in settings._p_.get_cached()
|
|
||||||
# c._config.cfgimpl_reset_cache(True)
|
|
||||||
# assert 'u1' not in values._p_.get_cached()
|
|
||||||
# assert 'u1' not in settings._p_.get_cached()
|
|
||||||
# assert 'u2' in values._p_.get_cached()
|
|
||||||
# assert 'u2' in settings._p_.get_cached()
|
|
||||||
|
|
||||||
|
|
||||||
#def test_cache_not_expire():
|
|
||||||
# od1 = make_description()
|
|
||||||
# c = Config(od1)
|
|
||||||
# api = getapi(c)
|
|
||||||
# values = c._config.cfgimpl_get_values()
|
|
||||||
# settings = c._config.cfgimpl_get_settings()
|
|
||||||
# #api.property.pop('expire')
|
|
||||||
# api.option('u1').value.get()
|
|
||||||
# assert 'u1' in values._p_.get_cached()
|
|
||||||
# assert 'u1' in settings._p_.get_cached()
|
|
||||||
# c._config.cfgimpl_reset_cache(True)
|
|
||||||
# assert 'u1' in values._p_.get_cached()
|
|
||||||
# assert 'u1' in settings._p_.get_cached()
|
|
||||||
# sleep(1)
|
|
||||||
# api.option('u2').value.get()
|
|
||||||
# assert 'u1' in values._p_.get_cached()
|
|
||||||
# assert 'u1' in settings._p_.get_cached()
|
|
||||||
# assert 'u2' in values._p_.get_cached()
|
|
||||||
# assert 'u2' in settings._p_.get_cached()
|
|
||||||
# c._config.cfgimpl_reset_cache(True)
|
|
||||||
# assert 'u1' in values._p_.get_cached()
|
|
||||||
# assert 'u1' in settings._p_.get_cached()
|
|
||||||
# assert 'u2' in values._p_.get_cached()
|
|
||||||
# assert 'u2' in settings._p_.get_cached()
|
|
||||||
|
|
||||||
|
|
||||||
def test_cache_not_cache():
|
def test_cache_not_cache():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
c = Config(od1)
|
cfg = Config(od1)
|
||||||
api = getapi(c)
|
values = cfg._config.cfgimpl_get_values()
|
||||||
values = c._config.cfgimpl_get_values()
|
settings = cfg._config.cfgimpl_get_settings()
|
||||||
settings = c._config.cfgimpl_get_settings()
|
cfg.property.pop('cache')
|
||||||
api.property.pop('cache')
|
cfg.option('u1').value.get()
|
||||||
api.option('u1').value.get()
|
|
||||||
assert 'u1' not in values._p_.get_cached()
|
assert 'u1' not in values._p_.get_cached()
|
||||||
assert 'u1' not in settings._p_.get_cached()
|
assert 'u1' not in settings._p_.get_cached()
|
||||||
|
|
||||||
|
|
||||||
#def test_reset_cache_only():
|
|
||||||
# od1 = make_description()
|
|
||||||
# c = Config(od1)
|
|
||||||
# api = getapi(c)
|
|
||||||
# values = c._config.cfgimpl_get_values()
|
|
||||||
# settings = c._config.cfgimpl_get_settings()
|
|
||||||
# api.option('u1').value.get()
|
|
||||||
# assert 'u1' in values._p_.get_cached()
|
|
||||||
# assert 'u1' in settings._p_.get_cached()
|
|
||||||
# c._config.cfgimpl_reset_cache(only=('values',))
|
|
||||||
# assert 'u1' not in values._p_.get_cached()
|
|
||||||
# assert 'u1' in settings._p_.get_cached()
|
|
||||||
# api.option('u1').value.get()
|
|
||||||
# assert 'u1' in values._p_.get_cached()
|
|
||||||
# assert 'u1' in settings._p_.get_cached()
|
|
||||||
# c._config.cfgimpl_reset_cache(only=('settings',))
|
|
||||||
# assert 'u1' in values._p_.get_cached()
|
|
||||||
# assert 'u1' not in settings._p_.get_cached()
|
|
||||||
|
|
||||||
|
|
||||||
#def test_force_cache():
|
|
||||||
# u1 = IntOption('u1', '', multi=True)
|
|
||||||
# u2 = IntOption('u2', '')
|
|
||||||
# u3 = IntOption('u3', '', multi=True)
|
|
||||||
# u4 = IntOption('u4', '', properties=('disabled',))
|
|
||||||
# od = OptionDescription('od1', '', [u1, u2, u3, u4])
|
|
||||||
# c = Config(od)
|
|
||||||
# api = getapi(c)
|
|
||||||
# api.property.read_write()
|
|
||||||
# api.property.pop('expire')
|
|
||||||
# api.property.pop('disabled')
|
|
||||||
#
|
|
||||||
# c._config.cfgimpl_get_values().force_cache()
|
|
||||||
# compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'u1': {None: ([], None)},
|
|
||||||
# 'u2': {None: (None, None)},
|
|
||||||
# 'u3': {None: ([], None)},
|
|
||||||
# 'u4': {None: (None, None)}})
|
|
||||||
# compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
|
||||||
# 'u1': {None: (set(['empty']), None)},
|
|
||||||
# 'u2': {None: (set([]), None)},
|
|
||||||
# 'u3': {None: (set(['empty']), None)},
|
|
||||||
# 'u4': {None: (set(['disabled']), None)}})
|
|
||||||
# api.property.read_only()
|
|
||||||
#
|
|
||||||
# c._config.cfgimpl_get_values().force_cache()
|
|
||||||
# compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'u1': {None: ([], None)},
|
|
||||||
# 'u2': {None: (None, None)},
|
|
||||||
# 'u3': {None: ([], None)}})
|
|
||||||
# compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'empty', 'everything_frozen', 'frozen', 'mandatory', 'validator', 'warnings']), None)},
|
|
||||||
# 'u1': {None: (set(['empty']), None)},
|
|
||||||
# 'u2': {None: (set([]), None)},
|
|
||||||
# 'u3': {None: (set(['empty']), None)},
|
|
||||||
# 'u4': {None: (set(['disabled']), None)}})
|
|
||||||
#
|
|
||||||
# c._config.cfgimpl_get_settings().remove('cache')
|
|
||||||
# raises(ConfigError, "c._config.cfgimpl_get_values().force_cache()")
|
|
||||||
|
|
||||||
|
|
||||||
def test_cache_master_slave():
|
def test_cache_master_slave():
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||||
|
@ -408,14 +252,13 @@ def test_cache_master_slave():
|
||||||
#interface1.impl_set_group_type(groups.master)
|
#interface1.impl_set_group_type(groups.master)
|
||||||
maconfig = OptionDescription('toto', '', [interface1])
|
maconfig = OptionDescription('toto', '', [interface1])
|
||||||
cfg = Config(maconfig)
|
cfg = Config(maconfig)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {}
|
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {}
|
||||||
#
|
#
|
||||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
||||||
api.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
cfg.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
||||||
cache = cfg._config.cfgimpl_get_values()._p_.get_cached()
|
cache = cfg._config.cfgimpl_get_values()._p_.get_cached()
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0'])
|
assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0'])
|
||||||
|
@ -435,10 +278,10 @@ def test_cache_master_slave():
|
||||||
else:
|
else:
|
||||||
assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([0])
|
assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([0])
|
||||||
#
|
#
|
||||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2', '192.168.1.1'])
|
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2', '192.168.1.1'])
|
||||||
api.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
cfg.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get()
|
cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get()
|
||||||
cache = cfg._config.cfgimpl_get_values()._p_.get_cached()
|
cache = cfg._config.cfgimpl_get_values()._p_.get_cached()
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0'])
|
assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0'])
|
||||||
|
@ -482,11 +325,10 @@ def test_cache_callback():
|
||||||
val5 = StrOption('val5', "", callback=return_value, callback_params=Params(kwargs={'value': ParamValue('yes')}), multi=True)
|
val5 = StrOption('val5', "", callback=return_value, callback_params=Params(kwargs={'value': ParamValue('yes')}), multi=True)
|
||||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
||||||
cfg = Config(maconfig)
|
cfg = Config(maconfig)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
api.property.pop('expire')
|
cfg.property.pop('expire')
|
||||||
api.option.make_dict()
|
cfg.option.make_dict()
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)}}
|
# 'val1': {None: (set([]), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('val', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('val', None)},
|
||||||
|
@ -494,12 +336,12 @@ def test_cache_callback():
|
||||||
'val3': {None: ('yes', None)},
|
'val3': {None: ('yes', None)},
|
||||||
'val4': {None: ('val', None)},
|
'val4': {None: ('val', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
api.option('val1').value.set('new')
|
cfg.option('val1').value.set('new')
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)}}
|
# 'val1': {None: (set([]), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val3': {None: ('yes', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val3': {None: ('yes', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
api.option.make_dict()
|
cfg.option.make_dict()
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)}}
|
# 'val1': {None: (set([]), None)}}
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
|
@ -507,7 +349,7 @@ def test_cache_callback():
|
||||||
'val3': {None: ('yes', None)},
|
'val3': {None: ('yes', None)},
|
||||||
'val4': {None: ('new', None)},
|
'val4': {None: ('new', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
api.option('val3').value.set('new2')
|
cfg.option('val3').value.set('new2')
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)}}
|
# 'val3': {None: (set([]), None)}}
|
||||||
|
@ -515,7 +357,7 @@ def test_cache_callback():
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'val4': {None: ('new', None)},
|
'val4': {None: ('new', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
api.option.make_dict()
|
cfg.option.make_dict()
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)}}
|
# 'val3': {None: (set([]), None)}}
|
||||||
|
@ -524,7 +366,7 @@ def test_cache_callback():
|
||||||
'val3': {None: ('new2', None)},
|
'val3': {None: ('new2', None)},
|
||||||
'val4': {None: ('new', None)},
|
'val4': {None: ('new', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
api.option('val4').value.set('new3')
|
cfg.option('val4').value.set('new3')
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)},
|
# 'val3': {None: (set([]), None)},
|
||||||
|
@ -533,7 +375,7 @@ def test_cache_callback():
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'val3': {None: ('new2', None)},
|
'val3': {None: ('new2', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
api.option.make_dict()
|
cfg.option.make_dict()
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)},
|
# 'val3': {None: (set([]), None)},
|
||||||
|
@ -543,7 +385,7 @@ def test_cache_callback():
|
||||||
'val3': {None: ('new2', None)},
|
'val3': {None: ('new2', None)},
|
||||||
'val4': {None: ('new3', None)},
|
'val4': {None: ('new3', None)},
|
||||||
'val5': {None: (['yes'], None)}})
|
'val5': {None: (['yes'], None)}})
|
||||||
api.option('val5').value.set([undefined, 'new4'])
|
cfg.option('val5').value.set([undefined, 'new4'])
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)},
|
# 'val3': {None: (set([]), None)},
|
||||||
|
@ -553,7 +395,7 @@ def test_cache_callback():
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'val3': {None: ('new2', None)},
|
'val3': {None: ('new2', None)},
|
||||||
'val4': {None: ('new3', None)}})
|
'val4': {None: ('new3', None)}})
|
||||||
api.option.make_dict()
|
cfg.option.make_dict()
|
||||||
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)},
|
# 'val1': {None: (set([]), None)},
|
||||||
# 'val3': {None: (set([]), None)},
|
# 'val3': {None: (set([]), None)},
|
||||||
|
@ -573,15 +415,14 @@ def test_cache_master_and_slaves_master():
|
||||||
#interface1.impl_set_group_type(groups.master)
|
#interface1.impl_set_group_type(groups.master)
|
||||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||||
cfg = Config(maconfig)
|
cfg = Config(maconfig)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
cfg.option.make_dict()
|
||||||
api.option.make_dict()
|
|
||||||
global_props = ['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']
|
global_props = ['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']
|
||||||
val1_props = []
|
val1_props = []
|
||||||
val1_val1_props = ['empty']
|
val1_val1_props = ['empty']
|
||||||
val1_val2_props = []
|
val1_val2_props = []
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
api.property.pop('expire')
|
cfg.property.pop('expire')
|
||||||
global_props = set(global_props)
|
global_props = set(global_props)
|
||||||
val1_props = set(val1_props)
|
val1_props = set(val1_props)
|
||||||
val1_val1_props = set(val1_val1_props)
|
val1_val1_props = set(val1_val1_props)
|
||||||
|
@ -604,11 +445,11 @@ def test_cache_master_and_slaves_master():
|
||||||
# len is 0 so don't get any value
|
# len is 0 so don't get any value
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([], None)}})
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([], None)}})
|
||||||
#
|
#
|
||||||
api.option('val1.val1').value.set([undefined])
|
cfg.option('val1.val1').value.set([undefined])
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'val1': {None: (set([]), None)}})
|
'val1': {None: (set([]), None)}})
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
api.option.make_dict()
|
cfg.option.make_dict()
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
val_val2 = [None]
|
val_val2 = [None]
|
||||||
val_val2_props = {None: (set(), None), 0: (set(), None)}
|
val_val2_props = {None: (set(), None), 0: (set(), None)}
|
||||||
|
@ -623,9 +464,9 @@ def test_cache_master_and_slaves_master():
|
||||||
'val1.val2': val_val2_props})
|
'val1.val2': val_val2_props})
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([None], None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([None], None)},
|
||||||
'val1.val2': {idx_val2: (val_val2, None)}})
|
'val1.val2': {idx_val2: (val_val2, None)}})
|
||||||
api.option('val1.val1').value.set([undefined, undefined])
|
cfg.option('val1.val1').value.set([undefined, undefined])
|
||||||
api.option.make_dict()
|
cfg.option.make_dict()
|
||||||
api.option('val1.val2', 1).value.set('oui')
|
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)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'val1': {None: (set([]), None)}})
|
'val1': {None: (set([]), None)}})
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
|
@ -652,15 +493,14 @@ def test_cache_master_callback():
|
||||||
#interface1.impl_set_group_type(groups.master)
|
#interface1.impl_set_group_type(groups.master)
|
||||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||||
cfg = Config(maconfig)
|
cfg = Config(maconfig)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
cfg.option.make_dict()
|
||||||
api.option.make_dict()
|
|
||||||
global_props = ['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']
|
global_props = ['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']
|
||||||
val1_props = []
|
val1_props = []
|
||||||
val1_val1_props = ['empty']
|
val1_val1_props = ['empty']
|
||||||
val1_val2_props = []
|
val1_val2_props = []
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
api.property.pop('expire')
|
cfg.property.pop('expire')
|
||||||
global_props = set(global_props)
|
global_props = set(global_props)
|
||||||
val1_props = set(val1_props)
|
val1_props = set(val1_props)
|
||||||
val1_val1_props = set(val1_val1_props)
|
val1_val1_props = set(val1_val1_props)
|
||||||
|
@ -679,12 +519,12 @@ def test_cache_master_callback():
|
||||||
'val1.val1': {None: (val1_val1_props, None)},
|
'val1.val1': {None: (val1_val1_props, None)},
|
||||||
'val1.val2': {None: (val1_val2_props, None)}})
|
'val1.val2': {None: (val1_val2_props, None)}})
|
||||||
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([], None)}})
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1.val1': {None: ([], None)}})
|
||||||
api.option('val1.val1').value.set([undefined])
|
cfg.option('val1.val1').value.set([undefined])
|
||||||
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'val1': {None: (set([]), None)}})
|
'val1': {None: (set([]), None)}})
|
||||||
|
|
||||||
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
api.option.make_dict()
|
cfg.option.make_dict()
|
||||||
#FIXMEassert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
#FIXMEassert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'val1': {None: (set([]), None)}}
|
# 'val1': {None: (set([]), None)}}
|
||||||
#FIXMEassert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None], None)},
|
#FIXMEassert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None], None)},
|
||||||
|
@ -692,109 +532,55 @@ def test_cache_master_callback():
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
|
||||||
#def test_cache_master_slave_different():
|
|
||||||
# b = IntOption('int', 'Test int option', default=[0], multi=True)
|
|
||||||
# c = StrOption('str', 'Test string option', multi=True)
|
|
||||||
# d = StrOption('str1', 'Test string option', requires=[{'option': c, 'expected': None, 'action': 'hidden', 'inverse': True}], multi=True)
|
|
||||||
# descr = MasterSlaves("int", "", [b, c, d])
|
|
||||||
# #descr.impl_set_group_type(groups.master)
|
|
||||||
# cfg = Config(descr)
|
|
||||||
# api = getapi(cfg)
|
|
||||||
# api.property.read_write()
|
|
||||||
# api.property.pop('expire')
|
|
||||||
# api.option.make_dict()
|
|
||||||
# compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'int': {None: ([0], None)},
|
|
||||||
# 'str': {None: ([None], None)},
|
|
||||||
# 'str1': {None: ([None], None)}})
|
|
||||||
# conver(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
|
||||||
# 'int': {None: (set(['empty']), None)},
|
|
||||||
# 'str': {None: (set([]), None), 0: (set([]), None)},
|
|
||||||
# 'str1': {None: (set([]), None), 0: (set([]), None)}})
|
|
||||||
# api.option('int').value.set([0, 1])
|
|
||||||
# api.option.make_dict()
|
|
||||||
# compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'int': {None: ([0, 1], None)},
|
|
||||||
# 'str': {None: ([None, None], None)},
|
|
||||||
# 'str1': {None: ([None, None], None)}})
|
|
||||||
# compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
|
||||||
# 'int': {None: (set(['empty']), None)},
|
|
||||||
# 'str': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)},
|
|
||||||
# 'str1': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)}})
|
|
||||||
#
|
|
||||||
# api.option('str', 1).value.set('1')
|
|
||||||
# api.option.make_dict()
|
|
||||||
# assert set(cfg._config.cfgimpl_get_values()._p_.get_cached().keys()) == set(['int', 'str', 'str1'])
|
|
||||||
# compare(cfg._config.cfgimpl_get_values()._p_.get_cached()['int'], {None: ([0, 1], None)})
|
|
||||||
# compare(cfg._config.cfgimpl_get_values()._p_.get_cached()['str'], {None: ([None, '1'], None)})
|
|
||||||
# assert cfg._config.cfgimpl_get_values()._p_.get_cached()['str1'][None][0][0] == None
|
|
||||||
# raises(PropertiesOptionError, "cfg._config.cfgimpl_get_values()._p_.get_cached()['str1'][None][0][1]")
|
|
||||||
# assert cfg._config.cfgimpl_get_values()._p_.get_cached()['str1'][None][1] == None
|
|
||||||
# compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
|
||||||
# 'int': {None: (set(['empty']), None)},
|
|
||||||
# 'str': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)},
|
|
||||||
# 'str1': {None: (set([]), None), 0: (set([]), None), 1: (set(['hidden']), None)}})
|
|
||||||
# api.property.read_only()
|
|
||||||
# assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
|
||||||
# assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {}
|
|
||||||
# api.option.make_dict()
|
|
||||||
# assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'int': {None: ([0, 1], None)},
|
|
||||||
# 'str': {None: ([None, '1'], None)},
|
|
||||||
# 'str1': {None: ([None, None], None)}}
|
|
||||||
# assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'everything_frozen', 'validator', 'warnings', 'empty', 'mandatory', ]), None)},
|
|
||||||
# 'int': {None: (set(['empty']), None)},
|
|
||||||
# 'str': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)},
|
|
||||||
# 'str1': {None: (set([]), None), 0: (set([]), None), 1: (set(['hidden']), None)}}
|
|
||||||
|
|
||||||
|
|
||||||
def test_cache_requires():
|
def test_cache_requires():
|
||||||
a = BoolOption('activate_service', '', True)
|
a = BoolOption('activate_service', '', True)
|
||||||
b = IPOption('ip_address_service', '',
|
b = IPOption('ip_address_service', '',
|
||||||
requires=[{'option': a, 'expected': False, 'action': 'disabled'}])
|
requires=[{'option': a, 'expected': False, 'action': 'disabled'}])
|
||||||
od = OptionDescription('service', '', [a, b])
|
od = OptionDescription('service', '', [a, b])
|
||||||
c = Config(od)
|
cfg = Config(od)
|
||||||
api = getapi(c)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
api.property.pop('expire')
|
cfg.property.pop('expire')
|
||||||
assert c._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
assert api.option('ip_address_service').value.get() == None
|
assert cfg.option('ip_address_service').value.get() == None
|
||||||
compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert c._config.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
||||||
else:
|
else:
|
||||||
compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
||||||
'activate_service': {None: (True, None)}})
|
'activate_service': {None: (True, None)}})
|
||||||
api.option.make_dict()
|
cfg.option.make_dict()
|
||||||
compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
||||||
'activate_service': {None: (True, None)}})
|
'activate_service': {None: (True, None)}})
|
||||||
api.option('ip_address_service').value.set('1.1.1.1')
|
cfg.option('ip_address_service').value.set('1.1.1.1')
|
||||||
compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)}})
|
'activate_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (True, None)}})
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (True, None)}})
|
||||||
api.option.make_dict()
|
cfg.option.make_dict()
|
||||||
compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: ('1.1.1.1', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: ('1.1.1.1', None)},
|
||||||
'activate_service': {None: (True, None)}})
|
'activate_service': {None: (True, None)}})
|
||||||
api.option('activate_service').value.set(False)
|
cfg.option('activate_service').value.set(False)
|
||||||
compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}})
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}})
|
||||||
|
|
||||||
assert c._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
api.option.make_dict()
|
cfg.option.make_dict()
|
||||||
compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set(['disabled']), None)}})
|
'ip_address_service': {None: (set(['disabled']), None)}})
|
||||||
|
|
||||||
compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (False, None)}})
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (False, None)}})
|
||||||
|
|
||||||
|
|
||||||
def test_cache_global_properties():
|
def test_cache_global_properties():
|
||||||
|
@ -802,28 +588,27 @@ def test_cache_global_properties():
|
||||||
b = IPOption('ip_address_service', '',
|
b = IPOption('ip_address_service', '',
|
||||||
requires=[{'option': a, 'expected': False, 'action': 'disabled'}])
|
requires=[{'option': a, 'expected': False, 'action': 'disabled'}])
|
||||||
od = OptionDescription('service', '', [a, b])
|
od = OptionDescription('service', '', [a, b])
|
||||||
c = Config(od)
|
cfg = Config(od)
|
||||||
api = getapi(c)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
assert c._config.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg.option('ip_address_service').value.get() == None
|
||||||
assert api.option('ip_address_service').value.get() == None
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert c._config.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
||||||
else:
|
else:
|
||||||
compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
||||||
'activate_service': {None: (True, None)}})
|
'activate_service': {None: (True, None)}})
|
||||||
api.property.pop('disabled')
|
cfg.property.pop('disabled')
|
||||||
assert api.option('ip_address_service').value.get() == None
|
assert cfg.option('ip_address_service').value.get() == None
|
||||||
compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
api.property.add('test')
|
cfg.property.add('test')
|
||||||
assert api.option('ip_address_service').value.get() == None
|
assert cfg.option('ip_address_service').value.get() == None
|
||||||
compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings', 'test']), None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings', 'test']), None)},
|
||||||
'activate_service': {None: (set([]), None)},
|
'activate_service': {None: (set([]), None)},
|
||||||
'ip_address_service': {None: (set([]), None)}})
|
'ip_address_service': {None: (set([]), None)}})
|
||||||
|
|
||||||
|
@ -833,16 +618,15 @@ def test_callback_value_incr():
|
||||||
val2 = IntOption('val2', "", callback=return_value, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
val2 = IntOption('val2', "", callback=return_value, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
||||||
maconfig = OptionDescription('rootconfig', '', [val1, val2])
|
maconfig = OptionDescription('rootconfig', '', [val1, val2])
|
||||||
cfg = Config(maconfig)
|
cfg = Config(maconfig)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
assert cfg.option('val1').value.get() == 1
|
||||||
assert api.option('val1').value.get() == 1
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
assert api.option('val2').value.get() == 1
|
assert cfg.option('val2').value.get() == 1
|
||||||
sleep(1)
|
sleep(1)
|
||||||
assert api.option('val1').value.get() == 1
|
assert cfg.option('val1').value.get() == 1
|
||||||
assert api.option('val2').value.get() == 1
|
assert cfg.option('val2').value.get() == 1
|
||||||
sleep(2)
|
sleep(2)
|
||||||
assert api.option('val1').value.get() == 2
|
assert cfg.option('val1').value.get() == 2
|
||||||
assert api.option('val2').value.get() == 2
|
assert cfg.option('val2').value.get() == 2
|
||||||
assert api.option('val1').value.get() == 2
|
assert cfg.option('val1').value.get() == 2
|
||||||
assert api.option('val2').value.get() == 2
|
assert cfg.option('val2').value.get() == 2
|
||||||
|
|
|
@ -8,7 +8,7 @@ from tiramisu.setting import owners
|
||||||
from tiramisu.option import ChoiceOption, StrOption, OptionDescription
|
from tiramisu.option import ChoiceOption, StrOption, OptionDescription
|
||||||
from tiramisu import Config
|
from tiramisu import Config
|
||||||
from tiramisu.error import ConfigError
|
from tiramisu.error import ConfigError
|
||||||
from tiramisu import getapi, undefined, Params, ParamValue, ParamOption
|
from tiramisu import undefined, Params, ParamValue, ParamOption
|
||||||
from tiramisu.api import TIRAMISU_VERSION
|
from tiramisu.api import TIRAMISU_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,92 +32,86 @@ def test_choiceoption():
|
||||||
choice = ChoiceOption('choice', '', values=('val1', 'val2'))
|
choice = ChoiceOption('choice', '', values=('val1', 'val2'))
|
||||||
odesc = OptionDescription('od', '', [choice])
|
odesc = OptionDescription('od', '', [choice])
|
||||||
cfg = Config(odesc)
|
cfg = Config(odesc)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
owner = cfg.owner.get()
|
||||||
owner = api.owner.get()
|
assert cfg.option('choice').owner.get() == owners.default
|
||||||
assert api.option('choice').owner.get() == owners.default
|
assert cfg.option('choice').owner.isdefault()
|
||||||
assert api.option('choice').owner.isdefault()
|
|
||||||
#
|
#
|
||||||
api.option('choice').value.set('val1')
|
cfg.option('choice').value.set('val1')
|
||||||
assert api.option('choice').owner.get() == owner
|
assert cfg.option('choice').owner.get() == owner
|
||||||
assert not api.option('choice').owner.isdefault()
|
assert not cfg.option('choice').owner.isdefault()
|
||||||
#
|
#
|
||||||
api.option('choice').value.reset()
|
cfg.option('choice').value.reset()
|
||||||
assert api.option('choice').owner.get() == owners.default
|
assert cfg.option('choice').owner.get() == owners.default
|
||||||
assert api.option('choice').owner.isdefault()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
#
|
#
|
||||||
raises(ValueError, "api.option('choice').value.set('no')")
|
raises(ValueError, "cfg.option('choice').value.set('no')")
|
||||||
assert api.option('choice').owner.get() == owners.default
|
assert cfg.option('choice').owner.get() == owners.default
|
||||||
assert api.option('choice').owner.isdefault()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
#
|
#
|
||||||
assert api.option('choice').value.list() == ('val1', 'val2')
|
assert cfg.option('choice').value.list() == ('val1', 'val2')
|
||||||
|
|
||||||
|
|
||||||
def test_choiceoption_function():
|
def test_choiceoption_function():
|
||||||
choice = ChoiceOption('choice', '', values=return_list)
|
choice = ChoiceOption('choice', '', values=return_list)
|
||||||
odesc = OptionDescription('od', '', [choice])
|
odesc = OptionDescription('od', '', [choice])
|
||||||
cfg = Config(odesc)
|
cfg = Config(odesc)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
owner = cfg.owner.get()
|
||||||
owner = api.owner.get()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
assert api.option('choice').owner.isdefault()
|
|
||||||
#
|
#
|
||||||
api.option('choice').value.set('val1')
|
cfg.option('choice').value.set('val1')
|
||||||
assert api.option('choice').owner.get() == owner
|
assert cfg.option('choice').owner.get() == owner
|
||||||
#
|
#
|
||||||
api.option('choice').value.reset()
|
cfg.option('choice').value.reset()
|
||||||
assert api.option('choice').owner.isdefault()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
#
|
#
|
||||||
raises(ValueError, "api.option('choice').value.set('no')")
|
raises(ValueError, "cfg.option('choice').value.set('no')")
|
||||||
assert api.option('choice').owner.isdefault()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
#
|
#
|
||||||
assert api.option('choice').value.list() == ['val1', 'val2']
|
assert cfg.option('choice').value.list() == ['val1', 'val2']
|
||||||
|
|
||||||
|
|
||||||
def test_choiceoption_function_error():
|
def test_choiceoption_function_error():
|
||||||
choice = ChoiceOption('choice', '', values=return_error)
|
choice = ChoiceOption('choice', '', values=return_error)
|
||||||
odesc = OptionDescription('od', '', [choice])
|
odesc = OptionDescription('od', '', [choice])
|
||||||
cfg = Config(odesc)
|
cfg = Config(odesc)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
raises(ConfigError, "cfg.option('choice').value.set('val1')")
|
||||||
raises(ConfigError, "api.option('choice').value.set('val1')")
|
|
||||||
|
|
||||||
|
|
||||||
def test_choiceoption_function_error_args():
|
def test_choiceoption_function_error_args():
|
||||||
choice = ChoiceOption('choice', '', values=return_error, values_params=Params((ParamValue('val1'),)))
|
choice = ChoiceOption('choice', '', values=return_error, values_params=Params((ParamValue('val1'),)))
|
||||||
odesc = OptionDescription('od', '', [choice])
|
odesc = OptionDescription('od', '', [choice])
|
||||||
cfg = Config(odesc)
|
cfg = Config(odesc)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
raises(ConfigError, "cfg.option('choice').value.set('val1')")
|
||||||
raises(ConfigError, "api.option('choice').value.set('val1')")
|
|
||||||
|
|
||||||
|
|
||||||
def test_choiceoption_function_error_kwargs():
|
def test_choiceoption_function_error_kwargs():
|
||||||
choice = ChoiceOption('choice', '', values=return_error, values_params=Params(kwargs={'kwargs': ParamValue('val1')}))
|
choice = ChoiceOption('choice', '', values=return_error, values_params=Params(kwargs={'kwargs': ParamValue('val1')}))
|
||||||
odesc = OptionDescription('od', '', [choice])
|
odesc = OptionDescription('od', '', [choice])
|
||||||
cfg = Config(odesc)
|
cfg = Config(odesc)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
raises(ConfigError, "cfg.option('choice').value.set('val1')")
|
||||||
raises(ConfigError, "api.option('choice').value.set('val1')")
|
|
||||||
|
|
||||||
|
|
||||||
def test_choiceoption_calc_function():
|
def test_choiceoption_calc_function():
|
||||||
choice = ChoiceOption('choice', "", values=return_calc_list, values_params=Params((ParamValue('val1'),)))
|
choice = ChoiceOption('choice', "", values=return_calc_list, values_params=Params((ParamValue('val1'),)))
|
||||||
odesc = OptionDescription('od', '', [choice])
|
odesc = OptionDescription('od', '', [choice])
|
||||||
cfg = Config(odesc)
|
cfg = Config(odesc)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
owner = cfg.owner.get()
|
||||||
owner = api.owner.get()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
assert api.option('choice').owner.isdefault()
|
|
||||||
#
|
#
|
||||||
api.option('choice').value.set('val1')
|
cfg.option('choice').value.set('val1')
|
||||||
assert api.option('choice').owner.get() == owner
|
assert cfg.option('choice').owner.get() == owner
|
||||||
#
|
#
|
||||||
api.option('choice').value.reset()
|
cfg.option('choice').value.reset()
|
||||||
assert api.option('choice').owner.isdefault()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
#
|
#
|
||||||
raises(ValueError, "api.option('choice').value.set('no')")
|
raises(ValueError, "cfg.option('choice').value.set('no')")
|
||||||
assert api.option('choice').owner.isdefault()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
|
|
||||||
|
|
||||||
def test_choiceoption_calc_opt_function():
|
def test_choiceoption_calc_opt_function():
|
||||||
|
@ -128,19 +122,18 @@ def test_choiceoption_calc_opt_function():
|
||||||
values_params=Params((ParamOption(str_),)))
|
values_params=Params((ParamOption(str_),)))
|
||||||
odesc = OptionDescription('od', '', [str_, choice])
|
odesc = OptionDescription('od', '', [str_, choice])
|
||||||
cfg = Config(odesc)
|
cfg = Config(odesc)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
owner = cfg.owner.get()
|
||||||
owner = api.owner.get()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
assert api.option('choice').owner.isdefault()
|
|
||||||
#
|
#
|
||||||
api.option('choice').value.set('val1')
|
cfg.option('choice').value.set('val1')
|
||||||
assert api.option('choice').owner.get() == owner
|
assert cfg.option('choice').owner.get() == owner
|
||||||
#
|
#
|
||||||
api.option('choice').value.reset()
|
cfg.option('choice').value.reset()
|
||||||
assert api.option('choice').owner.isdefault()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
#
|
#
|
||||||
raises(ValueError, "api.option('choice').value.set('no')")
|
raises(ValueError, "cfg.option('choice').value.set('no')")
|
||||||
assert api.option('choice').owner.isdefault()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
|
|
||||||
|
|
||||||
def test_choiceoption_calc_opt_function_propertyerror():
|
def test_choiceoption_calc_opt_function_propertyerror():
|
||||||
|
@ -151,12 +144,11 @@ def test_choiceoption_calc_opt_function_propertyerror():
|
||||||
values_params=Params((ParamOption(str_),)))
|
values_params=Params((ParamOption(str_),)))
|
||||||
odesc = OptionDescription('od', '', [str_, choice])
|
odesc = OptionDescription('od', '', [str_, choice])
|
||||||
cfg = Config(odesc)
|
cfg = Config(odesc)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
raises(ValueError, "api.option('choice').value.set('no')")
|
raises(ValueError, "cfg.option('choice').value.set('no')")
|
||||||
else:
|
else:
|
||||||
raises(ConfigError, "api.option('choice').value.set('no')")
|
raises(ConfigError, "cfg.option('choice').value.set('no')")
|
||||||
|
|
||||||
|
|
||||||
def test_choiceoption_calc_opt_multi_function():
|
def test_choiceoption_calc_opt_multi_function():
|
||||||
|
@ -175,27 +167,26 @@ def test_choiceoption_calc_opt_multi_function():
|
||||||
multi=True)
|
multi=True)
|
||||||
odesc = OptionDescription('od', '', [str_, choice, ch2])
|
odesc = OptionDescription('od', '', [str_, choice, ch2])
|
||||||
cfg = Config(odesc)
|
cfg = Config(odesc)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
owner = cfg.owner.get()
|
||||||
owner = api.owner.get()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
assert api.option('choice').owner.isdefault()
|
assert cfg.option('choice').value.get() == []
|
||||||
assert api.option('choice').value.get() == []
|
|
||||||
#
|
#
|
||||||
api.option('choice').value.set(['val1'])
|
cfg.option('choice').value.set(['val1'])
|
||||||
assert api.option('choice').owner.get() == owner
|
assert cfg.option('choice').owner.get() == owner
|
||||||
#
|
#
|
||||||
raises(ValueError, "api.option('choice').value.set([undefined])")
|
raises(ValueError, "cfg.option('choice').value.set([undefined])")
|
||||||
#
|
#
|
||||||
api.option('choice').value.set(['val1'])
|
cfg.option('choice').value.set(['val1'])
|
||||||
assert api.option('choice').owner.get() == owner
|
assert cfg.option('choice').owner.get() == owner
|
||||||
#
|
#
|
||||||
api.option('choice').value.reset()
|
cfg.option('choice').value.reset()
|
||||||
assert api.option('choice').owner.isdefault()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
#
|
#
|
||||||
raises(ValueError, "api.option('choice').value.set('no')")
|
raises(ValueError, "cfg.option('choice').value.set('no')")
|
||||||
assert api.option('choice').owner.isdefault()
|
assert cfg.option('choice').owner.isdefault()
|
||||||
#
|
#
|
||||||
raises(ValueError, "api.option('ch2').value.get()")
|
raises(ValueError, "cfg.option('ch2').value.get()")
|
||||||
|
|
||||||
|
|
||||||
def test_choiceoption_calc_invalid():
|
def test_choiceoption_calc_invalid():
|
||||||
|
@ -216,6 +207,5 @@ def test_choiceoption_calc_not_list():
|
||||||
multi=True)
|
multi=True)
|
||||||
odesc = OptionDescription('od', '', [str_, choice])
|
odesc = OptionDescription('od', '', [str_, choice])
|
||||||
cfg = Config(odesc)
|
cfg = Config(odesc)
|
||||||
api = getapi(cfg)
|
cfg.property.read_write()
|
||||||
api.property.read_write()
|
raises(ConfigError, "cfg.option('choice').value.set(['val1'])")
|
||||||
raises(ConfigError, "api.option('choice').value.set(['val1'])")
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ do_autopath()
|
||||||
from tiramisu import Config, IntOption, FloatOption, StrOption, ChoiceOption, \
|
from tiramisu import Config, IntOption, FloatOption, StrOption, ChoiceOption, \
|
||||||
BoolOption, FilenameOption, UnicodeOption, SymLinkOption, IPOption, \
|
BoolOption, FilenameOption, UnicodeOption, SymLinkOption, IPOption, \
|
||||||
PortOption, NetworkOption, NetmaskOption, BroadcastOption, \
|
PortOption, NetworkOption, NetmaskOption, BroadcastOption, \
|
||||||
DomainnameOption, OptionDescription, getapi
|
DomainnameOption, OptionDescription
|
||||||
from tiramisu.error import PropertiesOptionError
|
from tiramisu.error import PropertiesOptionError
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,37 +43,6 @@ def _is_same_opt(opt1, opt2):
|
||||||
assert opt1 == opt2
|
assert opt1 == opt2
|
||||||
|
|
||||||
|
|
||||||
#def test_iter_config():
|
|
||||||
# "iteration on config object"
|
|
||||||
# s = StrOption("string", "", default="string")
|
|
||||||
# s2 = StrOption("string2", "", default="string2")
|
|
||||||
# descr = OptionDescription("options", "", [s, s2])
|
|
||||||
# config = Config(descr)
|
|
||||||
# assert [(name, value) for name, value in config] == \
|
|
||||||
# [('string', 'string'), ('string2', 'string2')]
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#def test_iter_config_property():
|
|
||||||
# "iteration on config object"
|
|
||||||
# s = StrOption("string", "", default="string", properties=('disabled',))
|
|
||||||
# s2 = StrOption("string2", "", default="string2")
|
|
||||||
# descr = OptionDescription("options", "", [s, s2])
|
|
||||||
# config = Config(descr)
|
|
||||||
# config.read_only()
|
|
||||||
# assert [(name, value) for name, value in config] == \
|
|
||||||
# [('string2', 'string2')]
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#def test_iter_subconfig():
|
|
||||||
# "iteration on config sub object"
|
|
||||||
# descr = make_description()
|
|
||||||
# conf = Config(descr)
|
|
||||||
# for (name, value), (gname, gvalue) in \
|
|
||||||
# zip(conf.gc, [("name", "ref"), ("dummy", False)]):
|
|
||||||
# assert name == gname
|
|
||||||
# assert value == gvalue
|
|
||||||
|
|
||||||
|
|
||||||
def test_od_not_list():
|
def test_od_not_list():
|
||||||
b = BoolOption('bool', '', multi=True)
|
b = BoolOption('bool', '', multi=True)
|
||||||
raises(ValueError, "OptionDescription('od', '', b)")
|
raises(ValueError, "OptionDescription('od', '', b)")
|
||||||
|
@ -93,19 +62,18 @@ def test_make_dict():
|
||||||
BoolOption("b", "", default=False, properties=('hidden',))]),
|
BoolOption("b", "", default=False, properties=('hidden',))]),
|
||||||
IntOption("int", "", default=42)])
|
IntOption("int", "", default=42)])
|
||||||
config = Config(descr)
|
config = Config(descr)
|
||||||
api = getapi(config)
|
config.property.read_write()
|
||||||
api.property.read_write()
|
config.permissive.set(frozenset(['hidden']))
|
||||||
api.permissive.set(frozenset(['hidden']))
|
d = config.option.make_dict()
|
||||||
d = api.option.make_dict()
|
|
||||||
assert d == {"s1.a": False, "int": 42}
|
assert d == {"s1.a": False, "int": 42}
|
||||||
api.option('int').value.set(43)
|
config.option('int').value.set(43)
|
||||||
api.option('s1.a').value.set(True)
|
config.option('s1.a').value.set(True)
|
||||||
d = api.option.make_dict()
|
d = config.option.make_dict()
|
||||||
assert d == {"s1.a": True, "int": 43}
|
assert d == {"s1.a": True, "int": 43}
|
||||||
d2 = api.option.make_dict(flatten=True)
|
d2 = config.option.make_dict(flatten=True)
|
||||||
assert d2 == {'a': True, 'int': 43}
|
assert d2 == {'a': True, 'int': 43}
|
||||||
raises(ValueError, 'd2 = api.option.make_dict(withvalue="3")')
|
raises(ValueError, 'd2 = config.option.make_dict(withvalue="3")')
|
||||||
d = api.forcepermissive.option.make_dict()
|
d = config.forcepermissive.option.make_dict()
|
||||||
assert d == {"s1.a": True, "s1.b": False, "int": 43}
|
assert d == {"s1.a": True, "s1.b": False, "int": 43}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,11 +87,10 @@ def test_make_dict_with_disabled():
|
||||||
BoolOption("b", "", default=False)], properties=('disabled',)),
|
BoolOption("b", "", default=False)], properties=('disabled',)),
|
||||||
IntOption("int", "", default=42)])
|
IntOption("int", "", default=42)])
|
||||||
config = Config(descr)
|
config = Config(descr)
|
||||||
api = getapi(config)
|
config.property.read_only()
|
||||||
api.property.read_only()
|
assert config.option.make_dict() == {"s1.a": False, "int": 42}
|
||||||
assert api.option.make_dict() == {"s1.a": False, "int": 42}
|
assert config.forcepermissive.option.make_dict() == {"s1.a": False, "int": 42}
|
||||||
assert api.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 api.unrestraint.option.make_dict() == {"int": 42, "s1.a": False, "s1.b": False, "s2.a": False, "s2.b": False}
|
|
||||||
|
|
||||||
|
|
||||||
def test_make_dict_with_disabled_withoption():
|
def test_make_dict_with_disabled_withoption():
|
||||||
|
@ -136,11 +103,10 @@ def test_make_dict_with_disabled_withoption():
|
||||||
BoolOption("b", "", default=False)], properties=('disabled',)),
|
BoolOption("b", "", default=False)], properties=('disabled',)),
|
||||||
IntOption("int", "", default=42)])
|
IntOption("int", "", default=42)])
|
||||||
config = Config(descr)
|
config = Config(descr)
|
||||||
api = getapi(config)
|
config.property.read_only()
|
||||||
api.property.read_only()
|
assert config.option.make_dict(withoption="a") == {"s1.a": False}
|
||||||
assert api.option.make_dict(withoption="a") == {"s1.a": False}
|
assert config.forcepermissive.option.make_dict(withoption="a") == {"s1.a": False}
|
||||||
assert api.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 api.unrestraint.option.make_dict(withoption="a") == {"s1.a": False, "s1.b": False, "s2.a": False, "s2.b": False}
|
|
||||||
|
|
||||||
|
|
||||||
def test_make_dict_with_disabled_in_callback():
|
def test_make_dict_with_disabled_in_callback():
|
||||||
|
@ -153,9 +119,8 @@ def test_make_dict_with_disabled_in_callback():
|
||||||
BoolOption("b", "", default=False)], properties=('disabled',)),
|
BoolOption("b", "", default=False)], properties=('disabled',)),
|
||||||
IntOption("int", "", default=42)])
|
IntOption("int", "", default=42)])
|
||||||
config = Config(descr)
|
config = Config(descr)
|
||||||
api = getapi(config)
|
config.property.read_only()
|
||||||
api.property.read_only()
|
d = config.option.make_dict()
|
||||||
d = api.option.make_dict()
|
|
||||||
assert d == {"s1.a": False, "int": 42}
|
assert d == {"s1.a": False, "int": 42}
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,37 +136,35 @@ def test_make_dict_fullpath():
|
||||||
IntOption("int", "", default=42)]),
|
IntOption("int", "", default=42)]),
|
||||||
IntOption("introot", "", default=42)])
|
IntOption("introot", "", default=42)])
|
||||||
config = Config(descr)
|
config = Config(descr)
|
||||||
api = getapi(config)
|
config.property.read_only()
|
||||||
api.property.read_only()
|
assert config.option.make_dict() == {"opt.s1.a": False, "opt.int": 42, "introot": 42}
|
||||||
assert api.option.make_dict() == {"opt.s1.a": False, "opt.int": 42, "introot": 42}
|
assert config.option('opt').make_dict() == {"s1.a": False, "int": 42}
|
||||||
assert api.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 api.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 api.option('opt').make_dict(fullpath=True) == {"opt.s1.a": False, "opt.int": 42}
|
|
||||||
|
|
||||||
|
|
||||||
def test_find_in_config():
|
def test_find_in_config():
|
||||||
"finds option in config"
|
"finds option in config"
|
||||||
descr = make_description()
|
descr = make_description()
|
||||||
conf = Config(descr)
|
conf = Config(descr)
|
||||||
api = getapi(conf)
|
conf.property.read_only()
|
||||||
api.property.read_only()
|
conf.permissive.set(frozenset(['hidden']))
|
||||||
api.permissive.set(frozenset(['hidden']))
|
ret = conf.option.find('dummy')
|
||||||
ret = api.option.find('dummy')
|
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
_is_same_opt(ret[0].option.get(), api.option('gc.dummy').option.get())
|
_is_same_opt(ret[0].option.get(), conf.option('gc.dummy').option.get())
|
||||||
#
|
#
|
||||||
ret = api.option.find('dummy', first=True).option.get()
|
ret = conf.option.find('dummy', first=True).option.get()
|
||||||
_is_same_opt(ret, api.option('gc.dummy').option.get())
|
_is_same_opt(ret, conf.option('gc.dummy').option.get())
|
||||||
#
|
#
|
||||||
ret = api.option.find('float')
|
ret = conf.option.find('float')
|
||||||
assert len(ret) == 2
|
assert len(ret) == 2
|
||||||
_is_same_opt(ret[0].option.get(), api.option('gc.float').option.get())
|
_is_same_opt(ret[0].option.get(), conf.option('gc.float').option.get())
|
||||||
_is_same_opt(ret[1].option.get(), api.option('float').option.get())
|
_is_same_opt(ret[1].option.get(), conf.option('float').option.get())
|
||||||
#
|
#
|
||||||
_is_same_opt(api.option.find('bool', first=True).option.get(), api.option('gc.gc2.bool').option.get())
|
_is_same_opt(conf.option.find('bool', first=True).option.get(), conf.option('gc.gc2.bool').option.get())
|
||||||
_is_same_opt(api.option.find('bool', value=True, first=True).option.get(), api.option('bool').option.get())
|
_is_same_opt(conf.option.find('bool', value=True, first=True).option.get(), conf.option('bool').option.get())
|
||||||
_is_same_opt(api.option.find('dummy', first=True).option.get(), api.option('gc.dummy').option.get())
|
_is_same_opt(conf.option.find('dummy', first=True).option.get(), conf.option('gc.dummy').option.get())
|
||||||
_is_same_opt(api.option.find('float', first=True).option.get(), api.option('gc.float').option.get())
|
_is_same_opt(conf.option.find('float', first=True).option.get(), conf.option('gc.float').option.get())
|
||||||
#FIXME cannot find an option without name
|
#FIXME cannot find an option without name
|
||||||
#ret = conf.find(bytype=ChoiceOption)
|
#ret = conf.find(bytype=ChoiceOption)
|
||||||
#assert len(ret) == 2
|
#assert len(ret) == 2
|
||||||
|
@ -214,165 +177,109 @@ def test_find_in_config():
|
||||||
#_is_same_opt(ret[0], conf.unwrap_from_path('gc.name'))
|
#_is_same_opt(ret[0], conf.unwrap_from_path('gc.name'))
|
||||||
#_is_same_opt(conf.find_first(byvalue='ref'), conf.unwrap_from_path('gc.name'))
|
#_is_same_opt(conf.find_first(byvalue='ref'), conf.unwrap_from_path('gc.name'))
|
||||||
#
|
#
|
||||||
ret = api.option.find('prop')
|
ret = conf.option.find('prop')
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
_is_same_opt(ret[0].option.get(), api.option('gc.prop').option.get())
|
_is_same_opt(ret[0].option.get(), conf.option('gc.prop').option.get())
|
||||||
#
|
#
|
||||||
ret = api.option.find('prop', value=None)
|
ret = conf.option.find('prop', value=None)
|
||||||
ret = api.option.find('prop')
|
ret = conf.option.find('prop')
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
_is_same_opt(ret[0].option.get(), api.option('gc.prop').option.get())
|
_is_same_opt(ret[0].option.get(), conf.option('gc.prop').option.get())
|
||||||
#
|
#
|
||||||
api.property.read_write()
|
conf.property.read_write()
|
||||||
raises(AttributeError, "assert api.option.find('prop').option.get()")
|
raises(AttributeError, "assert conf.option.find('prop').option.get()")
|
||||||
ret = api.unrestraint.option.find(name='prop')
|
ret = conf.unrestraint.option.find(name='prop')
|
||||||
assert len(ret) == 2
|
assert len(ret) == 2
|
||||||
_is_same_opt(ret[0].option.get(), api.unrestraint.option('gc.gc2.prop').option.get())
|
_is_same_opt(ret[0].option.get(), conf.unrestraint.option('gc.gc2.prop').option.get())
|
||||||
_is_same_opt(ret[1].option.get(), api.forcepermissive.option('gc.prop').option.get())
|
_is_same_opt(ret[1].option.get(), conf.forcepermissive.option('gc.prop').option.get())
|
||||||
#
|
#
|
||||||
ret = api.forcepermissive.option.find('prop')
|
ret = conf.forcepermissive.option.find('prop')
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
_is_same_opt(ret[0].option.get(), api.forcepermissive.option('gc.prop').option.get())
|
_is_same_opt(ret[0].option.get(), conf.forcepermissive.option('gc.prop').option.get())
|
||||||
#
|
#
|
||||||
_is_same_opt(api.forcepermissive.option.find('prop', first=True).option.get(), api.forcepermissive.option('gc.prop').option.get())
|
_is_same_opt(conf.forcepermissive.option.find('prop', first=True).option.get(), conf.forcepermissive.option('gc.prop').option.get())
|
||||||
# combinaison of filters
|
# combinaison of filters
|
||||||
ret = api.unrestraint.option.find('prop', type=BoolOption)
|
ret = conf.unrestraint.option.find('prop', type=BoolOption)
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
_is_same_opt(ret[0].option.get(), api.unrestraint.option('gc.gc2.prop').option.get())
|
_is_same_opt(ret[0].option.get(), conf.unrestraint.option('gc.gc2.prop').option.get())
|
||||||
_is_same_opt(api.unrestraint.option.find('prop', type=BoolOption, first=True).option.get(), api.unrestraint.option('gc.gc2.prop').option.get())
|
_is_same_opt(conf.unrestraint.option.find('prop', type=BoolOption, first=True).option.get(), conf.unrestraint.option('gc.gc2.prop').option.get())
|
||||||
#
|
#
|
||||||
ret = api.option.find('dummy', value=False)
|
ret = conf.option.find('dummy', value=False)
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
_is_same_opt(ret[0].option.get(), api.option('gc.dummy').option.get())
|
_is_same_opt(ret[0].option.get(), conf.option('gc.dummy').option.get())
|
||||||
#
|
#
|
||||||
_is_same_opt(api.option.find('dummy', value=False, first=True).option.get(), api.option('gc.dummy').option.get())
|
_is_same_opt(conf.option.find('dummy', value=False, first=True).option.get(), conf.option('gc.dummy').option.get())
|
||||||
#subconfig
|
#subconfig
|
||||||
ret = api.option('gc').find('dummy')
|
ret = conf.option('gc').find('dummy')
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
_is_same_opt(ret[0].option.get(), api.option('gc.dummy').option.get())
|
_is_same_opt(ret[0].option.get(), conf.option('gc.dummy').option.get())
|
||||||
#
|
#
|
||||||
ret = api.option('gc').find('float')
|
ret = conf.option('gc').find('float')
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
_is_same_opt(ret[0].option.get(), api.option('gc.float').option.get())
|
_is_same_opt(ret[0].option.get(), conf.option('gc.float').option.get())
|
||||||
#
|
#
|
||||||
ret = api.option('gc').find('bool')
|
ret = conf.option('gc').find('bool')
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
_is_same_opt(ret[0].option.get(), api.option('gc.gc2.bool').option.get())
|
_is_same_opt(ret[0].option.get(), conf.option('gc.gc2.bool').option.get())
|
||||||
_is_same_opt(api.option('gc').find('bool', value=False, first=True).option.get(), api.option('gc.gc2.bool').option.get())
|
_is_same_opt(conf.option('gc').find('bool', value=False, first=True).option.get(), conf.option('gc.gc2.bool').option.get())
|
||||||
#
|
#
|
||||||
raises(AttributeError, "assert api.option('gc').find('bool', value=True, first=True).option.get()")
|
raises(AttributeError, "assert conf.option('gc').find('bool', value=True, first=True).option.get()")
|
||||||
#
|
#
|
||||||
raises(AttributeError, "api.option('gc').find('wantref').option.get()")
|
raises(AttributeError, "conf.option('gc').find('wantref').option.get()")
|
||||||
#
|
#
|
||||||
ret = api.unrestraint.option('gc').find('prop')
|
ret = conf.unrestraint.option('gc').find('prop')
|
||||||
assert len(ret) == 2
|
assert len(ret) == 2
|
||||||
_is_same_opt(ret[0].option.get(), api.unrestraint.option('gc.gc2.prop').option.get())
|
_is_same_opt(ret[0].option.get(), conf.unrestraint.option('gc.gc2.prop').option.get())
|
||||||
_is_same_opt(ret[1].option.get(), api.forcepermissive.option('gc.prop').option.get())
|
_is_same_opt(ret[1].option.get(), conf.forcepermissive.option('gc.prop').option.get())
|
||||||
#
|
#
|
||||||
api.property.read_only()
|
conf.property.read_only()
|
||||||
ret = api.option('gc').find('prop')
|
ret = conf.option('gc').find('prop')
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
_is_same_opt(ret[0].option.get(), api.option('gc.prop').option.get())
|
_is_same_opt(ret[0].option.get(), conf.option('gc.prop').option.get())
|
||||||
# not OptionDescription
|
# not OptionDescription
|
||||||
raises(AttributeError, "api.option.find('gc', first=True)")
|
raises(AttributeError, "conf.option.find('gc', first=True)")
|
||||||
raises(AttributeError, "api.option.find('gc2', first=True)")
|
raises(AttributeError, "conf.option.find('gc2', first=True)")
|
||||||
|
|
||||||
|
|
||||||
def test_find_multi():
|
def test_find_multi():
|
||||||
b = BoolOption('bool', '', multi=True)
|
b = BoolOption('bool', '', multi=True)
|
||||||
o = OptionDescription('od', '', [b])
|
o = OptionDescription('od', '', [b])
|
||||||
conf = Config(o)
|
conf = Config(o)
|
||||||
api = getapi(conf)
|
|
||||||
#
|
#
|
||||||
raises(AttributeError, "api.option.find('bool', value=True)")
|
raises(AttributeError, "conf.option.find('bool', value=True)")
|
||||||
raises(AttributeError, "api.option.find('bool', value=True, first=True)")
|
raises(AttributeError, "conf.option.find('bool', value=True, first=True)")
|
||||||
api.option('bool').value.set([False])
|
conf.option('bool').value.set([False])
|
||||||
raises(AttributeError, "api.option.find('bool', value=True)")
|
raises(AttributeError, "conf.option.find('bool', value=True)")
|
||||||
raises(AttributeError, "api.option.find('bool', value=True, first=True)")
|
raises(AttributeError, "conf.option.find('bool', value=True, first=True)")
|
||||||
api.option('bool').value.set([False, False])
|
conf.option('bool').value.set([False, False])
|
||||||
raises(AttributeError, "api.option.find('bool', value=True)")
|
raises(AttributeError, "conf.option.find('bool', value=True)")
|
||||||
raises(AttributeError, "api.option.find('bool', value=True, first=True)")
|
raises(AttributeError, "conf.option.find('bool', value=True, first=True)")
|
||||||
api.option('bool').value.set([False, False, True])
|
conf.option('bool').value.set([False, False, True])
|
||||||
ret = api.option.find('bool', value=True)
|
ret = conf.option.find('bool', value=True)
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
_is_same_opt(ret[0].option.get(), b)
|
_is_same_opt(ret[0].option.get(), b)
|
||||||
_is_same_opt(api.option.find('bool', value=True, first=True).option.get(), b)
|
_is_same_opt(conf.option.find('bool', value=True, first=True).option.get(), b)
|
||||||
|
|
||||||
|
|
||||||
def test_does_not_find_in_config():
|
def test_does_not_find_in_config():
|
||||||
descr = make_description()
|
descr = make_description()
|
||||||
conf = Config(descr)
|
conf = Config(descr)
|
||||||
api = getapi(conf)
|
raises(AttributeError, "conf.option.find('IDontExist')")
|
||||||
api
|
|
||||||
raises(AttributeError, "api.option.find('IDontExist')")
|
|
||||||
|
|
||||||
|
|
||||||
def test_filename():
|
def test_filename():
|
||||||
a = FilenameOption('a', '')
|
a = FilenameOption('a', '')
|
||||||
o = OptionDescription('o', '', [a])
|
o = OptionDescription('o', '', [a])
|
||||||
cfg = Config(o)
|
cfg = Config(o)
|
||||||
api = getapi(cfg)
|
cfg.option('a').value.set('/')
|
||||||
api.option('a').value.set('/')
|
cfg.option('a').value.set('/tmp')
|
||||||
api.option('a').value.set('/tmp')
|
cfg.option('a').value.set('/tmp/')
|
||||||
api.option('a').value.set('/tmp/')
|
cfg.option('a').value.set('/tmp/text.txt')
|
||||||
api.option('a').value.set('/tmp/text.txt')
|
cfg.option('a').value.set('tmp')
|
||||||
api.option('a').value.set('tmp')
|
cfg.option('a').value.set('tmp/')
|
||||||
api.option('a').value.set('tmp/')
|
cfg.option('a').value.set('tmp/text.txt')
|
||||||
api.option('a').value.set('tmp/text.txt')
|
raises(ValueError, "cfg.option('a').value.set('/tmp/with space.txt')")
|
||||||
raises(ValueError, "api.option('a').value.set('/tmp/with space.txt')")
|
raises(ValueError, "cfg.option('a').value.set('/tmp/with$.txt')")
|
||||||
raises(ValueError, "api.option('a').value.set('/tmp/with$.txt')")
|
|
||||||
|
|
||||||
|
|
||||||
#def test_iter_all():
|
|
||||||
# s = StrOption("string", "", default="string")
|
|
||||||
# s2 = StrOption("string2", "", default="string2")
|
|
||||||
# descr = OptionDescription("options", "", [s, s2])
|
|
||||||
# config = Config(descr)
|
|
||||||
# assert list(config.iter_all()) == [('string', 'string'), ('string2', 'string2')]
|
|
||||||
# for i in config.iter_all():
|
|
||||||
# #test StopIteration
|
|
||||||
# break
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#def test_iter_all_force_permissive():
|
|
||||||
# s = StrOption("string", "", default="string")
|
|
||||||
# s2 = StrOption("string2", "", default="string2")
|
|
||||||
# s3 = StrOption("string3", "", default="string3", properties=('hidden',))
|
|
||||||
# descr = OptionDescription("options", "", [s, s2, s3])
|
|
||||||
# config = Config(descr)
|
|
||||||
# api = getapi(config)
|
|
||||||
# api.property.read_write()
|
|
||||||
# api.permissive.set(('hidden',))
|
|
||||||
# assert list(config.iter_all()) == [('string', 'string'), ('string2', 'string2')]
|
|
||||||
# assert list(config.iter_all(force_permissive=True)) == [('string', 'string'),
|
|
||||||
# ('string2', 'string2'),
|
|
||||||
# ('string3', 'string3')]
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#def test_iter_all_prop():
|
|
||||||
# s = StrOption("string", "", default="string", properties=('disabled',))
|
|
||||||
# s2 = StrOption("string2", "", default="string2")
|
|
||||||
# descr = OptionDescription("options", "", [s, s2])
|
|
||||||
# config = Config(descr)
|
|
||||||
# api = getapi(config)
|
|
||||||
# api.property.read_only()
|
|
||||||
# assert list(config.iter_all()) == [('string2', 'string2')]
|
|
||||||
|
|
||||||
|
|
||||||
#def test_impl_getpaths():
|
|
||||||
# s = StrOption("string", "", default="string", properties=('disabled',))
|
|
||||||
# s2 = StrOption("string2", "", default="string2")
|
|
||||||
# s3 = StrOption("string3", "", default="string3")
|
|
||||||
# s4 = StrOption("string4", "", default="string4", properties=('hidden',))
|
|
||||||
# od = OptionDescription('od', '', [s3, s4])
|
|
||||||
# descr = OptionDescription("options", "", [s, s2, od])
|
|
||||||
# config = Config(descr)
|
|
||||||
# assert ['string', 'string2', 'od.string3', 'od.string4'] == config.cfgimpl_get_description().impl_getpaths()
|
|
||||||
# assert ['string', 'string2', 'od', 'od.string3', 'od.string4'] == config.cfgimpl_get_description().impl_getpaths(include_groups=True)
|
|
||||||
# config.read_write()
|
|
||||||
# raises(PropertiesOptionError, "config.od.string4")
|
|
||||||
# assert ['string', 'string2', 'od.string3', 'od.string4'] == config.cfgimpl_get_description().impl_getpaths()
|
|
||||||
# assert ['string', 'string2', 'od', 'od.string3', 'od.string4'] == config.cfgimpl_get_description().impl_getpaths(include_groups=True)
|
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_option():
|
def test_invalid_option():
|
||||||
|
@ -429,10 +336,9 @@ def test_invalid_option():
|
||||||
raises(ValueError, "DomainnameOption('a', '', multi=True, default_multi=1)")
|
raises(ValueError, "DomainnameOption('a', '', multi=True, default_multi=1)")
|
||||||
|
|
||||||
|
|
||||||
#def test_help():
|
def test_help():
|
||||||
# stro = StrOption('s', '', multi=True)
|
stro = StrOption('s', '', multi=True)
|
||||||
# od1 = OptionDescription('o', '', [stro])
|
od1 = OptionDescription('o', '', [stro])
|
||||||
# od2 = OptionDescription('o', '', [od1])
|
od2 = OptionDescription('o', '', [od1])
|
||||||
# cfg = Config(od2)
|
cfg = Config(od2)
|
||||||
# api = getapi(cfg)
|
cfg.help(_display=False, _valid=True)
|
||||||
# api.help(_display=False, _valid=True)
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from py.test import raises
|
||||||
from tiramisu.setting import groups, owners
|
from tiramisu.setting import groups, owners
|
||||||
from tiramisu import IntOption, StrOption, NetworkOption, NetmaskOption, \
|
from tiramisu import IntOption, StrOption, NetworkOption, NetmaskOption, \
|
||||||
OptionDescription, MasterSlaves, Config, GroupConfig, MetaConfig, \
|
OptionDescription, MasterSlaves, Config, GroupConfig, MetaConfig, \
|
||||||
getapi, Params, ParamOption, ParamValue
|
Params, ParamOption, ParamValue
|
||||||
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError, SlaveError
|
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError, SlaveError
|
||||||
|
|
||||||
owners.addowner('meta1')
|
owners.addowner('meta1')
|
||||||
|
@ -38,150 +38,143 @@ def make_metaconfig(double=False):
|
||||||
conf1 = Config(od2, session_id='conf1')
|
conf1 = Config(od2, session_id='conf1')
|
||||||
conf2 = Config(od2, session_id='conf2')
|
conf2 = Config(od2, session_id='conf2')
|
||||||
meta = MetaConfig([conf1, conf2], session_id='meta')
|
meta = MetaConfig([conf1, conf2], session_id='meta')
|
||||||
api = getapi(meta)
|
|
||||||
if double:
|
if double:
|
||||||
api.owner.set(owners.meta2)
|
meta.owner.set(owners.meta2)
|
||||||
meta = MetaConfig([meta])
|
meta = MetaConfig([meta])
|
||||||
api = getapi(meta)
|
meta.property.read_write()
|
||||||
api.property.read_write()
|
meta.owner.set(owners.meta1)
|
||||||
api.owner.set(owners.meta1)
|
return meta
|
||||||
return api
|
|
||||||
|
|
||||||
|
|
||||||
def test_unknown_config():
|
def test_unknown_config():
|
||||||
api = make_metaconfig()
|
meta = make_metaconfig()
|
||||||
raises(ConfigError, "api.config('unknown')")
|
raises(ConfigError, "meta.config('unknown')")
|
||||||
|
|
||||||
|
|
||||||
#FIXME ne pas mettre 2 meta dans une config
|
#FIXME ne pas mettre 2 meta dans une config
|
||||||
#FIXME ne pas mettre 2 OD differents dans un meta
|
#FIXME ne pas mettre 2 OD differents dans un meta
|
||||||
def test_none():
|
def test_none():
|
||||||
api = make_metaconfig()
|
meta = make_metaconfig()
|
||||||
assert api.option('od1.i3').value.get() is api.config('conf1').option('od1.i3').value.get() is api.config('conf2').option('od1.i3').value.get() is None
|
assert meta.option('od1.i3').value.get() is meta.config('conf1').option('od1.i3').value.get() is meta.config('conf2').option('od1.i3').value.get() is None
|
||||||
assert api.option('od1.i3').owner.get() is api.config('conf1').option('od1.i3').owner.get() is api.config('conf2').option('od1.i3').owner.get() is owners.default
|
assert meta.option('od1.i3').owner.get() is meta.config('conf1').option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.default
|
||||||
#
|
#
|
||||||
api.option('od1.i3').value.set(3)
|
meta.option('od1.i3').value.set(3)
|
||||||
assert api.option('od1.i3').value.get() == api.config('conf1').option('od1.i3').value.get() == api.config('conf2').option('od1.i3').value.get() == 3
|
assert meta.option('od1.i3').value.get() == meta.config('conf1').option('od1.i3').value.get() == meta.config('conf2').option('od1.i3').value.get() == 3
|
||||||
assert api.option('od1.i3').owner.get() is api.config('conf1').option('od1.i3').owner.get() is api.config('conf2').option('od1.i3').owner.get() is owners.meta1
|
assert meta.option('od1.i3').owner.get() is meta.config('conf1').option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.meta1
|
||||||
#
|
#
|
||||||
api.config('conf1').option('od1.i3').value.set(2)
|
meta.config('conf1').option('od1.i3').value.set(2)
|
||||||
assert api.option('od1.i3').value.get() == api.config('conf2').option('od1.i3').value.get() == 3
|
assert meta.option('od1.i3').value.get() == meta.config('conf2').option('od1.i3').value.get() == 3
|
||||||
assert api.config('conf1').option('od1.i3').value.get() == 2
|
assert meta.config('conf1').option('od1.i3').value.get() == 2
|
||||||
assert api.option('od1.i3').owner.get() is api.config('conf2').option('od1.i3').owner.get() is owners.meta1
|
assert meta.option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.meta1
|
||||||
assert api.config('conf1').option('od1.i3').owner.get() is owners.user
|
assert meta.config('conf1').option('od1.i3').owner.get() is owners.user
|
||||||
#
|
#
|
||||||
api.option('od1.i3').value.set(4)
|
meta.option('od1.i3').value.set(4)
|
||||||
assert api.option('od1.i3').value.get() == api.config('conf2').option('od1.i3').value.get() == 4
|
assert meta.option('od1.i3').value.get() == meta.config('conf2').option('od1.i3').value.get() == 4
|
||||||
assert api.config('conf1').option('od1.i3').value.get() == 2
|
assert meta.config('conf1').option('od1.i3').value.get() == 2
|
||||||
assert api.option('od1.i3').owner.get() is api.config('conf2').option('od1.i3').owner.get() is owners.meta1
|
assert meta.option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.meta1
|
||||||
assert api.config('conf1').option('od1.i3').owner.get() is owners.user
|
assert meta.config('conf1').option('od1.i3').owner.get() is owners.user
|
||||||
#
|
#
|
||||||
api.option('od1.i3').value.reset()
|
meta.option('od1.i3').value.reset()
|
||||||
assert api.option('od1.i3').value.get() is api.config('conf2').option('od1.i3').value.get() is None
|
assert meta.option('od1.i3').value.get() is meta.config('conf2').option('od1.i3').value.get() is None
|
||||||
assert api.config('conf1').option('od1.i3').value.get() == 2
|
assert meta.config('conf1').option('od1.i3').value.get() == 2
|
||||||
assert api.option('od1.i3').owner.get() is api.config('conf2').option('od1.i3').owner.get() is owners.default
|
assert meta.option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.default
|
||||||
assert api.config('conf1').option('od1.i3').owner.get() is owners.user
|
assert meta.config('conf1').option('od1.i3').owner.get() is owners.user
|
||||||
#
|
#
|
||||||
api.config('conf1').option('od1.i3').value.reset()
|
meta.config('conf1').option('od1.i3').value.reset()
|
||||||
assert api.option('od1.i3').value.get() is api.config('conf1').option('od1.i3').value.get() is api.config('conf2').option('od1.i3').value.get() is None
|
assert meta.option('od1.i3').value.get() is meta.config('conf1').option('od1.i3').value.get() is meta.config('conf2').option('od1.i3').value.get() is None
|
||||||
assert api.option('od1.i3').owner.get() is api.config('conf1').option('od1.i3').owner.get() is api.config('conf2').option('od1.i3').owner.get() is owners.default
|
assert meta.option('od1.i3').owner.get() is meta.config('conf1').option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.default
|
||||||
|
|
||||||
|
|
||||||
def test_default():
|
def test_default():
|
||||||
api = make_metaconfig()
|
meta = make_metaconfig()
|
||||||
assert api.option('od1.i2').value.get() == api.config('conf1').option('od1.i2').value.get() == api.config('conf2').option('od1.i2').value.get() == 1
|
assert meta.option('od1.i2').value.get() == meta.config('conf1').option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 1
|
||||||
assert api.option('od1.i2').owner.get() is api.config('conf1').option('od1.i2').owner.get() is api.config('conf2').option('od1.i2').owner.get() is owners.default
|
assert meta.option('od1.i2').owner.get() is meta.config('conf1').option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.default
|
||||||
#
|
#
|
||||||
api.option('od1.i2').value.set(3)
|
meta.option('od1.i2').value.set(3)
|
||||||
assert api.option('od1.i2').value.get() == api.config('conf1').option('od1.i2').value.get() == api.config('conf2').option('od1.i2').value.get() == 3
|
assert meta.option('od1.i2').value.get() == meta.config('conf1').option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 3
|
||||||
assert api.option('od1.i2').owner.get() is api.config('conf1').option('od1.i2').owner.get() is api.config('conf2').option('od1.i2').owner.get() is owners.meta1
|
assert meta.option('od1.i2').owner.get() is meta.config('conf1').option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.meta1
|
||||||
#
|
#
|
||||||
api.config('conf1').option('od1.i2').value.set(2)
|
meta.config('conf1').option('od1.i2').value.set(2)
|
||||||
assert api.option('od1.i2').value.get() == api.config('conf2').option('od1.i2').value.get() == 3
|
assert meta.option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 3
|
||||||
assert api.config('conf1').option('od1.i2').value.get() == 2
|
assert meta.config('conf1').option('od1.i2').value.get() == 2
|
||||||
assert api.option('od1.i2').owner.get() is api.config('conf2').option('od1.i2').owner.get() is owners.meta1
|
assert meta.option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.meta1
|
||||||
assert api.config('conf1').option('od1.i2').owner.get() is owners.user
|
assert meta.config('conf1').option('od1.i2').owner.get() is owners.user
|
||||||
#
|
#
|
||||||
api.option('od1.i2').value.set(4)
|
meta.option('od1.i2').value.set(4)
|
||||||
assert api.option('od1.i2').value.get() == api.config('conf2').option('od1.i2').value.get() == 4
|
assert meta.option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 4
|
||||||
assert api.config('conf1').option('od1.i2').value.get() == 2
|
assert meta.config('conf1').option('od1.i2').value.get() == 2
|
||||||
assert api.option('od1.i2').owner.get() is api.config('conf2').option('od1.i2').owner.get() is owners.meta1
|
assert meta.option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.meta1
|
||||||
assert api.config('conf1').option('od1.i2').owner.get() is owners.user
|
assert meta.config('conf1').option('od1.i2').owner.get() is owners.user
|
||||||
#
|
#
|
||||||
api.option('od1.i2').value.reset()
|
meta.option('od1.i2').value.reset()
|
||||||
assert api.option('od1.i2').value.get() == api.config('conf2').option('od1.i2').value.get() == 1
|
assert meta.option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 1
|
||||||
assert api.config('conf1').option('od1.i2').value.get() == 2
|
assert meta.config('conf1').option('od1.i2').value.get() == 2
|
||||||
assert api.option('od1.i2').owner.get() is api.config('conf2').option('od1.i2').owner.get() is owners.default
|
assert meta.option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.default
|
||||||
assert api.config('conf1').option('od1.i2').owner.get() is owners.user
|
assert meta.config('conf1').option('od1.i2').owner.get() is owners.user
|
||||||
#
|
#
|
||||||
api.config('conf1').option('od1.i2').value.reset()
|
meta.config('conf1').option('od1.i2').value.reset()
|
||||||
assert api.option('od1.i2').value.get() == api.config('conf1').option('od1.i2').value.get() == api.config('conf2').option('od1.i2').value.get() == 1
|
assert meta.option('od1.i2').value.get() == meta.config('conf1').option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 1
|
||||||
assert api.option('od1.i2').owner.get() is api.config('conf1').option('od1.i2').owner.get() is api.config('conf2').option('od1.i2').owner.get() is owners.default
|
assert meta.option('od1.i2').owner.get() is meta.config('conf1').option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.default
|
||||||
|
|
||||||
|
|
||||||
def test_contexts():
|
def test_contexts():
|
||||||
api = make_metaconfig()
|
meta = make_metaconfig()
|
||||||
errors = api.value.set('od1.i2', 6, only_config=True)
|
errors = meta.value.set('od1.i2', 6, only_config=True)
|
||||||
assert api.option('od1.i2').value.get() == 1
|
assert meta.option('od1.i2').value.get() == 1
|
||||||
assert api.option('od1.i2').owner.get() == owners.default
|
assert meta.option('od1.i2').owner.get() == owners.default
|
||||||
assert api.config('conf1').option('od1.i2').value.get() == api.config('conf1').option('od1.i2').value.get() == 6
|
assert meta.config('conf1').option('od1.i2').value.get() == meta.config('conf1').option('od1.i2').value.get() == 6
|
||||||
assert api.config('conf1').option('od1.i2').owner.get() == api.config('conf1').option('od1.i2').owner.get() is owners.user
|
assert meta.config('conf1').option('od1.i2').owner.get() == meta.config('conf1').option('od1.i2').owner.get() is owners.user
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
|
|
||||||
|
|
||||||
def test_find():
|
def test_find():
|
||||||
api = make_metaconfig()
|
meta = make_metaconfig()
|
||||||
ret = api.option.find('i2')
|
ret = meta.option.find('i2')
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
assert 1 == ret[0].value.get()
|
assert 1 == ret[0].value.get()
|
||||||
assert 1 == api.option.find('i2', first=True).value.get()
|
assert 1 == meta.option.find('i2', first=True).value.get()
|
||||||
assert api.option.make_dict() == {'od1.i4': 2, 'od1.i1': None, 'od1.i3': None,
|
assert meta.option.make_dict() == {'od1.i4': 2, 'od1.i1': None, 'od1.i3': None,
|
||||||
'od1.i2': 1, 'od1.i5': [2]}
|
'od1.i2': 1, 'od1.i5': [2]}
|
||||||
|
|
||||||
|
|
||||||
#def test_group_error():
|
|
||||||
# raises(ValueError, "GroupConfig('str')")
|
|
||||||
# raises(ValueError, "GroupConfig(['str'])")
|
|
||||||
|
|
||||||
|
|
||||||
def test_meta_meta():
|
def test_meta_meta():
|
||||||
api = make_metaconfig(double=True)
|
meta = make_metaconfig(double=True)
|
||||||
assert api.option('od1.i2').value.get() == api.config('meta').option('od1.i2').value.get() == api.config('meta.conf1').option('od1.i2').value.get() == api.config('meta.conf2').option('od1.i2').value.get() == 1
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf1').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 1
|
||||||
assert api.option('od1.i2').owner.get() is api.config('meta').option('od1.i2').owner.get() is api.config('meta.conf1').option('od1.i2').owner.get() is api.config('meta.conf2').option('od1.i2').owner.get() is owners.default
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf1').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.default
|
||||||
#
|
#
|
||||||
api.option('od1.i2').value.set(3)
|
meta.option('od1.i2').value.set(3)
|
||||||
assert api.option('od1.i2').value.get() == api.config('meta').option('od1.i2').value.get() == api.config('meta.conf1').option('od1.i2').value.get() == api.config('meta.conf2').option('od1.i2').value.get() == 3
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf1').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 3
|
||||||
assert api.option('od1.i2').owner.get() is api.config('meta').option('od1.i2').owner.get() is api.config('meta.conf1').option('od1.i2').owner.get() is api.config('meta.conf2').option('od1.i2').owner.get() is owners.meta1
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf1').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.meta1
|
||||||
#
|
#
|
||||||
api.config('meta.conf1').option('od1.i2').value.set(2)
|
meta.config('meta.conf1').option('od1.i2').value.set(2)
|
||||||
assert api.option('od1.i2').value.get() == api.config('meta').option('od1.i2').value.get() == api.config('meta.conf2').option('od1.i2').value.get() == 3
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 3
|
||||||
assert api.config('meta.conf1').option('od1.i2').value.get() == 2
|
assert meta.config('meta.conf1').option('od1.i2').value.get() == 2
|
||||||
assert api.option('od1.i2').owner.get() is api.config('meta').option('od1.i2').owner.get() is api.config('meta.conf2').option('od1.i2').owner.get() is owners.meta1
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.meta1
|
||||||
assert api.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
assert meta.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
||||||
#
|
#
|
||||||
api.config('meta').option('od1.i2').value.set(4)
|
meta.config('meta').option('od1.i2').value.set(4)
|
||||||
assert api.option('od1.i2').value.get() == 3
|
assert meta.option('od1.i2').value.get() == 3
|
||||||
assert api.config('meta').option('od1.i2').value.get() == api.config('meta.conf2').option('od1.i2').value.get() == 4
|
assert meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 4
|
||||||
assert api.config('meta.conf1').option('od1.i2').value.get() == 2
|
assert meta.config('meta.conf1').option('od1.i2').value.get() == 2
|
||||||
assert api.option('od1.i2').owner.get() is owners.meta1
|
assert meta.option('od1.i2').owner.get() is owners.meta1
|
||||||
assert api.config('meta').option('od1.i2').owner.get() is api.config('meta.conf2').option('od1.i2').owner.get() is owners.meta2
|
assert meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.meta2
|
||||||
assert api.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
assert meta.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
||||||
#
|
#
|
||||||
api.config('meta').option('od1.i2').value.reset()
|
meta.config('meta').option('od1.i2').value.reset()
|
||||||
assert api.option('od1.i2').value.get() == api.config('meta').option('od1.i2').value.get() == api.config('meta.conf2').option('od1.i2').value.get() == 3
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 3
|
||||||
assert api.config('meta.conf1').option('od1.i2').value.get() == 2
|
assert meta.config('meta.conf1').option('od1.i2').value.get() == 2
|
||||||
assert api.option('od1.i2').owner.get() is api.config('meta').option('od1.i2').owner.get() is api.config('meta.conf2').option('od1.i2').owner.get() is owners.meta1
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.meta1
|
||||||
assert api.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
assert meta.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
||||||
#
|
#
|
||||||
api.option('od1.i2').value.reset()
|
meta.option('od1.i2').value.reset()
|
||||||
assert api.option('od1.i2').value.get() == api.config('meta').option('od1.i2').value.get() == api.config('meta.conf2').option('od1.i2').value.get() == 1
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 1
|
||||||
assert api.config('meta.conf1').option('od1.i2').value.get() == 2
|
assert meta.config('meta.conf1').option('od1.i2').value.get() == 2
|
||||||
assert api.option('od1.i2').owner.get() is api.config('meta').option('od1.i2').owner.get() is api.config('meta.conf2').option('od1.i2').owner.get() is owners.default
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.default
|
||||||
assert api.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
assert meta.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
||||||
#
|
#
|
||||||
api.config('meta.conf1').option('od1.i2').value.reset()
|
meta.config('meta.conf1').option('od1.i2').value.reset()
|
||||||
assert api.option('od1.i2').value.get() == api.config('meta').option('od1.i2').value.get() == api.config('meta.conf1').option('od1.i2').value.get() == api.config('meta.conf2').option('od1.i2').value.get() == 1
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf1').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 1
|
||||||
assert api.option('od1.i2').owner.get() is api.config('meta').option('od1.i2').owner.get() is api.config('meta.conf1').option('od1.i2').owner.get() is api.config('meta.conf2').option('od1.i2').owner.get() is owners.default
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf1').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.default
|
||||||
|
|
||||||
|
|
||||||
def test_meta_new_config():
|
def test_meta_new_config():
|
||||||
|
@ -201,27 +194,27 @@ def test_meta_new_config_wrong_name():
|
||||||
|
|
||||||
|
|
||||||
def test_meta_meta_set():
|
def test_meta_meta_set():
|
||||||
api = make_metaconfig(double=True)
|
meta = make_metaconfig(double=True)
|
||||||
errors1 = api.value.set('od1.i1', 7, only_config=True)
|
errors1 = meta.value.set('od1.i1', 7, only_config=True)
|
||||||
errors2 = api.value.set('od1.i6', 7, only_config=True)
|
errors2 = meta.value.set('od1.i6', 7, only_config=True)
|
||||||
assert len(errors1) == 0
|
assert len(errors1) == 0
|
||||||
assert len(errors2) == 2
|
assert len(errors2) == 2
|
||||||
meta = api._config.getconfig('meta')
|
meta = meta._config.getconfig('meta')
|
||||||
conf1 = meta.getconfig('conf1')
|
conf1 = meta.getconfig('conf1')
|
||||||
conf2 = meta.getconfig('conf2')
|
conf2 = meta.getconfig('conf2')
|
||||||
assert api.config('meta.conf1').option('od1.i1').value.get() == api.config('meta.conf2').option('od1.i1').value.get() == 7
|
assert meta.config('meta.conf1').option('od1.i1').value.get() == meta.config('meta.conf2').option('od1.i1').value.get() == 7
|
||||||
assert [conf1, conf2] == api.config.find('i1', value=7, first=True).cfgimpl_get_children()
|
assert [conf1, conf2] == meta.config.find('i1', value=7, first=True).cfgimpl_get_children()
|
||||||
api.config('meta.conf1').option('od1.i1').value.set(8)
|
meta.config('meta.conf1').option('od1.i1').value.set(8)
|
||||||
assert [conf1, conf2] == api.config.find('i1', first=True).cfgimpl_get_children()
|
assert [conf1, conf2] == meta.config.find('i1', first=True).cfgimpl_get_children()
|
||||||
assert [conf2] == api.config.find('i1', value=7, first=True).cfgimpl_get_children()
|
assert [conf2] == meta.config.find('i1', value=7, first=True).cfgimpl_get_children()
|
||||||
assert [conf1] == api.config.find('i1', value=8, first=True).cfgimpl_get_children()
|
assert [conf1] == meta.config.find('i1', value=8, first=True).cfgimpl_get_children()
|
||||||
assert [conf1, conf2] == api.config.find('i5', value=2, first=True).cfgimpl_get_children()
|
assert [conf1, conf2] == meta.config.find('i5', value=2, first=True).cfgimpl_get_children()
|
||||||
raises(AttributeError, "api.config.find('i1', value=10, first=True)")
|
raises(AttributeError, "meta.config.find('i1', value=10, first=True)")
|
||||||
raises(AttributeError, "api.config.find('not', value=10, first=True)")
|
raises(AttributeError, "meta.config.find('not', value=10, first=True)")
|
||||||
raises(AttributeError, "api.config.find('i6', first=True)")
|
raises(AttributeError, "meta.config.find('i6', first=True)")
|
||||||
raises(ValueError, "api.value.set('od1.i6', 7, only_config=True, force_default=True)")
|
raises(ValueError, "meta.value.set('od1.i6', 7, only_config=True, force_default=True)")
|
||||||
raises(ValueError, "api.value.set('od1.i6', 7, only_config=True, force_default_if_same=True)")
|
raises(ValueError, "meta.value.set('od1.i6', 7, only_config=True, force_default_if_same=True)")
|
||||||
raises(ValueError, "api.value.set('od1.i6', 7, only_config=True, force_dont_change_value=True)")
|
raises(ValueError, "meta.value.set('od1.i6', 7, only_config=True, force_dont_change_value=True)")
|
||||||
|
|
||||||
|
|
||||||
def test_not_meta():
|
def test_not_meta():
|
||||||
|
@ -237,13 +230,12 @@ def test_not_meta():
|
||||||
raises(ConflictError, "GroupConfig([conf2, conf4], session_id='conf2')")
|
raises(ConflictError, "GroupConfig([conf2, conf4], session_id='conf2')")
|
||||||
raises(ConflictError, "GroupConfig([conf2, conf2], session_id='conf8')")
|
raises(ConflictError, "GroupConfig([conf2, conf2], session_id='conf8')")
|
||||||
grp = GroupConfig([conf1, conf2])
|
grp = GroupConfig([conf1, conf2])
|
||||||
api = getapi(grp)
|
raises(ConfigError, "grp.option('od1.i1').value.get()")
|
||||||
raises(ConfigError, "api.option('od1.i1').value.get()")
|
|
||||||
conf1, conf2 = grp.config.list()
|
conf1, conf2 = grp.config.list()
|
||||||
errors = api.value.set('od1.i1', 7)
|
errors = grp.value.set('od1.i1', 7)
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
assert api.config('conf1').option('od1.i1').value.get() == api.config('conf2').option('od1.i1').value.get() == 7
|
assert grp.config('conf1').option('od1.i1').value.get() == grp.config('conf2').option('od1.i1').value.get() == 7
|
||||||
assert api.config('conf1').option('od1.i1').owner.get() is api.config('conf2').option('od1.i1').owner.get() is owners.user
|
assert grp.config('conf1').option('od1.i1').owner.get() is grp.config('conf2').option('od1.i1').owner.get() is owners.user
|
||||||
|
|
||||||
|
|
||||||
def test_group_find_firsts():
|
def test_group_find_firsts():
|
||||||
|
@ -253,8 +245,7 @@ def test_group_find_firsts():
|
||||||
conf1 = Config(od2, session_id='conf1')
|
conf1 = Config(od2, session_id='conf1')
|
||||||
conf2 = Config(od2, session_id='conf2')
|
conf2 = Config(od2, session_id='conf2')
|
||||||
grp = GroupConfig([conf1, conf2])
|
grp = GroupConfig([conf1, conf2])
|
||||||
api = getapi(grp)
|
assert [conf1._config, conf2._config] == grp.config.find('i1', first=True).cfgimpl_get_children()
|
||||||
assert [conf1._config, conf2._config] == api.config.find('i1', first=True).cfgimpl_get_children()
|
|
||||||
|
|
||||||
|
|
||||||
def test_group_group():
|
def test_group_group():
|
||||||
|
@ -265,11 +256,10 @@ def test_group_group():
|
||||||
conf2 = Config(od2, session_id='conf10')
|
conf2 = Config(od2, session_id='conf10')
|
||||||
grp = GroupConfig([conf1, conf2], 'grp')
|
grp = GroupConfig([conf1, conf2], 'grp')
|
||||||
grp2 = GroupConfig([grp])
|
grp2 = GroupConfig([grp])
|
||||||
api = getapi(grp2)
|
errors = grp2.value.set('od1.i1', 2)
|
||||||
errors = api.value.set('od1.i1', 2)
|
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
assert api.config('grp.conf9').option('od1.i1').value.get() == 2
|
assert grp2.config('grp.conf9').option('od1.i1').value.get() == 2
|
||||||
assert api.config('grp.conf9').option('od1.i1').owner.get() is owners.user
|
assert grp2.config('grp.conf9').option('od1.i1').owner.get() is owners.user
|
||||||
|
|
||||||
|
|
||||||
def test_meta_unconsistent():
|
def test_meta_unconsistent():
|
||||||
|
@ -284,14 +274,14 @@ def test_meta_unconsistent():
|
||||||
conf2 = Config(od2, session_id='conf2')
|
conf2 = Config(od2, session_id='conf2')
|
||||||
conf3 = Config(od2, session_id='conf3')
|
conf3 = Config(od2, session_id='conf3')
|
||||||
conf4 = Config(od3, session_id='conf4')
|
conf4 = Config(od3, session_id='conf4')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.owner.set(owners.meta1)
|
meta.owner.set(owners.meta1)
|
||||||
raises(TypeError, 'MetaConfig("string")')
|
raises(TypeError, 'MetaConfig("string")')
|
||||||
#same descr but conf1 already in meta
|
#same descr but conf1 already in meta
|
||||||
raises(ValueError, "MetaConfig([conf1, conf3])")
|
raises(ValueError, "MetaConfig([conf1, conf3])")
|
||||||
#not same descr
|
#not same descr
|
||||||
raises(ValueError, "MetaConfig([conf3, conf4])")
|
raises(ValueError, "MetaConfig([conf3, conf4])")
|
||||||
raises(ConfigError, "api.config('conf1').property.read_only()")
|
raises(ConfigError, "meta.config('conf1').property.read_only()")
|
||||||
|
|
||||||
|
|
||||||
def test_meta_master_slaves():
|
def test_meta_master_slaves():
|
||||||
|
@ -301,15 +291,15 @@ def test_meta_master_slaves():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
conf1 = Config(od, session_id='conf1')
|
conf1 = Config(od, session_id='conf1')
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.property.read_only()
|
meta.property.read_only()
|
||||||
assert [conf1._config, conf2._config] == api.config.find('ip_admin_eth0', first=True).cfgimpl_get_children()
|
assert [conf1._config, conf2._config] == meta.config.find('ip_admin_eth0', first=True).cfgimpl_get_children()
|
||||||
assert [conf1._config, conf2._config] == api.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
assert [conf1._config, conf2._config] == meta.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
raises(AttributeError, "api.config.find('netmask_admin_eth0', first=True)")
|
raises(AttributeError, "meta.config.find('netmask_admin_eth0', first=True)")
|
||||||
assert [conf1._config, conf2._config] == api.unrestraint.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
assert [conf1._config, conf2._config] == meta.unrestraint.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
||||||
api.property.read_only()
|
meta.property.read_only()
|
||||||
assert [conf1._config, conf2._config] == api.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
assert [conf1._config, conf2._config] == meta.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
||||||
|
|
||||||
|
|
||||||
def test_meta_master_slaves_value2():
|
def test_meta_master_slaves_value2():
|
||||||
|
@ -320,22 +310,21 @@ def test_meta_master_slaves_value2():
|
||||||
conf1 = Config(od, session_id='conf1')
|
conf1 = Config(od, session_id='conf1')
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
meta = MetaConfig([conf1, conf2], session_id="meta")
|
meta = MetaConfig([conf1, conf2], session_id="meta")
|
||||||
api = getapi(meta)
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.8'])
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.8'])
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
#FIXME devrait raise ! assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0', 0).value.get() == None
|
||||||
#FIXME devrait raise ! assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0', 0).value.get() == None
|
|
||||||
#
|
#
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
||||||
#
|
#
|
||||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
meta.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.255.0'
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.255.0'
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
|
||||||
#
|
#
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
|
|
||||||
|
|
||||||
def test_meta_master_slaves_value_default():
|
def test_meta_master_slaves_value_default():
|
||||||
|
@ -345,20 +334,20 @@ def test_meta_master_slaves_value_default():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
conf1 = Config(od, session_id='conf1')
|
conf1 = Config(od, session_id='conf1')
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
#
|
#
|
||||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
meta.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
#
|
#
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.255.0'
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.255.0'
|
||||||
#
|
#
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
|
||||||
#
|
#
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
|
|
||||||
|
|
||||||
def test_meta_master_slaves_owners():
|
def test_meta_master_slaves_owners():
|
||||||
|
@ -368,33 +357,33 @@ def test_meta_master_slaves_owners():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
conf1 = Config(od, session_id='conf1')
|
conf1 = Config(od, session_id='conf1')
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.owner.set(owners.meta1)
|
meta.owner.set(owners.meta1)
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||||
raises(SlaveError, "api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()")
|
raises(SlaveError, "meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()")
|
||||||
#
|
#
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.user
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.user
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()
|
||||||
#
|
#
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||||
#
|
#
|
||||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
meta.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.meta1
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.meta1
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()
|
||||||
#
|
#
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.meta1
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.meta1
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.meta1
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.meta1
|
||||||
#
|
#
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.meta1
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.meta1
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.meta1
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.meta1
|
||||||
#
|
#
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.user
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.user
|
||||||
assert api.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.default
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.default
|
||||||
|
|
||||||
|
|
||||||
def test_meta_force_default():
|
def test_meta_force_default():
|
||||||
|
@ -404,35 +393,35 @@ def test_meta_force_default():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
conf1 = Config(od, session_id='conf1')
|
conf1 = Config(od, session_id='conf1')
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
api.owner.set('meta1')
|
meta.owner.set('meta1')
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
#
|
#
|
||||||
errors = api.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.1'])
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.1'])
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
#
|
#
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
#
|
#
|
||||||
errors = api.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.3'])
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.3'])
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
#
|
#
|
||||||
errors = api.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default=True)
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default=True)
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
|
||||||
|
|
||||||
def test_meta_force_dont_change_value():
|
def test_meta_force_dont_change_value():
|
||||||
|
@ -442,24 +431,24 @@ def test_meta_force_dont_change_value():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
conf1 = Config(od, session_id='conf1')
|
conf1 = Config(od, session_id='conf1')
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
api.owner.set('meta1')
|
meta.owner.set('meta1')
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||||
errors = api.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_dont_change_value=True)
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_dont_change_value=True)
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
|
||||||
|
|
||||||
def test_meta_force_default_if_same():
|
def test_meta_force_default_if_same():
|
||||||
|
@ -469,39 +458,39 @@ def test_meta_force_default_if_same():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
conf1 = Config(od, session_id='conf1')
|
conf1 = Config(od, session_id='conf1')
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
api.owner.set('meta1')
|
meta.owner.set('meta1')
|
||||||
#
|
#
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
#
|
#
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||||
errors = api.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True)
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True)
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
||||||
#
|
#
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.3'])
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.3'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
||||||
errors = api.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True)
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True)
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
||||||
|
|
||||||
|
|
||||||
def test_meta_force_default_if_same_and_dont_change():
|
def test_meta_force_default_if_same_and_dont_change():
|
||||||
|
@ -511,39 +500,39 @@ def test_meta_force_default_if_same_and_dont_change():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
conf1 = Config(od, session_id='conf1')
|
conf1 = Config(od, session_id='conf1')
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
api.owner.set('meta1')
|
meta.owner.set('meta1')
|
||||||
#
|
#
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
#
|
#
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||||
errors = api.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True, force_dont_change_value=True)
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True, force_dont_change_value=True)
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
#
|
#
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.3'])
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.3'])
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
errors = api.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True, force_dont_change_value=True)
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True, force_dont_change_value=True)
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
|
||||||
|
|
||||||
def test_meta_force_default_and_dont_change():
|
def test_meta_force_default_and_dont_change():
|
||||||
|
@ -553,10 +542,10 @@ def test_meta_force_default_and_dont_change():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
conf1 = Config(od, session_id='rconf1')
|
conf1 = Config(od, session_id='rconf1')
|
||||||
conf2 = Config(od, session_id='rconf2')
|
conf2 = Config(od, session_id='rconf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
api.owner.set('meta1')
|
meta.owner.set('meta1')
|
||||||
raises(ValueError, "api.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default=True, force_dont_change_value=True)")
|
raises(ValueError, "meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default=True, force_dont_change_value=True)")
|
||||||
|
|
||||||
|
|
||||||
def test_meta_properties_meta():
|
def test_meta_properties_meta():
|
||||||
|
@ -567,9 +556,9 @@ def test_meta_properties_meta():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
conf1 = Config(od, session_id='conf1')
|
conf1 = Config(od, session_id='conf1')
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
assert api.config('conf1').option.make_dict() == {}
|
assert meta.config('conf1').option.make_dict() == {}
|
||||||
|
|
||||||
|
|
||||||
def test_meta_exception_meta():
|
def test_meta_exception_meta():
|
||||||
|
@ -580,8 +569,8 @@ def test_meta_exception_meta():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
conf1 = Config(od, session_id='conf1')
|
conf1 = Config(od, session_id='conf1')
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
raises(Exception, "conf1.make_dict()")
|
raises(Exception, "conf1.make_dict()")
|
||||||
|
|
||||||
|
|
||||||
|
@ -593,20 +582,20 @@ def test_meta_callback():
|
||||||
val5 = StrOption('val5', "", callback=return_value, callback_params=Params(kwargs={'value': ParamValue('yes')}))
|
val5 = StrOption('val5', "", callback=return_value, callback_params=Params(kwargs={'value': ParamValue('yes')}))
|
||||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
||||||
cfg = Config(maconfig, session_id='cfg')
|
cfg = Config(maconfig, session_id='cfg')
|
||||||
api = getapi(MetaConfig([cfg]))
|
meta = MetaConfig([cfg])
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'val', 'val1': 'val', 'val5': 'yes', 'val4': 'val'}
|
assert meta.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'val', 'val1': 'val', 'val5': 'yes', 'val4': 'val'}
|
||||||
api.config('cfg').option('val1').value.set('new')
|
meta.config('cfg').option('val1').value.set('new')
|
||||||
#assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
#assert meta.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||||
#api.config('cfg').option('val1').value.reset()
|
#meta.config('cfg').option('val1').value.reset()
|
||||||
#api.option('val1').value.set('new')
|
#meta.option('val1').value.set('new')
|
||||||
#assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
#assert meta.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||||
#api.config('cfg').option('val4').value.set('new1')
|
#meta.config('cfg').option('val4').value.set('new1')
|
||||||
#assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
#assert meta.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||||
#api.config('cfg').option('val4').value.reset()
|
#meta.config('cfg').option('val4').value.reset()
|
||||||
#api.option('val4').value.set('new1')
|
#meta.option('val4').value.set('new1')
|
||||||
#assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
#assert meta.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||||
#api.option('val4').value.reset()
|
#meta.option('val4').value.reset()
|
||||||
|
|
||||||
|
|
||||||
def test_meta_callback_slave():
|
def test_meta_callback_slave():
|
||||||
|
@ -618,38 +607,38 @@ def test_meta_callback_slave():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||||
cfg = Config(maconfig, session_id='cfg1')
|
cfg = Config(maconfig, session_id='cfg1')
|
||||||
api = getapi(MetaConfig([cfg]))
|
meta = MetaConfig([cfg])
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||||
api.config('cfg1').option('val').value.set('val1')
|
meta.config('cfg1').option('val').value.set('val1')
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||||
api.config('cfg1').option('val').value.reset()
|
meta.config('cfg1').option('val').value.reset()
|
||||||
api.option('val').value.set('val1')
|
meta.option('val').value.set('val1')
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||||
api.option('val').value.reset()
|
meta.option('val').value.reset()
|
||||||
api.config('cfg1').option('val1.val2', 0).value.set('val2')
|
meta.config('cfg1').option('val1.val2', 0).value.set('val2')
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||||
api.config('cfg1').option('val1.val2', 0).value.reset()
|
meta.config('cfg1').option('val1.val2', 0).value.reset()
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||||
api.option('val1.val2', 0).value.set('val2')
|
meta.option('val1.val2', 0).value.set('val2')
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||||
api.config('cfg1').option('val1.val3', 0).value.set('val6')
|
meta.config('cfg1').option('val1.val3', 0).value.set('val6')
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val6'], 'val': 'val'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val6'], 'val': 'val'}
|
||||||
api.option('val1.val2', 0).value.reset()
|
meta.option('val1.val2', 0).value.reset()
|
||||||
api.config('cfg1').option('val1.val3', 0).value.reset()
|
meta.config('cfg1').option('val1.val3', 0).value.reset()
|
||||||
api.config('cfg1').option('val1.val1').value.set(['val3'])
|
meta.config('cfg1').option('val1.val1').value.set(['val3'])
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||||
api.config('cfg1').option('val1.val1').value.reset()
|
meta.config('cfg1').option('val1.val1').value.reset()
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||||
api.option('val1.val1').value.set(['val3'])
|
meta.option('val1.val1').value.set(['val3'])
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||||
api.config('cfg1').option('val1.val2', 0).value.set('val2')
|
meta.config('cfg1').option('val1.val2', 0).value.set('val2')
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||||
api.option('val1.val1').value.set(['val3', 'rah'])
|
meta.option('val1.val1').value.set(['val3', 'rah'])
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
||||||
api.option('val1.val1').value.pop(1)
|
meta.option('val1.val1').value.pop(1)
|
||||||
api.option('val1.val1').value.set(['val4'])
|
meta.option('val1.val1').value.set(['val4'])
|
||||||
assert api.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val4'], 'val1.val3': ['val4'], 'val': 'val'}
|
assert meta.config('cfg1').option.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val4'], 'val1.val3': ['val4'], 'val': 'val'}
|
||||||
|
|
||||||
|
|
||||||
def test_meta_reset():
|
def test_meta_reset():
|
||||||
|
@ -659,25 +648,25 @@ def test_meta_reset():
|
||||||
od = OptionDescription('root', '', [interface1])
|
od = OptionDescription('root', '', [interface1])
|
||||||
conf1 = Config(od, session_id='conf1')
|
conf1 = Config(od, session_id='conf1')
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
api.owner.set('meta1')
|
meta.owner.set('meta1')
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
errors = api.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.1'])
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.1'])
|
||||||
assert len(errors) == 0
|
assert len(errors) == 0
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
api.value.reset('ip_admin_eth0.ip_admin_eth0')
|
meta.value.reset('ip_admin_eth0.ip_admin_eth0')
|
||||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert api.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
|
||||||
|
|
||||||
def test_meta_properties_meta_set_value():
|
def test_meta_properties_meta_set_value():
|
||||||
|
@ -686,42 +675,42 @@ def test_meta_properties_meta_set_value():
|
||||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
conf1 = Config(interface1, session_id='conf1')
|
conf1 = Config(interface1, session_id='conf1')
|
||||||
conf2 = Config(interface1, session_id='conf2')
|
conf2 = Config(interface1, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
meta = MetaConfig([conf1, conf2])
|
||||||
api.property.read_write()
|
meta.property.read_write()
|
||||||
assert api.config('conf1').option.make_dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
assert meta.config('conf1').option.make_dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
ret = api.value.set('netmask_admin_eth0', ['255.255.255.255'], only_config=True)
|
ret = meta.value.set('netmask_admin_eth0', ['255.255.255.255'], only_config=True)
|
||||||
assert len(ret) == 2
|
assert len(ret) == 2
|
||||||
assert isinstance(ret[0], PropertiesOptionError)
|
assert isinstance(ret[0], PropertiesOptionError)
|
||||||
assert isinstance(ret[1], PropertiesOptionError)
|
assert isinstance(ret[1], PropertiesOptionError)
|
||||||
del(ret)
|
del(ret)
|
||||||
ret = api.value.set('netmask_admin_eth0', ['255.255.255.255'], force_default=True)
|
ret = meta.value.set('netmask_admin_eth0', ['255.255.255.255'], force_default=True)
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
assert isinstance(ret[0], PropertiesOptionError)
|
assert isinstance(ret[0], PropertiesOptionError)
|
||||||
del(ret)
|
del(ret)
|
||||||
ret = api.value.set('netmask_admin_eth0', ['255.255.255.255'], force_dont_change_value=True)
|
ret = meta.value.set('netmask_admin_eth0', ['255.255.255.255'], force_dont_change_value=True)
|
||||||
assert len(ret) == 3
|
assert len(ret) == 3
|
||||||
assert isinstance(ret[0], PropertiesOptionError)
|
assert isinstance(ret[0], PropertiesOptionError)
|
||||||
assert isinstance(ret[1], PropertiesOptionError)
|
assert isinstance(ret[1], PropertiesOptionError)
|
||||||
assert isinstance(ret[2], PropertiesOptionError)
|
assert isinstance(ret[2], PropertiesOptionError)
|
||||||
del(ret)
|
del(ret)
|
||||||
ret = api.value.set('netmask_admin_eth0', ['255.255.255.255'], force_default_if_same=True)
|
ret = meta.value.set('netmask_admin_eth0', ['255.255.255.255'], force_default_if_same=True)
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
assert isinstance(ret[0], PropertiesOptionError)
|
assert isinstance(ret[0], PropertiesOptionError)
|
||||||
del(ret)
|
del(ret)
|
||||||
ret = api.value.set('ip_admin_eth0', '255.255.255.255', only_config=True)
|
ret = meta.value.set('ip_admin_eth0', '255.255.255.255', only_config=True)
|
||||||
assert len(ret) == 2
|
assert len(ret) == 2
|
||||||
assert isinstance(ret[0], ValueError)
|
assert isinstance(ret[0], ValueError)
|
||||||
assert isinstance(ret[1], ValueError)
|
assert isinstance(ret[1], ValueError)
|
||||||
del(ret)
|
del(ret)
|
||||||
ret = api.value.set('ip_admin_eth0', '255.255.255.255', force_default=True)
|
ret = meta.value.set('ip_admin_eth0', '255.255.255.255', force_default=True)
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
assert isinstance(ret[0], ValueError)
|
assert isinstance(ret[0], ValueError)
|
||||||
del(ret)
|
del(ret)
|
||||||
ret = api.value.set('ip_admin_eth0', '255.255.255.255', force_dont_change_value=True)
|
ret = meta.value.set('ip_admin_eth0', '255.255.255.255', force_dont_change_value=True)
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
assert isinstance(ret[0], ValueError)
|
assert isinstance(ret[0], ValueError)
|
||||||
del(ret)
|
del(ret)
|
||||||
ret = api.value.set('ip_admin_eth0', '255.255.255.255', force_default_if_same=True)
|
ret = meta.value.set('ip_admin_eth0', '255.255.255.255', force_default_if_same=True)
|
||||||
assert len(ret) == 1
|
assert len(ret) == 1
|
||||||
assert isinstance(ret[0], ValueError)
|
assert isinstance(ret[0], ValueError)
|
||||||
del(ret)
|
del(ret)
|
||||||
|
|
|
@ -53,7 +53,10 @@ class TiramisuHelp:
|
||||||
modules.sort()
|
modules.sort()
|
||||||
for module_name in modules:
|
for module_name in modules:
|
||||||
module = self.registers[module_name]
|
module = self.registers[module_name]
|
||||||
instance_module = module(None)
|
try:
|
||||||
|
instance_module = module(None)
|
||||||
|
except TypeError:
|
||||||
|
instance_module = module(None, None, None)
|
||||||
if isinstance(instance_module, TiramisuDispatcher):
|
if isinstance(instance_module, TiramisuDispatcher):
|
||||||
if _valid and not getdoc(module.__call__): # pragma: no cover
|
if _valid and not getdoc(module.__call__): # pragma: no cover
|
||||||
raise Exception('unknown doc for {}'.format('__call__'))
|
raise Exception('unknown doc for {}'.format('__call__'))
|
||||||
|
@ -143,9 +146,11 @@ class CommonTiramisuOption(CommonTiramisu):
|
||||||
self.option_bag = option_bag
|
self.option_bag = option_bag
|
||||||
self._name = name
|
self._name = name
|
||||||
self.subconfig = subconfig
|
self.subconfig = subconfig
|
||||||
self._get_option()
|
if option_bag is not None:
|
||||||
if option_bag.config_bag is not None and self.slave_need_index:
|
# for help()
|
||||||
self._test_slave_index()
|
self._get_option()
|
||||||
|
if option_bag.config_bag is not None and self.slave_need_index:
|
||||||
|
self._test_slave_index()
|
||||||
|
|
||||||
def _test_slave_index(self) -> None:
|
def _test_slave_index(self) -> None:
|
||||||
option = self.option_bag.option
|
option = self.option_bag.option
|
||||||
|
@ -262,7 +267,9 @@ class TiramisuOptionOwner(CommonTiramisuOption):
|
||||||
super().__init__(name,
|
super().__init__(name,
|
||||||
subconfig,
|
subconfig,
|
||||||
option_bag)
|
option_bag)
|
||||||
self.values = self.option_bag.config_bag.context.cfgimpl_get_values()
|
if option_bag is not None:
|
||||||
|
# for help()
|
||||||
|
self.values = self.option_bag.config_bag.context.cfgimpl_get_values()
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
"""get owner for a specified option"""
|
"""get owner for a specified option"""
|
||||||
|
@ -298,7 +305,7 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
||||||
super().__init__(name,
|
super().__init__(name,
|
||||||
subconfig,
|
subconfig,
|
||||||
option_bag)
|
option_bag)
|
||||||
if option_bag.config_bag:
|
if option_bag and option_bag.config_bag:
|
||||||
self.settings = option_bag.config_bag.context.cfgimpl_get_settings()
|
self.settings = option_bag.config_bag.context.cfgimpl_get_settings()
|
||||||
|
|
||||||
def get(self, apply_requires=True):
|
def get(self, apply_requires=True):
|
||||||
|
@ -350,7 +357,7 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
||||||
super().__init__(name,
|
super().__init__(name,
|
||||||
subconfig,
|
subconfig,
|
||||||
option_bag)
|
option_bag)
|
||||||
if option_bag.config_bag:
|
if option_bag and option_bag.config_bag:
|
||||||
self.settings = option_bag.config_bag.context.cfgimpl_get_settings()
|
self.settings = option_bag.config_bag.context.cfgimpl_get_settings()
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
|
|
Loading…
Reference in New Issue