config => KernelConfig + Config in api
This commit is contained in:
parent
071e9c20d4
commit
3210a54ab8
21 changed files with 356 additions and 265 deletions
|
@ -1304,7 +1304,7 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
||||||
for func in autocheck_registers:
|
for func in autocheck_registers:
|
||||||
cfg_name = 'conftest' + str(idx)
|
cfg_name = 'conftest' + str(idx)
|
||||||
idx += 1
|
idx += 1
|
||||||
ncfg = cfg.duplicate(session_id=cfg_name)
|
ncfg = cfg.config.duplicate(session_id=cfg_name)
|
||||||
if meta:
|
if meta:
|
||||||
confwrite = None
|
confwrite = None
|
||||||
confread = cfg_name
|
confread = cfg_name
|
||||||
|
|
|
@ -6,7 +6,7 @@ from tiramisu import setting, value
|
||||||
setting.expires_time = 1
|
setting.expires_time = 1
|
||||||
value.expires_time = 1
|
value.expires_time = 1
|
||||||
from tiramisu.option import BoolOption, IPOption, IntOption, StrOption, OptionDescription, MasterSlaves
|
from tiramisu.option import BoolOption, IPOption, IntOption, StrOption, OptionDescription, MasterSlaves
|
||||||
from tiramisu.config 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 getapi, undefined, Params, ParamValue, ParamOption
|
||||||
|
@ -48,8 +48,8 @@ def test_cache():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
c = Config(od1)
|
c = Config(od1)
|
||||||
api = getapi(c)
|
api = getapi(c)
|
||||||
values = c.cfgimpl_get_values()
|
values = c._config.cfgimpl_get_values()
|
||||||
settings = c.cfgimpl_get_settings()
|
settings = c._config.cfgimpl_get_settings()
|
||||||
api.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()
|
||||||
|
@ -101,8 +101,8 @@ def test_cache_importation_permissive():
|
||||||
# od1 = make_description()
|
# od1 = make_description()
|
||||||
# c = Config(od1)
|
# c = Config(od1)
|
||||||
# api = getapi(c)
|
# api = getapi(c)
|
||||||
# values = c.cfgimpl_get_values()
|
# values = c._config.cfgimpl_get_values()
|
||||||
# settings = c.cfgimpl_get_settings()
|
# settings = c._config.cfgimpl_get_settings()
|
||||||
# ntime = time() + 1
|
# ntime = time() + 1
|
||||||
# settings._p_.setcache('u1', set(['inject']), ntime, None)
|
# settings._p_.setcache('u1', set(['inject']), ntime, None)
|
||||||
# assert 'inject' in settings[od1.u1]
|
# assert 'inject' in settings[od1.u1]
|
||||||
|
@ -115,8 +115,8 @@ def test_cache_importation_permissive():
|
||||||
# od1 = make_description()
|
# od1 = make_description()
|
||||||
# c = Config(od1)
|
# c = Config(od1)
|
||||||
# api = getapi(c)
|
# api = getapi(c)
|
||||||
# values = c.cfgimpl_get_values()
|
# values = c._config.cfgimpl_get_values()
|
||||||
# settings = c.cfgimpl_get_settings()
|
# settings = c._config.cfgimpl_get_settings()
|
||||||
# settings._p_.setcache('u1', set(['inject2']), None, None)
|
# settings._p_.setcache('u1', set(['inject2']), None, None)
|
||||||
# assert 'inject2' in settings[od1.u1]
|
# assert 'inject2' in settings[od1.u1]
|
||||||
# values._p_.setcache('u1', 200, None, None)
|
# values._p_.setcache('u1', 200, None, None)
|
||||||
|
@ -127,8 +127,8 @@ def test_cache_reset():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
c = Config(od1)
|
c = Config(od1)
|
||||||
api = getapi(c)
|
api = getapi(c)
|
||||||
values = c.cfgimpl_get_values()
|
values = c._config.cfgimpl_get_values()
|
||||||
settings = c.cfgimpl_get_settings()
|
settings = c._config.cfgimpl_get_settings()
|
||||||
#when change a value
|
#when change a value
|
||||||
api.option('u1').value.get()
|
api.option('u1').value.get()
|
||||||
api.option('u2').value.get()
|
api.option('u2').value.get()
|
||||||
|
@ -188,8 +188,8 @@ def test_cache_reset_multi():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
c = Config(od1)
|
c = Config(od1)
|
||||||
api = getapi(c)
|
api = getapi(c)
|
||||||
values = c.cfgimpl_get_values()
|
values = c._config.cfgimpl_get_values()
|
||||||
settings = c.cfgimpl_get_settings()
|
settings = c._config.cfgimpl_get_settings()
|
||||||
api.option('u1').value.get()
|
api.option('u1').value.get()
|
||||||
api.option('u3').value.get()
|
api.option('u3').value.get()
|
||||||
assert 'u1' in values._p_.get_cached()
|
assert 'u1' in values._p_.get_cached()
|
||||||
|
@ -241,12 +241,12 @@ def test_reset_cache():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
c = Config(od1)
|
c = Config(od1)
|
||||||
api = getapi(c)
|
api = getapi(c)
|
||||||
values = c.cfgimpl_get_values()
|
values = c._config.cfgimpl_get_values()
|
||||||
settings = c.cfgimpl_get_settings()
|
settings = c._config.cfgimpl_get_settings()
|
||||||
api.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.cfgimpl_reset_cache(None, None)
|
c._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()
|
api.option('u1').value.get()
|
||||||
|
@ -258,7 +258,7 @@ def test_reset_cache():
|
||||||
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.cfgimpl_reset_cache(None, None)
|
c._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()
|
||||||
|
@ -270,7 +270,7 @@ def test_reset_cache():
|
||||||
# od2 = OptionDescription('od2', '', [od1])
|
# od2 = OptionDescription('od2', '', [od1])
|
||||||
# c = Config(od2)
|
# c = Config(od2)
|
||||||
# api = getapi(c)
|
# api = getapi(c)
|
||||||
# values = c.cfgimpl_get_values()
|
# values = c._config.cfgimpl_get_values()
|
||||||
# api.option('od1.u1').value.get()
|
# api.option('od1.u1').value.get()
|
||||||
# assert 'od1.u1' in values._p_.get_cached()
|
# assert 'od1.u1' in values._p_.get_cached()
|
||||||
# c.od1.cfgimpl_reset_cache(None, None)
|
# c.od1.cfgimpl_reset_cache(None, None)
|
||||||
|
@ -282,12 +282,12 @@ def test_reset_cache():
|
||||||
# c = Config(od1)
|
# c = Config(od1)
|
||||||
# api = getapi(c)
|
# api = getapi(c)
|
||||||
# api.property.add('expire')
|
# api.property.add('expire')
|
||||||
# values = c.cfgimpl_get_values()
|
# values = c._config.cfgimpl_get_values()
|
||||||
# settings = c.cfgimpl_get_settings()
|
# settings = c._config.cfgimpl_get_settings()
|
||||||
# api.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.cfgimpl_reset_cache(True)
|
# c._config.cfgimpl_reset_cache(True)
|
||||||
# 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()
|
||||||
# sleep(1)
|
# sleep(1)
|
||||||
|
@ -298,7 +298,7 @@ def test_reset_cache():
|
||||||
# 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.cfgimpl_reset_cache(True)
|
# c._config.cfgimpl_reset_cache(True)
|
||||||
# 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' in values._p_.get_cached()
|
# assert 'u2' in values._p_.get_cached()
|
||||||
|
@ -309,13 +309,13 @@ def test_reset_cache():
|
||||||
# od1 = make_description()
|
# od1 = make_description()
|
||||||
# c = Config(od1)
|
# c = Config(od1)
|
||||||
# api = getapi(c)
|
# api = getapi(c)
|
||||||
# values = c.cfgimpl_get_values()
|
# values = c._config.cfgimpl_get_values()
|
||||||
# settings = c.cfgimpl_get_settings()
|
# settings = c._config.cfgimpl_get_settings()
|
||||||
# #api.property.pop('expire')
|
# #api.property.pop('expire')
|
||||||
# api.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.cfgimpl_reset_cache(True)
|
# c._config.cfgimpl_reset_cache(True)
|
||||||
# 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()
|
||||||
# sleep(1)
|
# sleep(1)
|
||||||
|
@ -324,7 +324,7 @@ def test_reset_cache():
|
||||||
# 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.cfgimpl_reset_cache(True)
|
# c._config.cfgimpl_reset_cache(True)
|
||||||
# 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()
|
||||||
|
@ -335,8 +335,8 @@ def test_cache_not_cache():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
c = Config(od1)
|
c = Config(od1)
|
||||||
api = getapi(c)
|
api = getapi(c)
|
||||||
values = c.cfgimpl_get_values()
|
values = c._config.cfgimpl_get_values()
|
||||||
settings = c.cfgimpl_get_settings()
|
settings = c._config.cfgimpl_get_settings()
|
||||||
api.property.pop('cache')
|
api.property.pop('cache')
|
||||||
api.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()
|
||||||
|
@ -347,18 +347,18 @@ def test_cache_not_cache():
|
||||||
# od1 = make_description()
|
# od1 = make_description()
|
||||||
# c = Config(od1)
|
# c = Config(od1)
|
||||||
# api = getapi(c)
|
# api = getapi(c)
|
||||||
# values = c.cfgimpl_get_values()
|
# values = c._config.cfgimpl_get_values()
|
||||||
# settings = c.cfgimpl_get_settings()
|
# settings = c._config.cfgimpl_get_settings()
|
||||||
# api.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.cfgimpl_reset_cache(only=('values',))
|
# c._config.cfgimpl_reset_cache(only=('values',))
|
||||||
# assert 'u1' not in values._p_.get_cached()
|
# assert 'u1' not in values._p_.get_cached()
|
||||||
# assert 'u1' in settings._p_.get_cached()
|
# assert 'u1' in settings._p_.get_cached()
|
||||||
# api.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.cfgimpl_reset_cache(only=('settings',))
|
# c._config.cfgimpl_reset_cache(only=('settings',))
|
||||||
# assert 'u1' in values._p_.get_cached()
|
# assert 'u1' in values._p_.get_cached()
|
||||||
# assert 'u1' not in settings._p_.get_cached()
|
# assert 'u1' not in settings._p_.get_cached()
|
||||||
|
|
||||||
|
@ -375,30 +375,30 @@ def test_cache_not_cache():
|
||||||
# api.property.pop('expire')
|
# api.property.pop('expire')
|
||||||
# api.property.pop('disabled')
|
# api.property.pop('disabled')
|
||||||
#
|
#
|
||||||
# c.cfgimpl_get_values().force_cache()
|
# c._config.cfgimpl_get_values().force_cache()
|
||||||
# compare(c.cfgimpl_get_values()._p_.get_cached(), {'u1': {None: ([], None)},
|
# compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'u1': {None: ([], None)},
|
||||||
# 'u2': {None: (None, None)},
|
# 'u2': {None: (None, None)},
|
||||||
# 'u3': {None: ([], None)},
|
# 'u3': {None: ([], None)},
|
||||||
# 'u4': {None: (None, None)}})
|
# 'u4': {None: (None, None)}})
|
||||||
# compare(c.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
# compare(c._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||||
# 'u1': {None: (set(['empty']), None)},
|
# 'u1': {None: (set(['empty']), None)},
|
||||||
# 'u2': {None: (set([]), None)},
|
# 'u2': {None: (set([]), None)},
|
||||||
# 'u3': {None: (set(['empty']), None)},
|
# 'u3': {None: (set(['empty']), None)},
|
||||||
# 'u4': {None: (set(['disabled']), None)}})
|
# 'u4': {None: (set(['disabled']), None)}})
|
||||||
# api.property.read_only()
|
# api.property.read_only()
|
||||||
#
|
#
|
||||||
# c.cfgimpl_get_values().force_cache()
|
# c._config.cfgimpl_get_values().force_cache()
|
||||||
# compare(c.cfgimpl_get_values()._p_.get_cached(), {'u1': {None: ([], None)},
|
# compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'u1': {None: ([], None)},
|
||||||
# 'u2': {None: (None, None)},
|
# 'u2': {None: (None, None)},
|
||||||
# 'u3': {None: ([], None)}})
|
# 'u3': {None: ([], None)}})
|
||||||
# compare(c.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'empty', 'everything_frozen', 'frozen', 'mandatory', 'validator', 'warnings']), 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)},
|
# 'u1': {None: (set(['empty']), None)},
|
||||||
# 'u2': {None: (set([]), None)},
|
# 'u2': {None: (set([]), None)},
|
||||||
# 'u3': {None: (set(['empty']), None)},
|
# 'u3': {None: (set(['empty']), None)},
|
||||||
# 'u4': {None: (set(['disabled']), None)}})
|
# 'u4': {None: (set(['disabled']), None)}})
|
||||||
#
|
#
|
||||||
# c.cfgimpl_get_settings().remove('cache')
|
# c._config.cfgimpl_get_settings().remove('cache')
|
||||||
# raises(ConfigError, "c.cfgimpl_get_values().force_cache()")
|
# raises(ConfigError, "c._config.cfgimpl_get_values().force_cache()")
|
||||||
|
|
||||||
|
|
||||||
def test_cache_master_slave():
|
def test_cache_master_slave():
|
||||||
|
@ -410,13 +410,13 @@ def test_cache_master_slave():
|
||||||
cfg = Config(maconfig)
|
cfg = Config(maconfig)
|
||||||
api = getapi(cfg)
|
api = getapi(cfg)
|
||||||
api.property.read_write()
|
api.property.read_write()
|
||||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
#assert cfg.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'])
|
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
||||||
api.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
api.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
||||||
cache = cfg.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'])
|
||||||
else:
|
else:
|
||||||
|
@ -426,7 +426,7 @@ def test_cache_master_slave():
|
||||||
#assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([None])
|
#assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([None])
|
||||||
#assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None]
|
#assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None]
|
||||||
#assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None
|
#assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None
|
||||||
cache = cfg.cfgimpl_get_settings()._p_.get_cached()
|
cache = cfg._config.cfgimpl_get_settings()._p_.get_cached()
|
||||||
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
||||||
assert set(cache['ip_admin_eth0'].keys()) == set([None])
|
assert set(cache['ip_admin_eth0'].keys()) == set([None])
|
||||||
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
|
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
|
||||||
|
@ -439,7 +439,7 @@ def test_cache_master_slave():
|
||||||
api.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
api.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
||||||
api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get()
|
api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get()
|
||||||
cache = cfg.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'])
|
||||||
else:
|
else:
|
||||||
|
@ -450,7 +450,7 @@ def test_cache_master_slave():
|
||||||
#assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None, None]
|
#assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None, None]
|
||||||
#assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None
|
#assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None
|
||||||
#assert cache['ip_admin_eth0.netmask_admin_eth0'][1][0] is None
|
#assert cache['ip_admin_eth0.netmask_admin_eth0'][1][0] is None
|
||||||
cache = cfg.cfgimpl_get_settings()._p_.get_cached()
|
cache = cfg._config.cfgimpl_get_settings()._p_.get_cached()
|
||||||
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
||||||
assert set(cache['ip_admin_eth0'].keys()) == set([None])
|
assert set(cache['ip_admin_eth0'].keys()) == set([None])
|
||||||
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
|
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
|
||||||
|
@ -487,79 +487,79 @@ def test_cache_callback():
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
api.property.pop('expire')
|
api.property.pop('expire')
|
||||||
api.option.make_dict()
|
api.option.make_dict()
|
||||||
#assert cfg.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.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('val', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('val', None)},
|
||||||
'val2': {None: ('val', None)},
|
'val2': {None: ('val', None)},
|
||||||
'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')
|
api.option('val1').value.set('new')
|
||||||
#assert cfg.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.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()
|
api.option.make_dict()
|
||||||
#assert cfg.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.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'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')
|
api.option('val3').value.set('new2')
|
||||||
#assert cfg.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)}}
|
||||||
compare(cfg.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'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()
|
api.option.make_dict()
|
||||||
#assert cfg.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)}}
|
||||||
compare(cfg.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'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')
|
api.option('val4').value.set('new3')
|
||||||
#assert cfg.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)},
|
||||||
# 'val4': {None: (set([]), None)}}
|
# 'val4': {None: (set([]), None)}}
|
||||||
compare(cfg.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'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()
|
api.option.make_dict()
|
||||||
#assert cfg.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)},
|
||||||
# 'val4': {None: (set([]), None)}}
|
# 'val4': {None: (set([]), None)}}
|
||||||
compare(cfg.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'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'])
|
api.option('val5').value.set([undefined, 'new4'])
|
||||||
#assert cfg.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)},
|
||||||
# 'val4': {None: (set([]), None)},
|
# 'val4': {None: (set([]), None)},
|
||||||
# 'val5': {None: (set(['empty']), None)}}
|
# 'val5': {None: (set(['empty']), None)}}
|
||||||
compare(cfg.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'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()
|
api.option.make_dict()
|
||||||
#assert cfg.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)},
|
||||||
# 'val4': {None: (set([]), None)},
|
# 'val4': {None: (set([]), None)},
|
||||||
# 'val5': {None: (set(['empty']), None)}}
|
# 'val5': {None: (set(['empty']), None)}}
|
||||||
compare(cfg.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'val1': {None: ('new', None)},
|
||||||
'val2': {None: ('new', None)},
|
'val2': {None: ('new', None)},
|
||||||
'val3': {None: ('new2', None)},
|
'val3': {None: ('new2', None)},
|
||||||
'val4': {None: ('new3', None)},
|
'val4': {None: ('new3', None)},
|
||||||
|
@ -594,20 +594,20 @@ def test_cache_master_and_slaves_master():
|
||||||
#None because no value
|
#None because no value
|
||||||
idx_val2 = None
|
idx_val2 = None
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {}
|
||||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
else:
|
else:
|
||||||
compare(cfg.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
||||||
'val1': {None: (val1_props, None)},
|
'val1': {None: (val1_props, None)},
|
||||||
'val1.val1': {None: (val1_val1_props, None)},
|
'val1.val1': {None: (val1_val1_props, None)},
|
||||||
'val1.val2': {idx_val2: (val1_val2_props, None)}})
|
'val1.val2': {idx_val2: (val1_val2_props, None)}})
|
||||||
# len is 0 so don't get any value
|
# len is 0 so don't get any value
|
||||||
compare(cfg.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])
|
api.option('val1.val1').value.set([undefined])
|
||||||
compare(cfg.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.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
api.option.make_dict()
|
api.option.make_dict()
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
val_val2 = [None]
|
val_val2 = [None]
|
||||||
|
@ -617,31 +617,31 @@ def test_cache_master_and_slaves_master():
|
||||||
idx_val2 = 0
|
idx_val2 = 0
|
||||||
val_val2 = None
|
val_val2 = None
|
||||||
val_val2_props = {idx_val2: (val1_val2_props, None)}
|
val_val2_props = {idx_val2: (val1_val2_props, None)}
|
||||||
compare(cfg.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
||||||
'val1': {None: (val1_props, None)},
|
'val1': {None: (val1_props, None)},
|
||||||
'val1.val1': {None: (val1_val1_props, None)},
|
'val1.val1': {None: (val1_val1_props, None)},
|
||||||
'val1.val2': val_val2_props})
|
'val1.val2': val_val2_props})
|
||||||
compare(cfg.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])
|
api.option('val1.val1').value.set([undefined, undefined])
|
||||||
api.option.make_dict()
|
api.option.make_dict()
|
||||||
api.option('val1.val2', 1).value.set('oui')
|
api.option('val1.val2', 1).value.set('oui')
|
||||||
compare(cfg.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.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
val1_val2_props = {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)}
|
val1_val2_props = {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)}
|
||||||
else:
|
else:
|
||||||
val1_val2_props = {0: (frozenset([]), None), 1: (frozenset([]), None)}
|
val1_val2_props = {0: (frozenset([]), None), 1: (frozenset([]), None)}
|
||||||
#assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (global_props, None)},
|
#assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (global_props, None)},
|
||||||
# 'val1': {None: (val1_props, None)},
|
# 'val1': {None: (val1_props, None)},
|
||||||
# 'val1.val1': {None: (val1_val1_props, None)},
|
# 'val1.val1': {None: (val1_val1_props, None)},
|
||||||
# 'val1.val2': val1_val2_props}
|
# 'val1.val2': val1_val2_props}
|
||||||
#if TIRAMISU_VERSION == 2:
|
#if TIRAMISU_VERSION == 2:
|
||||||
# assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None, None], None)},
|
# assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None, None], None)},
|
||||||
# 'val1.val2': {None: ([None, 'oui'], None)}}
|
# 'val1.val2': {None: ([None, 'oui'], None)}}
|
||||||
#else:
|
#else:
|
||||||
# assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None, None], None)},
|
# assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None, None], None)},
|
||||||
# 'val1.val2': {0: (None, None), 1: ('oui', None)}}
|
# 'val1.val2': {0: (None, None), 1: ('oui', None)}}
|
||||||
|
|
||||||
|
|
||||||
|
@ -671,23 +671,23 @@ def test_cache_master_callback():
|
||||||
val1_val1_props = frozenset(val1_val1_props)
|
val1_val1_props = frozenset(val1_val1_props)
|
||||||
val1_val2_props = frozenset(val1_val2_props)
|
val1_val2_props = frozenset(val1_val2_props)
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {}
|
||||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
else:
|
else:
|
||||||
compare(cfg.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
compare(cfg._config.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (global_props, None)},
|
||||||
'val1': {None: (val1_props, None)},
|
'val1': {None: (val1_props, None)},
|
||||||
'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.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])
|
api.option('val1.val1').value.set([undefined])
|
||||||
compare(cfg.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.cfgimpl_get_values()._p_.get_cached() == {}
|
assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
api.option.make_dict()
|
api.option.make_dict()
|
||||||
#FIXMEassert cfg.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.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)},
|
||||||
# 'val1.val2': {None: ([None], None)}
|
# 'val1.val2': {None: ([None], None)}
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
@ -703,43 +703,43 @@ def test_cache_master_callback():
|
||||||
# api.property.read_write()
|
# api.property.read_write()
|
||||||
# api.property.pop('expire')
|
# api.property.pop('expire')
|
||||||
# api.option.make_dict()
|
# api.option.make_dict()
|
||||||
# compare(cfg.cfgimpl_get_values()._p_.get_cached(), {'int': {None: ([0], None)},
|
# compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'int': {None: ([0], None)},
|
||||||
# 'str': {None: ([None], None)},
|
# 'str': {None: ([None], None)},
|
||||||
# 'str1': {None: ([None], None)}})
|
# 'str1': {None: ([None], None)}})
|
||||||
# conver(cfg.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), 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)},
|
# 'int': {None: (set(['empty']), None)},
|
||||||
# 'str': {None: (set([]), None), 0: (set([]), None)},
|
# 'str': {None: (set([]), None), 0: (set([]), None)},
|
||||||
# 'str1': {None: (set([]), None), 0: (set([]), None)}})
|
# 'str1': {None: (set([]), None), 0: (set([]), None)}})
|
||||||
# api.option('int').value.set([0, 1])
|
# api.option('int').value.set([0, 1])
|
||||||
# api.option.make_dict()
|
# api.option.make_dict()
|
||||||
# compare(cfg.cfgimpl_get_values()._p_.get_cached(), {'int': {None: ([0, 1], None)},
|
# compare(cfg._config.cfgimpl_get_values()._p_.get_cached(), {'int': {None: ([0, 1], None)},
|
||||||
# 'str': {None: ([None, None], None)},
|
# 'str': {None: ([None, None], None)},
|
||||||
# 'str1': {None: ([None, None], None)}})
|
# 'str1': {None: ([None, None], None)}})
|
||||||
# compare(cfg.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)},
|
||||||
# 'int': {None: (set(['empty']), None)},
|
# 'int': {None: (set(['empty']), None)},
|
||||||
# 'str': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)},
|
# 'str': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)},
|
||||||
# 'str1': {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('str', 1).value.set('1')
|
||||||
# api.option.make_dict()
|
# api.option.make_dict()
|
||||||
# assert set(cfg.cfgimpl_get_values()._p_.get_cached().keys()) == set(['int', 'str', 'str1'])
|
# assert set(cfg._config.cfgimpl_get_values()._p_.get_cached().keys()) == set(['int', 'str', 'str1'])
|
||||||
# compare(cfg.cfgimpl_get_values()._p_.get_cached()['int'], {None: ([0, 1], None)})
|
# compare(cfg._config.cfgimpl_get_values()._p_.get_cached()['int'], {None: ([0, 1], None)})
|
||||||
# compare(cfg.cfgimpl_get_values()._p_.get_cached()['str'], {None: ([None, '1'], None)})
|
# compare(cfg._config.cfgimpl_get_values()._p_.get_cached()['str'], {None: ([None, '1'], None)})
|
||||||
# assert cfg.cfgimpl_get_values()._p_.get_cached()['str1'][None][0][0] == None
|
# assert cfg._config.cfgimpl_get_values()._p_.get_cached()['str1'][None][0][0] == None
|
||||||
# raises(PropertiesOptionError, "cfg.cfgimpl_get_values()._p_.get_cached()['str1'][None][0][1]")
|
# raises(PropertiesOptionError, "cfg._config.cfgimpl_get_values()._p_.get_cached()['str1'][None][0][1]")
|
||||||
# assert cfg.cfgimpl_get_values()._p_.get_cached()['str1'][None][1] == None
|
# assert cfg._config.cfgimpl_get_values()._p_.get_cached()['str1'][None][1] == None
|
||||||
# compare(cfg.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)},
|
||||||
# 'int': {None: (set(['empty']), None)},
|
# 'int': {None: (set(['empty']), None)},
|
||||||
# 'str': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)},
|
# 'str': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)},
|
||||||
# 'str1': {None: (set([]), None), 0: (set([]), None), 1: (set(['hidden']), None)}})
|
# 'str1': {None: (set([]), None), 0: (set([]), None), 1: (set(['hidden']), None)}})
|
||||||
# api.property.read_only()
|
# api.property.read_only()
|
||||||
# assert cfg.cfgimpl_get_values()._p_.get_cached() == {}
|
# assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
# assert cfg.cfgimpl_get_settings()._p_.get_cached() == {}
|
# assert cfg._config.cfgimpl_get_settings()._p_.get_cached() == {}
|
||||||
# api.option.make_dict()
|
# api.option.make_dict()
|
||||||
# assert cfg.cfgimpl_get_values()._p_.get_cached() == {'int': {None: ([0, 1], None)},
|
# assert cfg._config.cfgimpl_get_values()._p_.get_cached() == {'int': {None: ([0, 1], None)},
|
||||||
# 'str': {None: ([None, '1'], None)},
|
# 'str': {None: ([None, '1'], None)},
|
||||||
# 'str1': {None: ([None, None], None)}}
|
# 'str1': {None: ([None, None], None)}}
|
||||||
# assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'everything_frozen', 'validator', 'warnings', 'empty', 'mandatory', ]), 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)},
|
# 'int': {None: (set(['empty']), None)},
|
||||||
# 'str': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)},
|
# 'str': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)},
|
||||||
# 'str1': {None: (set([]), None), 0: (set([]), None), 1: (set(['hidden']), None)}}
|
# 'str1': {None: (set([]), None), 0: (set([]), None), 1: (set(['hidden']), None)}}
|
||||||
|
@ -755,46 +755,46 @@ def test_cache_requires():
|
||||||
api.property.read_write()
|
api.property.read_write()
|
||||||
if TIRAMISU_VERSION == 2:
|
if TIRAMISU_VERSION == 2:
|
||||||
api.property.pop('expire')
|
api.property.pop('expire')
|
||||||
assert c.cfgimpl_get_values()._p_.get_cached() == {}
|
assert c._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
assert api.option('ip_address_service').value.get() == None
|
assert api.option('ip_address_service').value.get() == None
|
||||||
compare(c.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.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
assert c._config.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
||||||
else:
|
else:
|
||||||
compare(c.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
compare(c._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()
|
api.option.make_dict()
|
||||||
compare(c.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)}})
|
||||||
|
|
||||||
compare(c.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
compare(c._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')
|
api.option('ip_address_service').value.set('1.1.1.1')
|
||||||
compare(c.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)}})
|
||||||
|
|
||||||
compare(c.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (True, None)}})
|
compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (True, None)}})
|
||||||
api.option.make_dict()
|
api.option.make_dict()
|
||||||
compare(c.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)}})
|
||||||
|
|
||||||
compare(c.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: ('1.1.1.1', None)},
|
compare(c._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)
|
api.option('activate_service').value.set(False)
|
||||||
compare(c.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)}})
|
||||||
|
|
||||||
assert c.cfgimpl_get_values()._p_.get_cached() == {}
|
assert c._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
api.option.make_dict()
|
api.option.make_dict()
|
||||||
compare(c.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(['disabled']), None)}})
|
'ip_address_service': {None: (set(['disabled']), None)}})
|
||||||
|
|
||||||
compare(c.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (False, None)}})
|
compare(c._config.cfgimpl_get_values()._p_.get_cached(), {'activate_service': {None: (False, None)}})
|
||||||
|
|
||||||
|
|
||||||
def test_cache_global_properties():
|
def test_cache_global_properties():
|
||||||
|
@ -805,25 +805,25 @@ def test_cache_global_properties():
|
||||||
c = Config(od)
|
c = Config(od)
|
||||||
api = getapi(c)
|
api = getapi(c)
|
||||||
api.property.read_write()
|
api.property.read_write()
|
||||||
assert c.cfgimpl_get_values()._p_.get_cached() == {}
|
assert c._config.cfgimpl_get_values()._p_.get_cached() == {}
|
||||||
assert api.option('ip_address_service').value.get() == None
|
assert api.option('ip_address_service').value.get() == None
|
||||||
compare(c.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.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
assert c._config.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
||||||
else:
|
else:
|
||||||
compare(c.cfgimpl_get_values()._p_.get_cached(), {'ip_address_service': {None: (None, None)},
|
compare(c._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')
|
api.property.pop('disabled')
|
||||||
assert api.option('ip_address_service').value.get() == None
|
assert api.option('ip_address_service').value.get() == None
|
||||||
compare(c.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
compare(c._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')
|
api.property.add('test')
|
||||||
assert api.option('ip_address_service').value.get() == None
|
assert api.option('ip_address_service').value.get() == None
|
||||||
compare(c.cfgimpl_get_settings()._p_.get_cached(), {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings', 'test']), None)},
|
compare(c._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)}})
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import owners
|
from tiramisu.setting import owners
|
||||||
from tiramisu.option import ChoiceOption, StrOption, OptionDescription
|
from tiramisu.option import ChoiceOption, StrOption, OptionDescription
|
||||||
from tiramisu.config 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 getapi, undefined, Params, ParamValue, ParamOption
|
||||||
from tiramisu.api import TIRAMISU_VERSION
|
from tiramisu.api import TIRAMISU_VERSION
|
||||||
|
|
|
@ -8,7 +8,8 @@ import weakref
|
||||||
from .autopath import do_autopath
|
from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.config import Config, SubConfig
|
from tiramisu import Config
|
||||||
|
from tiramisu.config import SubConfig
|
||||||
from tiramisu.i18n import _
|
from tiramisu.i18n import _
|
||||||
from tiramisu import Config, IntOption, FloatOption, StrOption, ChoiceOption, \
|
from tiramisu import Config, IntOption, FloatOption, StrOption, ChoiceOption, \
|
||||||
BoolOption, UnicodeOption, OptionDescription, getapi, undefined
|
BoolOption, UnicodeOption, OptionDescription, getapi, undefined
|
||||||
|
@ -54,12 +55,12 @@ def test_base_config_name():
|
||||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||||
descr = OptionDescription('tiramisu', '', [gcdummy])
|
descr = OptionDescription('tiramisu', '', [gcdummy])
|
||||||
cfg = Config(descr, session_id='cfg')
|
cfg = Config(descr, session_id='cfg')
|
||||||
cfg.impl_getname() == 'cfg'
|
cfg.config.name() == 'cfg'
|
||||||
raises(ValueError, "Config(descr, session_id='unvalid name')")
|
raises(ValueError, "Config(descr, session_id='unvalid name')")
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_not_config():
|
#def test_not_config():
|
||||||
assert raises(TypeError, "Config('str')")
|
# assert raises(TypeError, "Config('str')")
|
||||||
|
|
||||||
|
|
||||||
#def test_base_path():
|
#def test_base_path():
|
||||||
|
@ -167,8 +168,8 @@ def test_config_impl_get_path_by_opt():
|
||||||
boo = api.option('bool').option.get()
|
boo = api.option('bool').option.get()
|
||||||
unknown = IntOption('test', '')
|
unknown = IntOption('test', '')
|
||||||
unknown
|
unknown
|
||||||
assert config.cfgimpl_get_description().impl_get_path_by_opt(boo) == 'bool'
|
assert config._config.cfgimpl_get_description().impl_get_path_by_opt(boo) == 'bool'
|
||||||
assert config.cfgimpl_get_description().impl_get_path_by_opt(dummy) == 'gc.dummy'
|
assert config._config.cfgimpl_get_description().impl_get_path_by_opt(dummy) == 'gc.dummy'
|
||||||
#raises(AttributeError, "config.cfgimpl_get_description().impl_get_path_by_opt(unknown)")
|
#raises(AttributeError, "config.cfgimpl_get_description().impl_get_path_by_opt(unknown)")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ do_autopath()
|
||||||
import warnings, sys
|
import warnings, sys
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.config import Config
|
from tiramisu import Config
|
||||||
from tiramisu.option import DomainnameOption, EmailOption, URLOption, OptionDescription
|
from tiramisu.option import DomainnameOption, EmailOption, URLOption, OptionDescription
|
||||||
from tiramisu.error import ValueWarning
|
from tiramisu.error import ValueWarning
|
||||||
from tiramisu.i18n import _
|
from tiramisu.i18n import _
|
||||||
|
|
|
@ -19,7 +19,7 @@ def test_deref_storage():
|
||||||
b = BoolOption('b', '')
|
b = BoolOption('b', '')
|
||||||
o = OptionDescription('od', '', [b])
|
o = OptionDescription('od', '', [b])
|
||||||
c = Config(o)
|
c = Config(o)
|
||||||
w = weakref.ref(c.cfgimpl_get_values()._p_)
|
w = weakref.ref(c._config.cfgimpl_get_values()._p_)
|
||||||
del(c)
|
del(c)
|
||||||
assert w() is None
|
assert w() is None
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ def test_deref_value():
|
||||||
b = BoolOption('b', '')
|
b = BoolOption('b', '')
|
||||||
o = OptionDescription('od', '', [b])
|
o = OptionDescription('od', '', [b])
|
||||||
c = Config(o)
|
c = Config(o)
|
||||||
w = weakref.ref(c.cfgimpl_get_values())
|
w = weakref.ref(c._config.cfgimpl_get_values())
|
||||||
del(c)
|
del(c)
|
||||||
assert w() is None
|
assert w() is None
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ def test_deref_setting():
|
||||||
b = BoolOption('b', '')
|
b = BoolOption('b', '')
|
||||||
o = OptionDescription('od', '', [b])
|
o = OptionDescription('od', '', [b])
|
||||||
c = Config(o)
|
c = Config(o)
|
||||||
w = weakref.ref(c.cfgimpl_get_settings())
|
w = weakref.ref(c._config.cfgimpl_get_settings())
|
||||||
del(c)
|
del(c)
|
||||||
assert w() is None
|
assert w() is None
|
||||||
|
|
||||||
|
@ -134,36 +134,36 @@ def test_deref_optiondescription_config():
|
||||||
assert w() is None
|
assert w() is None
|
||||||
|
|
||||||
|
|
||||||
def test_deref_groupconfig():
|
#def test_deref_groupconfig():
|
||||||
if not IS_DEREFABLE:
|
# if not IS_DEREFABLE:
|
||||||
return
|
# return
|
||||||
i1 = IntOption('i1', '')
|
# i1 = IntOption('i1', '')
|
||||||
od1 = OptionDescription('od1', '', [i1])
|
# od1 = OptionDescription('od1', '', [i1])
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
# od2 = OptionDescription('od2', '', [od1])
|
||||||
conf1 = Config(od2, 'conf1')
|
# conf1 = Config(od2, 'conf1')
|
||||||
conf2 = Config(od2, 'conf2')
|
# conf2 = Config(od2, 'conf2')
|
||||||
meta = GroupConfig([conf1, conf2])
|
# meta = GroupConfig([conf1, conf2])
|
||||||
w = weakref.ref(conf1)
|
# w = weakref.ref(conf1)
|
||||||
del(conf1)
|
# del(conf1)
|
||||||
assert w() is not None
|
# assert w() is not None
|
||||||
del(meta)
|
# del(meta)
|
||||||
assert w() is None
|
# assert w() is None
|
||||||
|
|
||||||
|
|
||||||
def test_deref_metaconfig():
|
#def test_deref_metaconfig():
|
||||||
if not IS_DEREFABLE:
|
# if not IS_DEREFABLE:
|
||||||
return
|
# return
|
||||||
i1 = IntOption('i1', '')
|
# i1 = IntOption('i1', '')
|
||||||
od1 = OptionDescription('od1', '', [i1])
|
# od1 = OptionDescription('od1', '', [i1])
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
# od2 = OptionDescription('od2', '', [od1])
|
||||||
conf1 = Config(od2, 'conf1')
|
# conf1 = Config(od2, 'conf1')
|
||||||
conf2 = Config(od2, 'conf2')
|
# conf2 = Config(od2, 'conf2')
|
||||||
meta = MetaConfig([conf1, conf2])
|
# meta = MetaConfig([conf1, conf2])
|
||||||
w = weakref.ref(conf1)
|
# w = weakref.ref(conf1)
|
||||||
del(conf1)
|
# del(conf1)
|
||||||
assert w() is not None
|
# assert w() is not None
|
||||||
del(meta)
|
# del(meta)
|
||||||
assert w() is None
|
# assert w() is None
|
||||||
|
|
||||||
|
|
||||||
def test_deref_consistency():
|
def test_deref_consistency():
|
||||||
|
|
|
@ -3,7 +3,7 @@ from .autopath import do_autopath
|
||||||
do_autopath()
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import groups
|
from tiramisu.setting import groups
|
||||||
from tiramisu.config import Config
|
from tiramisu import Config
|
||||||
from tiramisu import ChoiceOption, BoolOption, IntOption, \
|
from tiramisu import ChoiceOption, BoolOption, IntOption, \
|
||||||
StrOption, OptionDescription, getapi
|
StrOption, OptionDescription, getapi
|
||||||
from .test_state import _diff_opts, _diff_conf
|
from .test_state import _diff_opts, _diff_conf
|
||||||
|
@ -48,7 +48,7 @@ def make_description():
|
||||||
|
|
||||||
def test_duplicate():
|
def test_duplicate():
|
||||||
cfg = Config(make_description())
|
cfg = Config(make_description())
|
||||||
ncfg = cfg.duplicate()
|
ncfg = cfg.config.duplicate()
|
||||||
api = getapi(cfg)
|
api = getapi(cfg)
|
||||||
api2 = getapi(ncfg)
|
api2 = getapi(ncfg)
|
||||||
assert api.option('creole.general.numero_etab').value.get() == None
|
assert api.option('creole.general.numero_etab').value.get() == None
|
||||||
|
|
|
@ -4,7 +4,7 @@ do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
from tiramisu.api import TIRAMISU_VERSION
|
from tiramisu.api import TIRAMISU_VERSION
|
||||||
from tiramisu.config import Config
|
from tiramisu import Config
|
||||||
from tiramisu import IntOption, StrOption, UnicodeOption, OptionDescription, \
|
from tiramisu import IntOption, StrOption, UnicodeOption, OptionDescription, \
|
||||||
SymLinkOption, MasterSlaves, getapi, undefined, Params, ParamOption
|
SymLinkOption, MasterSlaves, getapi, undefined, Params, ParamOption
|
||||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||||
|
|
|
@ -139,9 +139,9 @@ def test_find():
|
||||||
'od1.i2': 1, 'od1.i5': [2]}
|
'od1.i2': 1, 'od1.i5': [2]}
|
||||||
|
|
||||||
|
|
||||||
def test_group_error():
|
#def test_group_error():
|
||||||
raises(ValueError, "GroupConfig('str')")
|
# raises(ValueError, "GroupConfig('str')")
|
||||||
raises(ValueError, "GroupConfig(['str'])")
|
# raises(ValueError, "GroupConfig(['str'])")
|
||||||
|
|
||||||
|
|
||||||
def test_meta_meta():
|
def test_meta_meta():
|
||||||
|
@ -187,17 +187,17 @@ def test_meta_meta():
|
||||||
def test_meta_new_config():
|
def test_meta_new_config():
|
||||||
od = make_description()
|
od = make_description()
|
||||||
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
||||||
assert len(meta.cfgimpl_get_children()) == 2
|
assert len(meta.config.list()) == 2
|
||||||
meta.new_config('newconf1')
|
meta.config.new('newconf1')
|
||||||
assert len(meta.cfgimpl_get_children()) == 3
|
assert len(meta.config.list()) == 3
|
||||||
|
|
||||||
|
|
||||||
def test_meta_new_config_wrong_name():
|
def test_meta_new_config_wrong_name():
|
||||||
od = make_description()
|
od = make_description()
|
||||||
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
||||||
assert len(meta.cfgimpl_get_children()) == 2
|
assert len(meta.config.list()) == 2
|
||||||
raises(ConflictError, "meta.new_config('name1')")
|
raises(ConflictError, "meta.config.new('name1')")
|
||||||
assert len(meta.cfgimpl_get_children()) == 2
|
assert len(meta.config.list()) == 2
|
||||||
|
|
||||||
|
|
||||||
def test_meta_meta_set():
|
def test_meta_meta_set():
|
||||||
|
@ -232,14 +232,14 @@ def test_not_meta():
|
||||||
conf2 = Config(od2, session_id='conf2')
|
conf2 = Config(od2, session_id='conf2')
|
||||||
conf3 = Config(od2)
|
conf3 = Config(od2)
|
||||||
conf4 = Config(od2, session_id='conf4')
|
conf4 = Config(od2, session_id='conf4')
|
||||||
raises(ValueError, "GroupConfig(conf1)")
|
raises(TypeError, "GroupConfig(conf1)")
|
||||||
#same name
|
#same name
|
||||||
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)
|
api = getapi(grp)
|
||||||
raises(ConfigError, "api.option('od1.i1').value.get()")
|
raises(ConfigError, "api.option('od1.i1').value.get()")
|
||||||
conf1, conf2 = grp.cfgimpl_get_children()
|
conf1, conf2 = grp.config.list()
|
||||||
errors = api.value.set('od1.i1', 7)
|
errors = api.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 api.config('conf1').option('od1.i1').value.get() == api.config('conf2').option('od1.i1').value.get() == 7
|
||||||
|
@ -254,7 +254,7 @@ def test_group_find_firsts():
|
||||||
conf2 = Config(od2, session_id='conf2')
|
conf2 = Config(od2, session_id='conf2')
|
||||||
grp = GroupConfig([conf1, conf2])
|
grp = GroupConfig([conf1, conf2])
|
||||||
api = getapi(grp)
|
api = getapi(grp)
|
||||||
assert [conf1, conf2] == api.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():
|
||||||
|
@ -303,13 +303,13 @@ def test_meta_master_slaves():
|
||||||
conf2 = Config(od, session_id='conf2')
|
conf2 = Config(od, session_id='conf2')
|
||||||
api = getapi(MetaConfig([conf1, conf2]))
|
api = getapi(MetaConfig([conf1, conf2]))
|
||||||
api.property.read_only()
|
api.property.read_only()
|
||||||
assert [conf1, conf2] == api.config.find('ip_admin_eth0', first=True).cfgimpl_get_children()
|
assert [conf1._config, conf2._config] == api.config.find('ip_admin_eth0', first=True).cfgimpl_get_children()
|
||||||
assert [conf1, conf2] == api.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
assert [conf1._config, conf2._config] == api.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
||||||
api.property.read_write()
|
api.property.read_write()
|
||||||
raises(AttributeError, "api.config.find('netmask_admin_eth0', first=True)")
|
raises(AttributeError, "api.config.find('netmask_admin_eth0', first=True)")
|
||||||
assert [conf1, conf2] == api.unrestraint.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
assert [conf1._config, conf2._config] == api.unrestraint.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
||||||
api.property.read_only()
|
api.property.read_only()
|
||||||
assert [conf1, conf2] == api.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
assert [conf1._config, conf2._config] == api.config.find('netmask_admin_eth0', first=True).cfgimpl_get_children()
|
||||||
|
|
||||||
|
|
||||||
def test_meta_master_slaves_value2():
|
def test_meta_master_slaves_value2():
|
||||||
|
|
|
@ -3,7 +3,8 @@ do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.config import Config
|
from tiramisu import Config
|
||||||
|
from tiramisu.config import KernelConfig
|
||||||
from tiramisu.setting import groups, owners
|
from tiramisu.setting import groups, owners
|
||||||
from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||||
StrOption, OptionDescription, SymLinkOption, IPOption, NetmaskOption, MasterSlaves, \
|
StrOption, OptionDescription, SymLinkOption, IPOption, NetmaskOption, MasterSlaves, \
|
||||||
|
@ -66,14 +67,14 @@ def return_calc(i, j, k):
|
||||||
|
|
||||||
|
|
||||||
def is_config(config, **kwargs):
|
def is_config(config, **kwargs):
|
||||||
if isinstance(config, Config):
|
if isinstance(config, KernelConfig):
|
||||||
return 'yes'
|
return 'yes'
|
||||||
else:
|
else:
|
||||||
return 'no'
|
return 'no'
|
||||||
|
|
||||||
|
|
||||||
def ret_from_config(config):
|
def ret_from_config(config):
|
||||||
api = getapi(config)
|
api = Config(config)
|
||||||
return api.option('val1').value.get()
|
return api.option('val1').value.get()
|
||||||
|
|
||||||
|
|
||||||
|
@ -253,7 +254,6 @@ def test_callback_invalid():
|
||||||
|
|
||||||
|
|
||||||
def test_callback_with_context():
|
def test_callback_with_context():
|
||||||
#val1 = StrOption("val1", "", callback=is_config, callback_params={'': ((None,),), 'value': ('string',)})
|
|
||||||
context = ParamContext()
|
context = ParamContext()
|
||||||
value = ParamValue('string')
|
value = ParamValue('string')
|
||||||
params = Params((context,), {'value': value})
|
params = Params((context,), {'value': value})
|
||||||
|
|
|
@ -34,9 +34,9 @@ def return_if_val(value):
|
||||||
|
|
||||||
|
|
||||||
def is_context(value, context):
|
def is_context(value, context):
|
||||||
api = getapi(context)
|
api = Config(context)
|
||||||
api.property.pop('validator')
|
api.property.pop('validator')
|
||||||
if not isinstance(context, Config):
|
if not isinstance(api, Config):
|
||||||
raise ValueError('not context')
|
raise ValueError('not context')
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ def value_empty(value, empty, values):
|
||||||
|
|
||||||
|
|
||||||
def valid_from_config(value, config):
|
def valid_from_config(value, config):
|
||||||
api = getapi(config)
|
api = Config(config)
|
||||||
if api.option('opt1').value.get() != u'yes':
|
if api.option('opt1').value.get() != u'yes':
|
||||||
raise ValueError("c'est une erreur")
|
raise ValueError("c'est une erreur")
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@ try:
|
||||||
tiramisu_version = 3
|
tiramisu_version = 3
|
||||||
except:
|
except:
|
||||||
tiramisu_version = 2
|
tiramisu_version = 2
|
||||||
from tiramisu.config import Config, SubConfig
|
from tiramisu import Config
|
||||||
|
from tiramisu.config import SubConfig
|
||||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption,\
|
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption,\
|
||||||
StrOption, SymLinkOption, UnicodeOption, IPOption, OptionDescription, \
|
StrOption, SymLinkOption, UnicodeOption, IPOption, OptionDescription, \
|
||||||
PortOption, NetworkOption, NetmaskOption, DomainnameOption, EmailOption, \
|
PortOption, NetworkOption, NetmaskOption, DomainnameOption, EmailOption, \
|
||||||
|
@ -149,14 +150,14 @@ def test_slots_config():
|
||||||
od1 = OptionDescription('a', '', [])
|
od1 = OptionDescription('a', '', [])
|
||||||
od2 = OptionDescription('a', '', [od1])
|
od2 = OptionDescription('a', '', [od1])
|
||||||
c = Config(od2)
|
c = Config(od2)
|
||||||
raises(AttributeError, "c.x = 1")
|
raises(AttributeError, "c._config.x = 1")
|
||||||
raises(AttributeError, "c.cfgimpl_x = 1")
|
raises(AttributeError, "c._config.cfgimpl_x = 1")
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(od2,
|
option_bag.set_option(od2,
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
ConfigBag(c))
|
ConfigBag(c._config))
|
||||||
sc = c.get_subconfig('a', option_bag)
|
sc = c._config.get_subconfig('a', option_bag)
|
||||||
assert isinstance(sc, SubConfig)
|
assert isinstance(sc, SubConfig)
|
||||||
raises(AttributeError, "sc.x = 1")
|
raises(AttributeError, "sc.x = 1")
|
||||||
raises(AttributeError, "sc.cfgimpl_x = 1")
|
raises(AttributeError, "sc.cfgimpl_x = 1")
|
||||||
|
@ -166,7 +167,7 @@ def test_slots_setting():
|
||||||
od1 = OptionDescription('a', '', [])
|
od1 = OptionDescription('a', '', [])
|
||||||
od2 = OptionDescription('a', '', [od1])
|
od2 = OptionDescription('a', '', [od1])
|
||||||
c = Config(od2)
|
c = Config(od2)
|
||||||
s = c.cfgimpl_get_settings()
|
s = c._config.cfgimpl_get_settings()
|
||||||
s
|
s
|
||||||
raises(AttributeError, "s.x = 1")
|
raises(AttributeError, "s.x = 1")
|
||||||
|
|
||||||
|
@ -175,6 +176,6 @@ def test_slots_value():
|
||||||
od1 = OptionDescription('a', '', [])
|
od1 = OptionDescription('a', '', [])
|
||||||
od2 = OptionDescription('a', '', [od1])
|
od2 = OptionDescription('a', '', [od1])
|
||||||
c = Config(od2)
|
c = Config(od2)
|
||||||
v = c.cfgimpl_get_values()
|
v = c._config.cfgimpl_get_values()
|
||||||
v
|
v
|
||||||
raises(AttributeError, "v.x = 1")
|
raises(AttributeError, "v.x = 1")
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
from tiramisu.option import BoolOption, UnicodeOption, SymLinkOption, \
|
from tiramisu.option import BoolOption, UnicodeOption, SymLinkOption, \
|
||||||
OptionDescription, DynOptionDescription
|
OptionDescription, DynOptionDescription
|
||||||
from tiramisu.config import Config
|
from tiramisu import Config
|
||||||
from pickle import dumps
|
from pickle import dumps
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
import sys
|
import sys
|
||||||
|
@ -223,7 +223,8 @@ def test_diff_information_config():
|
||||||
b.impl_set_information('info2', 'oh')
|
b.impl_set_information('info2', 'oh')
|
||||||
o = OptionDescription('o', '', [b])
|
o = OptionDescription('o', '', [b])
|
||||||
o1 = OptionDescription('o1', '', [o])
|
o1 = OptionDescription('o1', '', [o])
|
||||||
raises(NotImplementedError, "dumps(Config(o1))")
|
c = Config(o1)._config
|
||||||
|
raises(NotImplementedError, "dumps(c)")
|
||||||
|
|
||||||
|
|
||||||
def test_only_optiondescription():
|
def test_only_optiondescription():
|
||||||
|
|
|
@ -5,7 +5,7 @@ do_autopath()
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.error import ConfigError
|
from tiramisu.error import ConfigError
|
||||||
from tiramisu.config import Config
|
from tiramisu import Config
|
||||||
from tiramisu.option import BoolOption, OptionDescription, MasterSlaves
|
from tiramisu.option import BoolOption, OptionDescription, MasterSlaves
|
||||||
from tiramisu.setting import groups, owners
|
from tiramisu.setting import groups, owners
|
||||||
from tiramisu.storage import list_sessions, delete_session
|
from tiramisu.storage import list_sessions, delete_session
|
||||||
|
|
|
@ -12,11 +12,10 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
from .config import Config, MetaConfig, GroupConfig
|
|
||||||
from .function import Params, ParamOption, ParamValue, ParamContext
|
from .function import Params, ParamOption, ParamValue, ParamContext
|
||||||
from .option import *
|
from .option import *
|
||||||
from .error import APIError
|
from .error import APIError
|
||||||
from .api import getapi
|
from .api import getapi, Config, MetaConfig, GroupConfig
|
||||||
from .option import __all__ as all_options
|
from .option import __all__ as all_options
|
||||||
from .setting import owners, undefined
|
from .setting import owners, undefined
|
||||||
|
|
||||||
|
|
109
tiramisu/api.py
109
tiramisu/api.py
|
@ -23,7 +23,7 @@ from typing import List, Any, Optional, Callable, Union, Dict
|
||||||
from .error import APIError, ConfigError, SlaveError, PropertiesOptionError
|
from .error import APIError, ConfigError, SlaveError, PropertiesOptionError
|
||||||
from .i18n import _
|
from .i18n import _
|
||||||
from .setting import ConfigBag, OptionBag, owners, groups, Undefined, undefined, FORBIDDEN_SET_PROPERTIES
|
from .setting import ConfigBag, OptionBag, owners, groups, Undefined, undefined, FORBIDDEN_SET_PROPERTIES
|
||||||
from .config import Config, SubConfig, GroupConfig, MetaConfig
|
from .config import KernelConfig, SubConfig, KernelGroupConfig, KernelMetaConfig
|
||||||
from .option import ChoiceOption, OptionDescription
|
from .option import ChoiceOption, OptionDescription
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ class CommonTiramisuOption(CommonTiramisu):
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
name: str,
|
name: str,
|
||||||
subconfig: Union[Config, SubConfig],
|
subconfig: Union[KernelConfig, SubConfig],
|
||||||
option_bag: OptionBag) -> None:
|
option_bag: OptionBag) -> None:
|
||||||
self.option_bag = option_bag
|
self.option_bag = option_bag
|
||||||
self._name = name
|
self._name = name
|
||||||
|
@ -256,7 +256,7 @@ class TiramisuOptionOwner(CommonTiramisuOption):
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
name: str,
|
name: str,
|
||||||
subconfig: Union[Config, SubConfig],
|
subconfig: Union[KernelConfig, SubConfig],
|
||||||
option_bag: OptionBag) -> None:
|
option_bag: OptionBag) -> None:
|
||||||
|
|
||||||
super().__init__(name,
|
super().__init__(name,
|
||||||
|
@ -293,7 +293,7 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
name: str,
|
name: str,
|
||||||
subconfig: Union[Config, SubConfig],
|
subconfig: Union[KernelConfig, SubConfig],
|
||||||
option_bag: OptionBag) -> None:
|
option_bag: OptionBag) -> None:
|
||||||
super().__init__(name,
|
super().__init__(name,
|
||||||
subconfig,
|
subconfig,
|
||||||
|
@ -345,7 +345,7 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
name: str,
|
name: str,
|
||||||
subconfig: Union[Config, SubConfig],
|
subconfig: Union[KernelConfig, SubConfig],
|
||||||
option_bag: OptionBag) -> None:
|
option_bag: OptionBag) -> None:
|
||||||
super().__init__(name,
|
super().__init__(name,
|
||||||
subconfig,
|
subconfig,
|
||||||
|
@ -483,7 +483,7 @@ class TiramisuOption(CommonTiramisu):
|
||||||
name: Optional[str],
|
name: Optional[str],
|
||||||
path: Optional[str]=None,
|
path: Optional[str]=None,
|
||||||
index: Optional[int]=None,
|
index: Optional[int]=None,
|
||||||
subconfig: Union[None, Config, SubConfig]=None,
|
subconfig: Union[None, KernelConfig, SubConfig]=None,
|
||||||
config_bag: Optional[ConfigBag]=None,
|
config_bag: Optional[ConfigBag]=None,
|
||||||
option_bag: Optional[OptionBag]=None) -> None:
|
option_bag: Optional[OptionBag]=None) -> None:
|
||||||
self._name = name
|
self._name = name
|
||||||
|
@ -915,6 +915,34 @@ class TiramisuContextConfig(TiramisuContext):
|
||||||
else:
|
else:
|
||||||
raise APIError('not implemented yet')
|
raise APIError('not implemented yet')
|
||||||
|
|
||||||
|
def name(self):
|
||||||
|
return self.config_bag.context.impl_getname()
|
||||||
|
|
||||||
|
def duplicate(self,
|
||||||
|
session_id=None):
|
||||||
|
return TiramisuAPI(self.config_bag.context.duplicate(session_id))
|
||||||
|
|
||||||
|
def _m_new(self, name):
|
||||||
|
self.config_bag.context.new_config(name)
|
||||||
|
|
||||||
|
def _m_list(self):
|
||||||
|
return self._g_list()
|
||||||
|
|
||||||
|
def _g_list(self):
|
||||||
|
return self.config_bag.context.cfgimpl_get_children()
|
||||||
|
|
||||||
|
def __getattr__(self,
|
||||||
|
name: str) -> Callable:
|
||||||
|
if not name.startswith('_'):
|
||||||
|
try:
|
||||||
|
if isinstance(self.config_bag.context, KernelMetaConfig):
|
||||||
|
return getattr(self, '_m_' + name)
|
||||||
|
elif isinstance(self.config_bag.context, KernelGroupConfig):
|
||||||
|
return getattr(self, '_g_' + name)
|
||||||
|
except APIError:
|
||||||
|
raise APIError(_('{} is unknown').format(name))
|
||||||
|
raise APIError(_('{} is unknown').format(name))
|
||||||
|
|
||||||
|
|
||||||
class TiramisuDispatcher:
|
class TiramisuDispatcher:
|
||||||
pass
|
pass
|
||||||
|
@ -924,7 +952,7 @@ class TiramisuAPI(TiramisuHelp):
|
||||||
registers = {}
|
registers = {}
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
config: Union[Config, GroupConfig, MetaConfig, ConfigBag]) -> None:
|
config) -> None:
|
||||||
self._config = config
|
self._config = config
|
||||||
if not self.registers:
|
if not self.registers:
|
||||||
registers(self.registers, 'TiramisuContext')
|
registers(self.registers, 'TiramisuContext')
|
||||||
|
@ -967,7 +995,7 @@ class TiramisuAPI(TiramisuHelp):
|
||||||
|
|
||||||
class TiramisuDispatcherConfig(TiramisuDispatcher, TiramisuContextConfig):
|
class TiramisuDispatcherConfig(TiramisuDispatcher, TiramisuContextConfig):
|
||||||
def __call__(self,
|
def __call__(self,
|
||||||
path: Optional[str]) -> TiramisuAPI:
|
path: Optional[str]):
|
||||||
"""select a child Tiramisu configuration (only with MetaConfig or GroupConfig)"""
|
"""select a child Tiramisu configuration (only with MetaConfig or GroupConfig)"""
|
||||||
if path is None:
|
if path is None:
|
||||||
return TiramisuAPI(self.config_bag)
|
return TiramisuAPI(self.config_bag)
|
||||||
|
@ -996,10 +1024,65 @@ class TiramisuDispatcherOption(TiramisuDispatcher, TiramisuContextOption):
|
||||||
self.config_bag)
|
self.config_bag)
|
||||||
|
|
||||||
|
|
||||||
def getapi(config: Union[Config, GroupConfig, MetaConfig]):
|
class Config(TiramisuAPI):
|
||||||
"""instanciate TiramisuAPI
|
def __init__(self,
|
||||||
|
descr: OptionDescription,
|
||||||
|
session_id: str=None,
|
||||||
|
persistent: bool=False,
|
||||||
|
storage=None) -> None:
|
||||||
|
if not isinstance(descr, KernelConfig):
|
||||||
|
config = KernelConfig(descr,
|
||||||
|
session_id=session_id,
|
||||||
|
persistent=persistent,
|
||||||
|
storage=storage)
|
||||||
|
else:
|
||||||
|
config = descr
|
||||||
|
super().__init__(config)
|
||||||
|
|
||||||
:param config: Config object
|
|
||||||
:type descr: an instance of ``config.Config``
|
|
||||||
|
class MetaConfig(TiramisuAPI):
|
||||||
|
def __init__(self,
|
||||||
|
children,
|
||||||
|
session_id: Union[str, None]=None,
|
||||||
|
persistent: bool=False,
|
||||||
|
optiondescription: Union[OptionDescription, None]=None) -> None:
|
||||||
|
_children = []
|
||||||
|
for child in children:
|
||||||
|
if isinstance(child, TiramisuAPI):
|
||||||
|
_children.append(child._config)
|
||||||
|
else:
|
||||||
|
_children.append(child)
|
||||||
|
|
||||||
|
config = KernelMetaConfig(_children,
|
||||||
|
session_id=session_id,
|
||||||
|
persistent=persistent,
|
||||||
|
optiondescription=optiondescription)
|
||||||
|
super().__init__(config)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GroupConfig(TiramisuAPI):
|
||||||
|
def __init__(self,
|
||||||
|
children,
|
||||||
|
session_id: Union[str, None]=None,
|
||||||
|
persistent: bool=False,
|
||||||
|
storage=None) -> None:
|
||||||
|
_children = []
|
||||||
|
for child in children:
|
||||||
|
_children.append(child._config)
|
||||||
|
|
||||||
|
config = KernelGroupConfig(_children,
|
||||||
|
session_id=session_id,
|
||||||
|
persistent=persistent,
|
||||||
|
storage=storage)
|
||||||
|
super().__init__(config)
|
||||||
|
|
||||||
|
|
||||||
|
def getapi(config: Config):
|
||||||
|
"""instanciate Config
|
||||||
|
|
||||||
|
:param config: KernelConfig object
|
||||||
|
:type descr: an instance of ``config.KernelConfig``
|
||||||
"""
|
"""
|
||||||
return TiramisuAPI(config)
|
return config
|
||||||
|
|
|
@ -93,7 +93,7 @@ def manager_callback(callbk: Union[ParamOption, ParamValue],
|
||||||
return value[index]
|
return value[index]
|
||||||
return value
|
return value
|
||||||
except PropertiesOptionError as err:
|
except PropertiesOptionError as err:
|
||||||
if callbk.notraiseproperty:
|
if callbk.notraisepropertyerror:
|
||||||
raise err
|
raise err
|
||||||
raise ConfigError(_('unable to carry out a calculation for "{}"'
|
raise ConfigError(_('unable to carry out a calculation for "{}"'
|
||||||
', {}').format(option.impl_get_display_name(), err))
|
', {}').format(option.impl_get_display_name(), err))
|
||||||
|
|
|
@ -602,7 +602,7 @@ class SubConfig(object):
|
||||||
|
|
||||||
|
|
||||||
class _CommonConfig(SubConfig):
|
class _CommonConfig(SubConfig):
|
||||||
"abstract base class for the Config, GroupConfig and the MetaConfig"
|
"abstract base class for the Config, KernelGroupConfig and the KernelMetaConfig"
|
||||||
__slots__ = ('_impl_values',
|
__slots__ = ('_impl_values',
|
||||||
'_impl_settings',
|
'_impl_settings',
|
||||||
'_impl_meta')
|
'_impl_meta')
|
||||||
|
@ -644,10 +644,10 @@ class _CommonConfig(SubConfig):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def _gen_fake_values(self):
|
def _gen_fake_values(self):
|
||||||
fake_config = Config(self._impl_descr,
|
fake_config = KernelConfig(self._impl_descr,
|
||||||
persistent=False,
|
persistent=False,
|
||||||
force_values=get_default_values_storages(),
|
force_values=get_default_values_storages(),
|
||||||
force_settings=self.cfgimpl_get_settings())
|
force_settings=self.cfgimpl_get_settings())
|
||||||
fake_config.cfgimpl_get_values()._p_.importation(self.cfgimpl_get_values()._p_.exportation())
|
fake_config.cfgimpl_get_values()._p_.importation(self.cfgimpl_get_values()._p_.exportation())
|
||||||
return fake_config
|
return fake_config
|
||||||
|
|
||||||
|
@ -656,12 +656,12 @@ class _CommonConfig(SubConfig):
|
||||||
force_values=None,
|
force_values=None,
|
||||||
force_settings=None,
|
force_settings=None,
|
||||||
storage=None):
|
storage=None):
|
||||||
config = Config(self._impl_descr,
|
config = KernelConfig(self._impl_descr,
|
||||||
_duplicate=True,
|
_duplicate=True,
|
||||||
session_id=session_id,
|
session_id=session_id,
|
||||||
force_values=force_values,
|
force_values=force_values,
|
||||||
force_settings=force_settings,
|
force_settings=force_settings,
|
||||||
storage=storage)
|
storage=storage)
|
||||||
config.cfgimpl_get_values()._p_.importation(self.cfgimpl_get_values()._p_.exportation())
|
config.cfgimpl_get_values()._p_.importation(self.cfgimpl_get_values()._p_.exportation())
|
||||||
config.cfgimpl_get_settings()._p_.importation(self.cfgimpl_get_settings(
|
config.cfgimpl_get_settings()._p_.importation(self.cfgimpl_get_settings(
|
||||||
)._p_.exportation())
|
)._p_.exportation())
|
||||||
|
@ -671,7 +671,7 @@ class _CommonConfig(SubConfig):
|
||||||
|
|
||||||
|
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
class Config(_CommonConfig):
|
class KernelConfig(_CommonConfig):
|
||||||
"main configuration management entry"
|
"main configuration management entry"
|
||||||
__slots__ = ('__weakref__', '_impl_name')
|
__slots__ = ('__weakref__', '_impl_name')
|
||||||
|
|
||||||
|
@ -721,10 +721,10 @@ class Config(_CommonConfig):
|
||||||
permissives)
|
permissives)
|
||||||
self._impl_values = Values(self,
|
self._impl_values = Values(self,
|
||||||
values)
|
values)
|
||||||
super(Config, self).__init__(descr,
|
super(KernelConfig, self).__init__(descr,
|
||||||
weakref.ref(self),
|
weakref.ref(self),
|
||||||
ConfigBag(self),
|
ConfigBag(self),
|
||||||
None)
|
None)
|
||||||
if _duplicate is False and (force_settings is None or force_values is None):
|
if _duplicate is False and (force_settings is None or force_values is None):
|
||||||
self._impl_build_all_caches()
|
self._impl_build_all_caches()
|
||||||
self._impl_name = session_id
|
self._impl_name = session_id
|
||||||
|
@ -736,7 +736,7 @@ class Config(_CommonConfig):
|
||||||
return self._impl_values._p_._storage.session_id
|
return self._impl_values._p_._storage.session_id
|
||||||
|
|
||||||
|
|
||||||
class GroupConfig(_CommonConfig):
|
class KernelGroupConfig(_CommonConfig):
|
||||||
__slots__ = ('__weakref__',
|
__slots__ = ('__weakref__',
|
||||||
'_impl_children',
|
'_impl_children',
|
||||||
'_impl_name')
|
'_impl_name')
|
||||||
|
@ -753,7 +753,10 @@ class GroupConfig(_CommonConfig):
|
||||||
for child in children:
|
for child in children:
|
||||||
if not isinstance(child,
|
if not isinstance(child,
|
||||||
_CommonConfig):
|
_CommonConfig):
|
||||||
raise ValueError(_("groupconfig's children must be Config, MetaConfig or GroupConfig"))
|
try:
|
||||||
|
child = child._config
|
||||||
|
except:
|
||||||
|
raise ValueError(_("groupconfig's children must be Config, MetaConfig or GroupConfig"))
|
||||||
name_ = child._impl_name
|
name_ = child._impl_name
|
||||||
names.append(name_)
|
names.append(name_)
|
||||||
if len(names) != len(set(names)):
|
if len(names) != len(set(names)):
|
||||||
|
@ -772,7 +775,7 @@ class GroupConfig(_CommonConfig):
|
||||||
permissives)
|
permissives)
|
||||||
self._impl_values = Values(self, values)
|
self._impl_values = Values(self, values)
|
||||||
self._impl_meta = None
|
self._impl_meta = None
|
||||||
super(GroupConfig, self).__init__(_descr,
|
super(KernelGroupConfig, self).__init__(_descr,
|
||||||
weakref.ref(self),
|
weakref.ref(self),
|
||||||
ConfigBag(self),
|
ConfigBag(self),
|
||||||
None)
|
None)
|
||||||
|
@ -787,8 +790,8 @@ class GroupConfig(_CommonConfig):
|
||||||
resetted_opts=None):
|
resetted_opts=None):
|
||||||
if resetted_opts is None:
|
if resetted_opts is None:
|
||||||
resetted_opts = []
|
resetted_opts = []
|
||||||
if isinstance(self, MetaConfig):
|
if isinstance(self, KernelMetaConfig):
|
||||||
super(GroupConfig, self).cfgimpl_reset_cache(option_bag,
|
super(KernelGroupConfig, self).cfgimpl_reset_cache(option_bag,
|
||||||
resetted_opts=copy(resetted_opts))
|
resetted_opts=copy(resetted_opts))
|
||||||
for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
child.cfgimpl_reset_cache(option_bag,
|
child.cfgimpl_reset_cache(option_bag,
|
||||||
|
@ -801,14 +804,14 @@ class GroupConfig(_CommonConfig):
|
||||||
config_bag,
|
config_bag,
|
||||||
only_config=False,
|
only_config=False,
|
||||||
_commit=True):
|
_commit=True):
|
||||||
"""Setattr not in current GroupConfig, but in each children
|
"""Setattr not in current KernelGroupConfig, but in each children
|
||||||
"""
|
"""
|
||||||
ret = []
|
ret = []
|
||||||
for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
cconfig_bag = config_bag.copy()
|
cconfig_bag = config_bag.copy()
|
||||||
cconfig_bag.context = child
|
cconfig_bag.context = child
|
||||||
try:
|
try:
|
||||||
if isinstance(child, GroupConfig):
|
if isinstance(child, KernelGroupConfig):
|
||||||
ret.extend(child.set_value(path,
|
ret.extend(child.set_value(path,
|
||||||
index,
|
index,
|
||||||
value,
|
value,
|
||||||
|
@ -852,13 +855,13 @@ class GroupConfig(_CommonConfig):
|
||||||
byvalue=undefined,
|
byvalue=undefined,
|
||||||
raise_if_not_found=True,
|
raise_if_not_found=True,
|
||||||
_sub=False):
|
_sub=False):
|
||||||
"""Find first not in current GroupConfig, but in each children
|
"""Find first not in current KernelGroupConfig, but in each children
|
||||||
"""
|
"""
|
||||||
#if MetaConfig, all children have same OptionDescription in context
|
#if KernelMetaConfig, all children have same OptionDescription in context
|
||||||
#so search only one time the option for all children
|
#so search only one time the option for all children
|
||||||
if bypath is undefined and byname is not None and \
|
if bypath is undefined and byname is not None and \
|
||||||
isinstance(self,
|
isinstance(self,
|
||||||
MetaConfig):
|
KernelMetaConfig):
|
||||||
bypath = next(self.find(bytype=None,
|
bypath = next(self.find(bytype=None,
|
||||||
byvalue=undefined,
|
byvalue=undefined,
|
||||||
byname=byname,
|
byname=byname,
|
||||||
|
@ -869,7 +872,7 @@ class GroupConfig(_CommonConfig):
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
if isinstance(child, GroupConfig):
|
if isinstance(child, KernelGroupConfig):
|
||||||
ret.extend(child.find_firsts(byname=byname,
|
ret.extend(child.find_firsts(byname=byname,
|
||||||
bypath=bypath,
|
bypath=bypath,
|
||||||
byoption=byoption,
|
byoption=byoption,
|
||||||
|
@ -894,7 +897,7 @@ class GroupConfig(_CommonConfig):
|
||||||
else:
|
else:
|
||||||
self._find_return_results(ret != [],
|
self._find_return_results(ret != [],
|
||||||
raise_if_not_found)
|
raise_if_not_found)
|
||||||
return GroupConfig(ret)
|
return KernelGroupConfig(ret)
|
||||||
|
|
||||||
def impl_getname(self):
|
def impl_getname(self):
|
||||||
return self._impl_name
|
return self._impl_name
|
||||||
|
@ -907,7 +910,7 @@ class GroupConfig(_CommonConfig):
|
||||||
raise ConfigError(_('unknown config "{}"').format(name))
|
raise ConfigError(_('unknown config "{}"').format(name))
|
||||||
|
|
||||||
|
|
||||||
class MetaConfig(GroupConfig):
|
class KernelMetaConfig(KernelGroupConfig):
|
||||||
__slots__ = tuple()
|
__slots__ = tuple()
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
@ -919,15 +922,18 @@ class MetaConfig(GroupConfig):
|
||||||
if optiondescription is not None:
|
if optiondescription is not None:
|
||||||
new_children = []
|
new_children = []
|
||||||
for child_session_id in children:
|
for child_session_id in children:
|
||||||
new_children.append(Config(optiondescription,
|
new_children.append(KernelConfig(optiondescription,
|
||||||
persistent=persistent,
|
persistent=persistent,
|
||||||
session_id=child_session_id))
|
session_id=child_session_id))
|
||||||
children = new_children
|
children = new_children
|
||||||
for child in children:
|
for child in children:
|
||||||
if not isinstance(child, _CommonConfig):
|
if not isinstance(child, _CommonConfig):
|
||||||
raise TypeError(_("metaconfig's children "
|
try:
|
||||||
"should be config, not {0}"
|
child = child._config
|
||||||
).format(type(child)))
|
except:
|
||||||
|
raise TypeError(_("metaconfig's children "
|
||||||
|
"should be config, not {0}"
|
||||||
|
).format(type(child)))
|
||||||
if child.cfgimpl_get_meta() is not None:
|
if child.cfgimpl_get_meta() is not None:
|
||||||
raise ValueError(_("child has already a metaconfig's"))
|
raise ValueError(_("child has already a metaconfig's"))
|
||||||
if descr is None:
|
if descr is None:
|
||||||
|
@ -937,10 +943,10 @@ class MetaConfig(GroupConfig):
|
||||||
'have the same optiondescription'))
|
'have the same optiondescription'))
|
||||||
child._impl_meta = weakref.ref(self)
|
child._impl_meta = weakref.ref(self)
|
||||||
|
|
||||||
super(MetaConfig, self).__init__(children,
|
super(KernelMetaConfig, self).__init__(children,
|
||||||
session_id,
|
session_id,
|
||||||
persistent,
|
persistent,
|
||||||
descr)
|
descr)
|
||||||
|
|
||||||
def set_value(self,
|
def set_value(self,
|
||||||
path,
|
path,
|
||||||
|
@ -953,19 +959,19 @@ class MetaConfig(GroupConfig):
|
||||||
only_config=False,
|
only_config=False,
|
||||||
_commit=True):
|
_commit=True):
|
||||||
"""only_config: could be set if you want modify value in all Config included in
|
"""only_config: could be set if you want modify value in all Config included in
|
||||||
this MetaConfig
|
this KernelMetaConfig
|
||||||
"""
|
"""
|
||||||
if only_config:
|
if only_config:
|
||||||
if force_default or force_default_if_same or force_dont_change_value:
|
if force_default or force_default_if_same or force_dont_change_value:
|
||||||
raise ValueError(_('force_default, force_default_if_same or '
|
raise ValueError(_('force_default, force_default_if_same or '
|
||||||
'force_dont_change_value cannot be set with'
|
'force_dont_change_value cannot be set with'
|
||||||
' only_config'))
|
' only_config'))
|
||||||
return super(MetaConfig, self).set_value(path,
|
return super(KernelMetaConfig, self).set_value(path,
|
||||||
index,
|
index,
|
||||||
value,
|
value,
|
||||||
config_bag,
|
config_bag,
|
||||||
only_config=only_config,
|
only_config=only_config,
|
||||||
_commit=_commit)
|
_commit=_commit)
|
||||||
ret = []
|
ret = []
|
||||||
if force_default or force_default_if_same or force_dont_change_value:
|
if force_default or force_default_if_same or force_dont_change_value:
|
||||||
if force_default and force_dont_change_value:
|
if force_default and force_dont_change_value:
|
||||||
|
@ -1047,9 +1053,9 @@ class MetaConfig(GroupConfig):
|
||||||
def new_config(self,
|
def new_config(self,
|
||||||
session_id,
|
session_id,
|
||||||
persistent=False):
|
persistent=False):
|
||||||
config = Config(self._impl_descr,
|
config = KernelConfig(self._impl_descr,
|
||||||
session_id=session_id,
|
session_id=session_id,
|
||||||
persistent=persistent)
|
persistent=persistent)
|
||||||
|
|
||||||
if config._impl_name in [child._impl_name for child in self._impl_children]: # pragma: no cover
|
if config._impl_name in [child._impl_name for child in self._impl_children]: # pragma: no cover
|
||||||
raise ConflictError(_('config name must be uniq in '
|
raise ConflictError(_('config name must be uniq in '
|
||||||
|
|
|
@ -162,7 +162,7 @@ class ValueWarning(UserWarning): # pragma: optional cover
|
||||||
>>> import warnings
|
>>> import warnings
|
||||||
>>> from tiramisu.error import ValueWarning
|
>>> from tiramisu.error import ValueWarning
|
||||||
>>> from tiramisu.option import StrOption, OptionDescription
|
>>> from tiramisu.option import StrOption, OptionDescription
|
||||||
>>> from tiramisu.config import Config
|
>>> from tiramisu import Config
|
||||||
>>> warnings.simplefilter("always", ValueWarning)
|
>>> warnings.simplefilter("always", ValueWarning)
|
||||||
>>> def a(val):
|
>>> def a(val):
|
||||||
... raise ValueError('pouet')
|
... raise ValueError('pouet')
|
||||||
|
|
|
@ -58,7 +58,7 @@ class ParamOption(Param):
|
||||||
).format(type(notraisepropertyerror)))
|
).format(type(notraisepropertyerror)))
|
||||||
|
|
||||||
self.option = cur_opt
|
self.option = cur_opt
|
||||||
self.notraiseproperty = notraisepropertyerror
|
self.notraisepropertyerror = notraisepropertyerror
|
||||||
|
|
||||||
|
|
||||||
class ParamValue(Param):
|
class ParamValue(Param):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from .syndynoptiondescription import SynDynOptionDescription
|
||||||
from .masterslave import MasterSlaves
|
from .masterslave import MasterSlaves
|
||||||
from .baseoption import submulti
|
from .baseoption import submulti
|
||||||
from .symlinkoption import SymLinkOption, DynSymLinkOption
|
from .symlinkoption import SymLinkOption, DynSymLinkOption
|
||||||
from .option import Option
|
from .option import Option, RegexpOption
|
||||||
from .choiceoption import ChoiceOption
|
from .choiceoption import ChoiceOption
|
||||||
from .booloption import BoolOption
|
from .booloption import BoolOption
|
||||||
from .intoption import IntOption
|
from .intoption import IntOption
|
||||||
|
@ -30,4 +30,4 @@ __all__ = ('MasterSlaves', 'OptionDescription', 'DynOptionDescription',
|
||||||
'IntOption', 'FloatOption', 'StrOption', 'UnicodeOption',
|
'IntOption', 'FloatOption', 'StrOption', 'UnicodeOption',
|
||||||
'IPOption', 'PortOption', 'NetworkOption', 'NetmaskOption',
|
'IPOption', 'PortOption', 'NetworkOption', 'NetmaskOption',
|
||||||
'BroadcastOption', 'DomainnameOption', 'EmailOption', 'URLOption',
|
'BroadcastOption', 'DomainnameOption', 'EmailOption', 'URLOption',
|
||||||
'UsernameOption', 'FilenameOption', 'PasswordOption', 'submulti')
|
'UsernameOption', 'FilenameOption', 'PasswordOption', 'submulti', 'RegexpOption')
|
||||||
|
|
Loading…
Reference in a new issue