Return Config not TiramisuAPI

This commit is contained in:
Emmanuel Garette 2018-09-06 19:28:04 +02:00
parent 1ef82af5d1
commit d61d1c2931
2 changed files with 13 additions and 7 deletions

View File

@ -199,8 +199,8 @@ def test_meta_meta_set():
errors2 = meta.value.set('od1.i6', 7, only_config=True)
assert len(errors1) == 0
assert len(errors2) == 2
conf1 = meta.config('meta.conf1')._config.context
conf2 = meta.config('meta.conf2')._config.context
conf1 = meta.config('meta.conf1')._config
conf2 = meta.config('meta.conf2')._config
assert meta.config('meta.conf1').option('od1.i1').value.get() == meta.config('meta.conf2').option('od1.i1').value.get() == 7
#
dconfigs = []
@ -577,6 +577,8 @@ def test_meta_properties_meta():
od = OptionDescription('root', '', [interface1])
conf1 = Config(od, session_id='conf1')
conf2 = Config(od, session_id='conf2')
conf1.property.read_write()
conf2.property.read_write()
meta = MetaConfig([conf1, conf2])
meta.property.read_write()
assert meta.config('conf1').config.dict() == {}
@ -696,6 +698,8 @@ def test_meta_properties_meta_copy():
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
conf1 = Config(interface1, session_id='conf1')
conf2 = Config(interface1, session_id='conf2')
conf1.property.read_write()
conf2.property.read_write()
meta = MetaConfig([conf1, conf2])
meta.property.read_write()
@ -723,6 +727,8 @@ def test_meta_properties_meta_deepcopy():
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
conf1 = Config(interface1, session_id='conf1')
conf2 = Config(interface1, session_id='conf2')
conf1.property.read_write()
conf2.property.read_write()
meta = MetaConfig([conf1, conf2])
meta.permissive.set(frozenset({'hidden'}))
meta.property.read_write()
@ -750,6 +756,8 @@ def test_meta_properties_meta_set_value():
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
conf1 = Config(interface1, session_id='conf1')
conf2 = Config(interface1, session_id='conf2')
conf1.property.read_write()
conf2.property.read_write()
meta = MetaConfig([conf1, conf2])
meta.property.read_write()
assert meta.config('conf1').config.dict() == {'ip_admin_eth0': ['192.168.1.1']}

View File

@ -1019,14 +1019,12 @@ class TiramisuDispatcherConfig(TiramisuDispatcher, TiramisuContextConfig):
path: Optional[str]):
"""select a child Tiramisu configuration (only with MetaConfig or GroupConfig)"""
if path is None:
return TiramisuAPI(self.config_bag)
return Config(self.config_bag)
spaths = path.split('.')
config = self.config_bag.context
for spath in spaths:
config = config.getconfig(spath)
config_bag = self.config_bag.copy()
config_bag.context = config
return TiramisuAPI(config_bag)
return Config(config)
class TiramisuDispatcherOption(TiramisuDispatcher, TiramisuContextOption):
@ -1050,7 +1048,7 @@ class Config(TiramisuAPI):
session_id: str=None,
persistent: bool=False,
storage=None) -> None:
if not isinstance(descr, KernelConfig):
if not isinstance(descr, (KernelConfig, KernelMetaConfig)):
config = KernelConfig(descr,
session_id=session_id,
persistent=persistent,