remove cache when import data

This commit is contained in:
Emmanuel Garette 2018-04-27 14:20:12 +02:00
parent b442d52289
commit a9919e438b
2 changed files with 41 additions and 2 deletions

View file

@ -60,6 +60,42 @@ def test_cache():
assert 'u2' in settings._p_.get_cached()
def test_cache_importation():
od1 = make_description()
api = getapi(Config(od1))
api.option('u2').value.set(1)
export = api.value.exportation()
assert api.option.make_dict() == {'u1': [], 'u2': 1, 'u3': []}
api.option('u2').value.set(2)
assert api.option.make_dict() == {'u1': [], 'u2': 2, 'u3': []}
api.value.importation(export)
assert api.option.make_dict() == {'u1': [], 'u2': 1, 'u3': []}
def test_cache_importation_property():
od1 = make_description()
api = getapi(Config(od1))
api.option('u2').property.add('prop')
export = api.property.exportation()
assert api.option('u2').property.get() == {'prop'}
api.option('u2').property.add('prop2')
assert api.option('u2').property.get() == {'prop', 'prop2'}
api.property.importation(export)
assert api.option('u2').property.get() == {'prop'}
def test_cache_importation_permissive():
od1 = make_description()
api = getapi(Config(od1))
api.option('u2').permissive.set(frozenset(['prop']))
export = api.permissive.exportation()
assert api.option('u2').permissive.get() == {'prop'}
api.option('u2').permissive.set(frozenset(['prop', 'prop2']))
assert api.option('u2').permissive.get() == {'prop', 'prop2'}
api.permissive.importation(export)
assert api.option('u2').permissive.get() == {'prop'}
#def test_get_cache():
# # force a value in cache, try if reget corrupted value
# od1 = make_description()

View file

@ -773,7 +773,8 @@ class TiramisuContextValue(TiramisuContext):
@count
def importation(self, values):
"""import values"""
return self.config_bag.config.cfgimpl_get_values()._p_.importation(values)
self.config_bag.config.cfgimpl_get_values()._p_.importation(values)
self.config_bag.config.cfgimpl_reset_cache(None, None, None)
class TiramisuContextOwner(TiramisuContext):
@ -855,7 +856,8 @@ class TiramisuContextProperty(TiramisuContext):
@count
def importation(self, properties):
"""import configuration properties"""
return self.config_bag.config.cfgimpl_get_settings()._p_.importation(properties)
self.config_bag.config.cfgimpl_get_settings()._p_.importation(properties)
self.config_bag.config.cfgimpl_reset_cache(None, None, None)
class TiramisuContextPermissive(TiramisuContext):
@ -880,6 +882,7 @@ class TiramisuContextPermissive(TiramisuContext):
def importation(self, permissives):
"""import configuration permissives"""
self.config_bag.config.cfgimpl_get_settings()._pp_.importation(permissives)
self.config_bag.config.cfgimpl_reset_cache(None, None, None)