From 688525f98ecd9d779081d823606985d48eb3e4ec Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sun, 10 Feb 2019 21:14:32 +0100 Subject: [PATCH] add cfg.cache.reset --- test/test_cache.py | 4 ++-- test/test_metaconfig.py | 2 -- tiramisu/api.py | 5 +++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/test/test_cache.py b/test/test_cache.py index a821a89..cb1c8fc 100644 --- a/test/test_cache.py +++ b/test/test_cache.py @@ -219,7 +219,7 @@ def test_reset_cache(): cfg.option('u1').value.get() assert 'u1' in values._p_.get_cached() assert 'u1' in settings._p_.get_cached() - cfg._config_bag.context.cfgimpl_reset_cache(None, None) + cfg.cache.reset() assert 'u1' not in values._p_.get_cached() assert 'u1' not in settings._p_.get_cached() cfg.option('u1').value.get() @@ -231,7 +231,7 @@ def test_reset_cache(): assert 'u1' in settings._p_.get_cached() assert 'u2' in values._p_.get_cached() assert 'u2' in settings._p_.get_cached() - cfg._config_bag.context.cfgimpl_reset_cache(None, None) + cfg.cache.reset() assert 'u1' not in values._p_.get_cached() assert 'u1' not in settings._p_.get_cached() assert 'u2' not in values._p_.get_cached() diff --git a/test/test_metaconfig.py b/test/test_metaconfig.py index 3b435a8..f29bb22 100644 --- a/test/test_metaconfig.py +++ b/test/test_metaconfig.py @@ -701,8 +701,6 @@ def test_meta_properties_requires_mandatory(): meta.option('ip_gw').value.set('1.1.1.2') conf1.option('eth0_method').value.set('dhcp') conf1.property.read_only() - meta._config_bag.context.cfgimpl_reset_cache(None, None) - conf1._config_bag.context.cfgimpl_reset_cache(None, None) assert conf1.value.dict(fullpath=True) == {'probes': True, 'eth0_method': 'dhcp', 'ip_address': '1.1.1.1', 'ip_eth0': '1.1.1.1', 'ip_gw': '1.1.1.2'} diff --git a/tiramisu/api.py b/tiramisu/api.py index a2e8366..aa53a99 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -1227,6 +1227,11 @@ class _TiramisuContextMetaConfig(_TiramisuContextGroupConfig, _TiramisuContextCo return Config(self._config_bag.context.pop_config(session_id=session_id)) +class TiramisuContextCache(TiramisuContext): + def reset(self): + self._config_bag.context.cfgimpl_reset_cache(None, None) + + class TiramisuDispatcher: pass