This commit is contained in:
Emmanuel Garette 2019-02-23 22:52:06 +01:00
parent e6f58153ef
commit b5497ab517
7 changed files with 51 additions and 109 deletions

View file

@ -5,10 +5,9 @@ do_autopath()
from py.test import raises from py.test import raises
from tiramisu.error import ConfigError from tiramisu.error import ConfigError
from tiramisu import Config from tiramisu import Config, BoolOption, OptionDescription, Leadership, \
from tiramisu.option import BoolOption, OptionDescription, Leadership list_sessions, delete_session, default_storage
from tiramisu.setting import groups, owners from tiramisu.setting import groups, owners
from tiramisu.storage import list_sessions, delete_session
def teardown_function(function): def teardown_function(function):
@ -31,13 +30,10 @@ def test_list():
assert 'test_non_persistent' not in list_sessions() assert 'test_non_persistent' not in list_sessions()
def test_delete_not_persisten(): def test_delete_not_persistent():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if not default_storage.is_persistent():
Config(o, session_id='test_persistent', persistent=True)
delete_session('test_persistent')
except:
c = Config(o, session_id='not_test_persistent') c = Config(o, session_id='not_test_persistent')
assert 'not_test_persistent' in list_sessions() assert 'not_test_persistent' in list_sessions()
del c del c
@ -50,34 +46,24 @@ def test_delete_not_persisten():
def test_create_persistent(): def test_create_persistent():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
Config(o, session_id='test_persistent', persistent=True) Config(o, session_id='test_persistent', persistent=True)
delete_session('test_persistent') delete_session('test_persistent')
except ValueError:
# storage is not persistent
pass
def test_create_delete_not_persistent(): def test_create_delete_not_persistent():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if not default_storage.is_persistent():
Config(o, session_id='test_persistent', persistent=True)
delete_session('test_persistent')
except ValueError:
raises(ValueError, "delete_session('test_persistent')") raises(ValueError, "delete_session('test_persistent')")
def test_list_sessions_persistent(): def test_list_sessions_persistent():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
c = Config(o, session_id='test_persistent', persistent=True) c = Config(o, session_id='test_persistent', persistent=True)
c.option('b').value.set(True) c.option('b').value.set(True)
except ValueError:
# storage is not persistent
pass
else:
assert 'test_persistent' in list_sessions() assert 'test_persistent' in list_sessions()
delete_session('test_persistent') delete_session('test_persistent')
@ -85,12 +71,8 @@ def test_list_sessions_persistent():
def test_delete_session_persistent(): def test_delete_session_persistent():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
Config(o, session_id='test_persistent', persistent=True) Config(o, session_id='test_persistent', persistent=True)
except ValueError:
# storage is not persistent
pass
else:
assert 'test_persistent' in list_sessions() assert 'test_persistent' in list_sessions()
delete_session('test_persistent') delete_session('test_persistent')
assert 'test_persistent' not in list_sessions() assert 'test_persistent' not in list_sessions()
@ -99,12 +81,8 @@ def test_delete_session_persistent():
def test_create_persistent_retrieve(): def test_create_persistent_retrieve():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
c = Config(o, session_id='test_persistent', persistent=True) c = Config(o, session_id='test_persistent', persistent=True)
except ValueError:
# storage is not persistent
pass
else:
assert c.option('b').value.get() is None assert c.option('b').value.get() is None
c.option('b').value.set(True) c.option('b').value.set(True)
assert c.option('b').value.get() is True assert c.option('b').value.get() is True
@ -123,12 +101,8 @@ def test_create_persistent_retrieve():
def test_two_persistent(): def test_two_persistent():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
c = Config(o, session_id='test_persistent', persistent=True) c = Config(o, session_id='test_persistent', persistent=True)
except ValueError:
# storage is not persistent
pass
else:
c2 = Config(o, session_id='test_persistent', persistent=True) c2 = Config(o, session_id='test_persistent', persistent=True)
c2.property.pop('cache') c2.property.pop('cache')
assert c.option('b').value.get() is None assert c.option('b').value.get() is None
@ -147,12 +121,8 @@ def test_two_persistent():
def test_create_persistent_retrieve_owner(): def test_create_persistent_retrieve_owner():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
c = Config(o, session_id='test_persistent', persistent=True) c = Config(o, session_id='test_persistent', persistent=True)
except ValueError:
# storage is not persistent
pass
else:
assert c.option('b').owner.isdefault() assert c.option('b').owner.isdefault()
c.option('b').value.set(True) c.option('b').value.set(True)
assert c.option('b').value.get() assert c.option('b').value.get()
@ -179,12 +149,8 @@ def test_create_persistent_retrieve_owner_leadership():
b = BoolOption('b', '', multi=True) b = BoolOption('b', '', multi=True)
o = Leadership('a', '', [a, b]) o = Leadership('a', '', [a, b])
o1 = OptionDescription('a', '', [o]) o1 = OptionDescription('a', '', [o])
try: if default_storage.is_persistent():
c = Config(o1, session_id='test_persistent', persistent=True) c = Config(o1, session_id='test_persistent', persistent=True)
except ValueError:
# storage is not persistent
pass
else:
assert c.option('a.a').owner.isdefault() assert c.option('a.a').owner.isdefault()
c.option('a.a').value.set([True, False]) c.option('a.a').value.set([True, False])
c.option('a.b', 1).value.set(True) c.option('a.b', 1).value.set(True)
@ -215,13 +181,9 @@ def test_create_persistent_retrieve_owner_leadership():
def test_two_persistent_owner(): def test_two_persistent_owner():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
c = Config(o, session_id='test_persistent', persistent=True) c = Config(o, session_id='test_persistent', persistent=True)
c.property.pop('cache') c.property.pop('cache')
except ValueError:
# storage is not persistent
pass
else:
c2 = Config(o, session_id='test_persistent', persistent=True) c2 = Config(o, session_id='test_persistent', persistent=True)
c2.property.pop('cache') c2.property.pop('cache')
assert c.option('b').owner.isdefault() assert c.option('b').owner.isdefault()
@ -238,12 +200,8 @@ def test_two_persistent_owner():
def test_create_persistent_retrieve_information(): def test_create_persistent_retrieve_information():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
c = Config(o, session_id='test_persistent', persistent=True) c = Config(o, session_id='test_persistent', persistent=True)
except ValueError:
# storage is not persistent
pass
else:
c.information.set('info', 'string') c.information.set('info', 'string')
assert c.information.get('info') == 'string' assert c.information.get('info') == 'string'
del c del c
@ -262,13 +220,9 @@ def test_create_persistent_retrieve_information():
def test_two_persistent_information(): def test_two_persistent_information():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
c = Config(o, session_id='test_persistent', persistent=True) c = Config(o, session_id='test_persistent', persistent=True)
c.property.pop('cache') c.property.pop('cache')
except ValueError:
# storage is not persistent
pass
else:
c.information.set('info', 'string') c.information.set('info', 'string')
assert c.information.get('info') == 'string' assert c.information.get('info') == 'string'
c2 = Config(o, session_id='test_persistent', persistent=True) c2 = Config(o, session_id='test_persistent', persistent=True)
@ -280,15 +234,11 @@ def test_two_persistent_information():
def test_two_different_persistents(): def test_two_different_persistents():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
c = Config(o, session_id='test_persistent', persistent=True) c = Config(o, session_id='test_persistent', persistent=True)
c.property.pop('cache') c.property.pop('cache')
d = Config(o, session_id='test_persistent2', persistent=True) d = Config(o, session_id='test_persistent2', persistent=True)
d.property.pop('cache') d.property.pop('cache')
except ValueError:
# storage is not persistent
pass
else:
c.option('b').property.add('test') c.option('b').property.add('test')
assert c.option('b').property.get() == {'test'} assert c.option('b').property.get() == {'test'}
assert d.option('b').property.get() == set() assert d.option('b').property.get() == set()
@ -305,15 +255,11 @@ def test_two_different_persistents():
def test_two_different_information(): def test_two_different_information():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
c = Config(o, session_id='test_persistent', persistent=True) c = Config(o, session_id='test_persistent', persistent=True)
c.information.set('a', 'a') c.information.set('a', 'a')
d = Config(o, session_id='test_persistent2', persistent=True) d = Config(o, session_id='test_persistent2', persistent=True)
d.information.set('a', 'b') d.information.set('a', 'b')
except ValueError:
# storage is not persistent
pass
else:
assert c.information.get('a') == 'a' assert c.information.get('a') == 'a'
assert d.information.get('a') == 'b' assert d.information.get('a') == 'b'
@ -324,14 +270,10 @@ def test_two_different_information():
def test_exportation_importation(): def test_exportation_importation():
b = BoolOption('b', '') b = BoolOption('b', '')
o = OptionDescription('od', '', [b]) o = OptionDescription('od', '', [b])
try: if default_storage.is_persistent():
c = Config(o, session_id='test_persistent', persistent=True) c = Config(o, session_id='test_persistent', persistent=True)
d = Config(o, session_id='test_persistent2', persistent=True) d = Config(o, session_id='test_persistent2', persistent=True)
e = Config(o, session_id='test_persistent3', persistent=True) e = Config(o, session_id='test_persistent3', persistent=True)
except ValueError:
# storage is not persistent
pass
else:
c.owner.set('export') c.owner.set('export')
assert c.option('b').value.get() is None assert c.option('b').value.get() is None
c.option('b').value.set(True) c.option('b').value.set(True)

