can remove config from a metaconfig
This commit is contained in:
parent
ccf3f0ae06
commit
620eaa6461
|
@ -1,3 +1,7 @@
|
|||
Sat Sep 8 22:54:12 2018 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||
* propose a new API to access to Tiramisu Option
|
||||
This new API is totally incompatible with older's one
|
||||
|
||||
Sat Jul 8 15:57:13 2017 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||
* better cache, only remove value/property from cache for value
|
||||
modified and for all value affected by this modification
|
||||
|
|
|
@ -185,6 +185,17 @@ def test_meta_new_config():
|
|||
assert len(list(meta.config.list())) == 3
|
||||
|
||||
|
||||
def test_meta_pop_config():
|
||||
od = make_description()
|
||||
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
||||
assert len(list(meta.config.list())) == 2
|
||||
meta.config.new('newconf1')
|
||||
assert len(list(meta.config.list())) == 3
|
||||
meta.config.pop('newconf1')
|
||||
assert len(list(meta.config.list())) == 2
|
||||
raises(ConfigError, "meta.config.pop('newconf1')")
|
||||
|
||||
|
||||
def test_meta_new_config_wrong_name():
|
||||
od = make_description()
|
||||
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
||||
|
|
|
@ -1002,6 +1002,10 @@ class TiramisuContextConfig(TiramisuContext):
|
|||
persistent=False):
|
||||
return Config(self.config_bag.context.new_config(session_id=session_id, persistent=persistent))
|
||||
|
||||
def _m_pop(self,
|
||||
session_id):
|
||||
return Config(self.config_bag.context.pop_config(session_id=session_id))
|
||||
|
||||
def _m_list(self):
|
||||
return self._g_list()
|
||||
|
||||
|
|
|
@ -1140,3 +1140,10 @@ class KernelMetaConfig(KernelGroupConfig):
|
|||
config._impl_meta = weakref.ref(self)
|
||||
self._impl_children.append(config)
|
||||
return config
|
||||
|
||||
def pop_config(self,
|
||||
session_id):
|
||||
for idx, child in enumerate(self._impl_children): # pragma: no cover
|
||||
if session_id == child._impl_name:
|
||||
return self._impl_children.pop(idx)
|
||||
raise ConfigError(_('cannot find the config {}').format(session_id))
|
||||
|
|
Loading…
Reference in New Issue