cache not expired be defaut

This commit is contained in:
Emmanuel Garette 2017-12-23 20:33:36 +01:00
parent d26626a1f9
commit 2ce251a8aa
4 changed files with 16 additions and 16 deletions

View File

@ -245,6 +245,7 @@ def test_reset_cache_only_expired():
od1 = make_description()
c = Config(od1)
api = getapi(c)
api.property.add('expire')
values = c.cfgimpl_get_values()
settings = c.cfgimpl_get_settings()
api.option('u1').value.get()
@ -274,7 +275,7 @@ def test_cache_not_expire():
api = getapi(c)
values = c.cfgimpl_get_values()
settings = c.cfgimpl_get_settings()
api.property.pop('expire')
#api.property.pop('expire')
api.option('u1').value.get()
assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached()
@ -438,7 +439,7 @@ def test_cache_callback():
cfg = Config(maconfig)
api = getapi(cfg)
api.property.read_write()
api.property.pop('expire')
#api.property.pop('expire')
api.option.make_dict()
#assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
# 'val1': {None: (set([]), None)}}
@ -528,7 +529,7 @@ def test_cache_master_and_slaves_master():
cfg = Config(maconfig)
api = getapi(cfg)
api.property.read_write()
api.property.pop('expire')
#api.property.pop('expire')
api.option.make_dict()
global_props = ['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']
val1_props = []
@ -606,7 +607,7 @@ def test_cache_master_callback():
cfg = Config(maconfig)
api = getapi(cfg)
api.property.read_write()
api.property.pop('expire')
#api.property.pop('expire')
api.option.make_dict()
global_props = ['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']
val1_props = []
@ -705,7 +706,7 @@ def test_cache_requires():
c = Config(od)
api = getapi(c)
api.property.read_write()
api.property.pop('expire')
#api.property.pop('expire')
#assert c.cfgimpl_get_settings()._p_.get_cached() == {}
assert c.cfgimpl_get_values()._p_.get_cached() == {}
assert api.option('ip_address_service').value.get() == None
@ -754,7 +755,7 @@ def test_cache_global_properties():
c = Config(od)
api = getapi(c)
api.property.read_write()
api.property.pop('expire')
#api.property.pop('expire')
#assert c.cfgimpl_get_settings()._p_.get_cached() == {}
assert c.cfgimpl_get_values()._p_.get_cached() == {}
assert api.option('ip_address_service').value.get() == None
@ -783,6 +784,7 @@ def test_callback_value_incr():
cfg = Config(maconfig)
api = getapi(cfg)
api.property.read_write()
api.property.add('expire')
assert api.option('val1').value.get() == 1
sleep(1)
assert api.option('val2').value.get() == 1

View File

@ -446,7 +446,7 @@ def test_reset_properties_force_store_value():
assert api.property.get_modified() == {}
api.property.add('frozen')
assert api.property.get_modified() == \
{None: set(('frozen', 'expire', 'cache', 'validator', 'warnings'))}
{None: set(('frozen', 'cache', 'validator', 'warnings'))}
api.property.reset()
assert api.property.get_modified() == {}
api.option('gc.dummy').property.add('test')
@ -455,15 +455,15 @@ def test_reset_properties_force_store_value():
assert api.property.get_modified() == {'gc.dummy': set(('test', 'force_store_value'))}
api.property.add('frozen')
assert api.property.get_modified() == \
{None: set(('frozen', 'expire', 'validator', 'cache', 'warnings')),
{None: set(('frozen', 'validator', 'cache', 'warnings')),
'gc.dummy': set(('test', 'force_store_value'))}
api.property.add('frozen')
assert api.property.get_modified() == \
{None: set(('frozen', 'expire', 'validator', 'cache', 'warnings')),
{None: set(('frozen', 'validator', 'cache', 'warnings')),
'gc.dummy': set(('test', 'force_store_value'))}
api.option('gc.dummy').property.add('test')
assert api.property.get_modified() == \
{None: set(('frozen', 'expire', 'validator', 'cache', 'warnings')),
{None: set(('frozen', 'validator', 'cache', 'warnings')),
'gc.dummy': set(('test', 'force_store_value'))}
@ -473,9 +473,9 @@ def test_set_modified_value():
descr = OptionDescription('tiramisu', '', [gcgroup])
api = getapi(Config(descr))
assert api.property.get_modified() == {}
api.property.set_modified({None: set(('frozen', 'expire', 'cache', 'validator', 'warnings'))})
api.property.set_modified({None: set(('frozen', 'cache', 'validator', 'warnings'))})
assert api.property.get_modified() == \
{None: set(('frozen', 'expire', 'cache', 'validator', 'warnings'))}
{None: set(('frozen', 'cache', 'validator', 'warnings'))}
def test_pprint():

View File

@ -85,7 +85,7 @@ validator
warnings
display warnings during validation
"""
default_properties = ('cache', 'expire', 'validator', 'warnings')
default_properties = ('cache', 'validator', 'warnings')
"""Config can be in two defaut mode:

View File

@ -118,9 +118,7 @@ class Values(object):
config_bag=config_bag)
# store value in cache
if not is_cached and \
setting_properties and 'cache' in setting_properties and \
config_bag.validate and config_bag.force_permissive is False and \
config_bag.trusted_cached_properties is True:
setting_properties and 'cache' in setting_properties:
if 'expire' in setting_properties:
if ntime is None:
ntime = int(time())