View file

@ -336,7 +336,7 @@ forbidden_owners = (owners.default, owners.forced)
# ____________________________________________________________ # ____________________________________________________________
class Undefined(object): class Undefined(object):
def __str__(self): def __str__(self): # pragma: no cover
return 'Undefined' return 'Undefined'
__repr__ = __str__ __repr__ = __str__
@ -739,7 +739,7 @@ class Settings(object):
was present was present
""" """
config_bag = option_bag.config_bag config_bag = option_bag.config_bag
if not config_bag.properties: if not config_bag.properties: # pragma: no cover
return return
properties = self.calc_raises_properties(option_bag.properties, properties = self.calc_raises_properties(option_bag.properties,
config_bag.properties, config_bag.properties,

View file

@ -73,7 +73,7 @@ class Storage:
'cannot rebind it')) 'cannot rebind it'))
self.storage_type = name self.storage_type = name
del kwargs['engine'] del kwargs['engine']
if kwargs: if kwargs: # pragma: no cover
mod = self.get() mod = self.get()
for key, value in kwargs.items(): for key, value in kwargs.items():
setattr(mod.SETTING, key, value) setattr(mod.SETTING, key, value)

View file

@ -79,7 +79,7 @@ class Values(Cache):
"""set value for a path """set value for a path
a specified value must be associated to an owner a specified value must be associated to an owner
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('setvalue', path, value, owner, index, id(self)) print('setvalue', path, value, owner, index, id(self))
values = [] values = []
vidx = None vidx = None
@ -101,7 +101,7 @@ class Values(Cache):
return: boolean return: boolean
""" """
has_path = path in self._values[0] has_path = path in self._values[0]
if DEBUG: if DEBUG: # pragma: no cover
print('hasvalue', path, index, has_path, id(self)) print('hasvalue', path, index, has_path, id(self))
if index is None: if index is None:
return has_path return has_path
@ -115,7 +115,7 @@ class Values(Cache):
""" """
_values == ((path1, path2), ((idx1_1, idx1_2), None), ((value1_1, value1_2), value2), ((owner1_1, owner1_2), owner2)) _values == ((path1, path2), ((idx1_1, idx1_2), None), ((value1_1, value1_2), value2), ((owner1_1, owner1_2), owner2))
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('reduce_index', path, index, id(self)) print('reduce_index', path, index, id(self))
path_idx = self._values[0].index(path) path_idx = self._values[0].index(path)
# get the "index" position # get the "index" position
@ -135,7 +135,7 @@ class Values(Cache):
path, path,
index, index,
commit): commit):
if DEBUG: if DEBUG: # pragma: no cover
print('resetvalue_index', path, index, id(self)) print('resetvalue_index', path, index, id(self))
def _resetvalue(nb): def _resetvalue(nb):
values_idx = list(values[nb]) values_idx = list(values[nb])
@ -170,7 +170,7 @@ class Values(Cache):
commit): commit):
"""remove value means delete value in storage """remove value means delete value in storage
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('resetvalue', path, id(self)) print('resetvalue', path, id(self))
def _resetvalue(nb): def _resetvalue(nb):
lst = list(self._values[nb]) lst = list(self._values[nb])
@ -224,7 +224,7 @@ class Values(Cache):
with_value) with_value)
if owner is undefined: if owner is undefined:
owner = default owner = default
if DEBUG: if DEBUG: # pragma: no cover
print('getvalue', path, index, value, owner, id(self)) print('getvalue', path, index, value, owner, id(self))
if with_value: if with_value:
return owner, value return owner, value

View file

@ -40,7 +40,7 @@ class Setting:
self.name = 'tiramisu' self.name = 'tiramisu'
def __setattr__(self, key, value): def __setattr__(self, key, value):
if CONN is not None: if CONN is not None: # pragma: no cover
raise Exception(_('cannot change setting when connexion is already ' raise Exception(_('cannot change setting when connexion is already '
'opened')) 'opened'))
super().__setattr__(key, value) super().__setattr__(key, value)

View file

@ -58,7 +58,7 @@ class Values(Sqlite3DB):
"""set value for an option """set value for an option
a specified value must be associated to an owner a specified value must be associated to an owner
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('setvalue', path, value, owner, index, commit) print('setvalue', path, value, owner, index, commit)
path = self._sqlite_encode_path(path) path = self._sqlite_encode_path(path)
if index is not None: if index is not None:
@ -86,7 +86,7 @@ class Values(Sqlite3DB):
"""if opt has a value """if opt has a value
return: boolean return: boolean
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('hasvalue', path, index) print('hasvalue', path, index)
path = self._sqlite_encode_path(path) path = self._sqlite_encode_path(path)
return self._sqlite_select(path, index) is not None return self._sqlite_select(path, index) is not None
@ -97,7 +97,7 @@ class Values(Sqlite3DB):
_values == ((path1, path2), ((idx1_1, idx1_2), None), _values == ((path1, path2), ((idx1_1, idx1_2), None),
((value1_1, value1_2), value2), ((owner1_1, owner1_2), owner2)) ((value1_1, value1_2), value2), ((owner1_1, owner1_2), owner2))
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('reduce_index', path, index, id(self)) print('reduce_index', path, index, id(self))
self._storage.execute("UPDATE value SET idx = ? WHERE path = ? and idx = ? " self._storage.execute("UPDATE value SET idx = ? WHERE path = ? and idx = ? "
"AND session_id = ?", "AND session_id = ?",
@ -109,7 +109,7 @@ class Values(Sqlite3DB):
commit=True): commit=True):
"""remove value means delete value in storage """remove value means delete value in storage
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('resetvalue_index', path, index, commit) print('resetvalue_index', path, index, commit)
path = self._sqlite_encode_path(path) path = self._sqlite_encode_path(path)
self._storage.execute("DELETE FROM value WHERE path = ? AND session_id = ? AND idx = ?", self._storage.execute("DELETE FROM value WHERE path = ? AND session_id = ? AND idx = ?",
@ -121,7 +121,7 @@ class Values(Sqlite3DB):
commit): commit):
"""remove value means delete value in storage """remove value means delete value in storage
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('resetvalue', path, commit) print('resetvalue', path, commit)
path = self._sqlite_encode_path(path) path = self._sqlite_encode_path(path)
self._storage.execute("DELETE FROM value WHERE path = ? AND session_id = ?", self._storage.execute("DELETE FROM value WHERE path = ? AND session_id = ?",
@ -135,7 +135,7 @@ class Values(Sqlite3DB):
index=None): index=None):
"""change owner for an option """change owner for an option
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('setowner', path, owner, index) print('setowner', path, owner, index)
path = self._sqlite_encode_path(path) path = self._sqlite_encode_path(path)
if index is None: if index is None:
@ -153,7 +153,7 @@ class Values(Sqlite3DB):
"""get owner for an option """get owner for an option
return: owner object return: owner object
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('getowner', path, default, index, with_value) print('getowner', path, default, index, with_value)
path = self._sqlite_encode_path(path) path = self._sqlite_encode_path(path)
request = "SELECT owner, value FROM value WHERE path = ? AND session_id = ?" request = "SELECT owner, value FROM value WHERE path = ? AND session_id = ?"
@ -189,7 +189,7 @@ class Values(Sqlite3DB):
:param key: information's key (ex: "help", "doc" :param key: information's key (ex: "help", "doc"
:param value: information's value (ex: "the help string") :param value: information's value (ex: "the help string")
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('set_information', key, value) print('set_information', key, value)
path = self._sqlite_encode_path(path) path = self._sqlite_encode_path(path)
self._storage.execute("DELETE FROM information WHERE key = ? AND session_id = ? AND path = ?", self._storage.execute("DELETE FROM information WHERE key = ? AND session_id = ? AND path = ?",
@ -203,7 +203,7 @@ class Values(Sqlite3DB):
:param key: the item string (ex: "help") :param key: the item string (ex: "help")
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('get_information', key, default) print('get_information', key, default)
path = self._sqlite_encode_path(path) path = self._sqlite_encode_path(path)
value = self._storage.select("SELECT value FROM information WHERE key = ? AND " value = self._storage.select("SELECT value FROM information WHERE key = ? AND "
@ -218,7 +218,7 @@ class Values(Sqlite3DB):
return self._sqlite_decode(value[0]) return self._sqlite_decode(value[0])
def del_information(self, path, key, raises): def del_information(self, path, key, raises):
if DEBUG: if DEBUG: # pragma: no cover
print('del_information', key, raises) print('del_information', key, raises)
path = self._sqlite_encode_path(path) path = self._sqlite_encode_path(path)
if raises and self._storage.select("SELECT value FROM information WHERE key = ? " if raises and self._storage.select("SELECT value FROM information WHERE key = ? "
@ -241,7 +241,7 @@ class Values(Sqlite3DB):
(self._session_id,)) (self._session_id,))
def exportation(self): def exportation(self):
if DEBUG: if DEBUG: # pragma: no cover
print('exportation') print('exportation')
rows = self._storage.select("SELECT path, value, owner, idx FROM value WHERE " rows = self._storage.select("SELECT path, value, owner, idx FROM value WHERE "
"session_id = ?;", (self._session_id,), only_one=False) "session_id = ?;", (self._session_id,), only_one=False)
@ -271,7 +271,7 @@ class Values(Sqlite3DB):
return ret return ret
def importation(self, export): def importation(self, export):
if DEBUG: if DEBUG: # pragma: no cover
print('importation') print('importation')
request = "DELETE FROM value WHERE session_id = ?" request = "DELETE FROM value WHERE session_id = ?"
self._storage.execute(request, (self._session_id,), self._storage.execute(request, (self._session_id,),
@ -298,7 +298,7 @@ class Values(Sqlite3DB):
def get_max_length(self, def get_max_length(self,
path): path):
if DEBUG: if DEBUG: # pragma: no cover
print('get_max_length', path) print('get_max_length', path)
val_max = self._storage.select("SELECT max(idx) FROM value WHERE path = ? AND session_id = ?", val_max = self._storage.select("SELECT max(idx) FROM value WHERE path = ? AND session_id = ?",
(path, self._session_id), False) (path, self._session_id), False)

View file

@ -20,7 +20,7 @@ from time import time
from .cache.dictionary import Cache as DictCache from .cache.dictionary import Cache as DictCache
def _display_classname(obj): def _display_classname(obj): # pragma: no cover
return(obj.__class__.__name__.lower()) return(obj.__class__.__name__.lower())
DEBUG = bool(os.environ.get('TIRAMISU_DEBUG', False)) DEBUG = bool(os.environ.get('TIRAMISU_DEBUG', False))
@ -39,12 +39,12 @@ class Cache(DictCache):
if follower, add index if follower, add index
""" """
if 'cache' in props or 'cache' in self_props: if 'cache' in props or 'cache' in self_props:
if DEBUG: if DEBUG: # pragma: no cover
print('setcache {} with index {} and value {} in {} ({})'.format(path, index, val, print('setcache {} with index {} and value {} in {} ({})'.format(path, index, val,
_display_classname(self), _display_classname(self),
id(self))) id(self)))
self._setcache(path, index, val, time()) self._setcache(path, index, val, time())
elif DEBUG: elif DEBUG: # pragma: no cover
print('not setcache {} with index {} and value {} and props {} and {} in {} ({})'.format(path, print('not setcache {} with index {} and value {} and props {} and {} in {} ({})'.format(path,
index, index,
val, val,
@ -80,22 +80,22 @@ class Cache(DictCache):
'expire' in self_props): 'expire' in self_props):
ntime = int(time()) ntime = int(time())
if timestamp + expires_time >= ntime: if timestamp + expires_time >= ntime:
if DEBUG: if DEBUG: # pragma: no cover
print('getcache in cache (1)', path, value, _display_classname(self), print('getcache in cache (1)', path, value, _display_classname(self),
id(self), index) id(self), index)
return True, value return True, value
else: else:
if DEBUG: if DEBUG: # pragma: no cover
print('getcache expired value for path {} < {}'.format( print('getcache expired value for path {} < {}'.format(
timestamp + expires_time, ntime)) timestamp + expires_time, ntime))
# if expired, remove from cache # if expired, remove from cache
#self.delcache(path) #self.delcache(path)
else: else:
if DEBUG: if DEBUG: # pragma: no cover
print('getcache in cache (2)', path, value, _display_classname(self), print('getcache in cache (2)', path, value, _display_classname(self),
id(self), index) id(self), index)
return True, value return True, value
if DEBUG: if DEBUG: # pragma: no cover
print('getcache {} with index {} not in {} cache'.format(path, index, print('getcache {} with index {} not in {} cache'.format(path, index,
_display_classname(self))) _display_classname(self)))
return no_cache return no_cache
@ -103,14 +103,14 @@ class Cache(DictCache):
def delcache(self, path): def delcache(self, path):
"""remove cache for a specified path """remove cache for a specified path
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('delcache', path, _display_classname(self), id(self)) print('delcache', path, _display_classname(self), id(self))
if path in self._cache: if path in self._cache:
self._delcache(path) self._delcache(path)
def reset_all_cache(self): def reset_all_cache(self):
"empty the cache" "empty the cache"
if DEBUG: if DEBUG: # pragma: no cover
print('reset_all_cache', _display_classname(self), id(self)) print('reset_all_cache', _display_classname(self), id(self))
self._reset_all_cache() self._reset_all_cache()
@ -119,6 +119,6 @@ class Cache(DictCache):
please only use it in test purpose please only use it in test purpose
example: {'path1': {'index1': ('value1', 'time1')}, 'path2': {'index2': ('value2', 'time2', )}} example: {'path1': {'index1': ('value1', 'time1')}, 'path2': {'index2': ('value2', 'time2', )}}
""" """
if DEBUG: if DEBUG: # pragma: no cover
print('get_chached {} for {} ({})'.format(self._cache, _display_classname(self), id(self))) print('get_chached {} for {} ({})'.format(self._cache, _display_classname(self), id(self)))
return self._get_cached() return self._get_cached()