remove unused context from get_cached

This commit is contained in:
Emmanuel Garette 2017-09-22 08:26:11 +02:00
parent 0ce4cc658b
commit d6bbbd87f5
2 changed files with 183 additions and 183 deletions

View File

@ -48,13 +48,13 @@ def test_cache():
values = c.cfgimpl_get_values() values = c.cfgimpl_get_values()
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
c.u2 c.u2
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u2' in values._p_.get_cached(c) assert 'u2' in values._p_.get_cached()
assert 'u2' in settings._p_.get_cached(c) assert 'u2' in settings._p_.get_cached()
def test_get_cache(): def test_get_cache():
@ -90,54 +90,54 @@ def test_cache_reset():
#when change a value #when change a value
c.u1 c.u1
c.u2 c.u2
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u2' in values._p_.get_cached(c) assert 'u2' in values._p_.get_cached()
assert 'u2' in settings._p_.get_cached(c) assert 'u2' in settings._p_.get_cached()
c.u2 = 1 c.u2 = 1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u2' not in values._p_.get_cached(c) assert 'u2' not in values._p_.get_cached()
assert 'u2' in settings._p_.get_cached(c) assert 'u2' in settings._p_.get_cached()
#when remove a value #when remove a value
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
del(c.u2) del(c.u2)
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u2' not in values._p_.get_cached(c) assert 'u2' not in values._p_.get_cached()
assert 'u2' in settings._p_.get_cached(c) assert 'u2' in settings._p_.get_cached()
#when add/del property #when add/del property
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
c.cfgimpl_get_settings()[od1.u2].append('test') c.cfgimpl_get_settings()[od1.u2].append('test')
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u2' not in values._p_.get_cached(c) assert 'u2' not in values._p_.get_cached()
assert 'u2' not in settings._p_.get_cached(c) assert 'u2' not in settings._p_.get_cached()
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
c.cfgimpl_get_settings()[od1.u2].remove('test') c.cfgimpl_get_settings()[od1.u2].remove('test')
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u2' not in values._p_.get_cached(c) assert 'u2' not in values._p_.get_cached()
assert 'u2' not in settings._p_.get_cached(c) assert 'u2' not in settings._p_.get_cached()
#when enable/disabled property #when enable/disabled property
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
c.cfgimpl_get_settings().append('test') c.cfgimpl_get_settings().append('test')
assert 'u1' not in values._p_.get_cached(c) assert 'u1' not in values._p_.get_cached()
assert 'u1' not in settings._p_.get_cached(c) assert 'u1' not in settings._p_.get_cached()
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
c.cfgimpl_get_settings().remove('test') c.cfgimpl_get_settings().remove('test')
assert 'u1' not in values._p_.get_cached(c) assert 'u1' not in values._p_.get_cached()
assert 'u1' not in settings._p_.get_cached(c) assert 'u1' not in settings._p_.get_cached()
def test_cache_reset_multi(): def test_cache_reset_multi():
@ -147,49 +147,49 @@ def test_cache_reset_multi():
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
c.u1 c.u1
c.u3 c.u3
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u3' in values._p_.get_cached(c) assert 'u3' in values._p_.get_cached()
assert 'u3' in settings._p_.get_cached(c) assert 'u3' in settings._p_.get_cached()
#when change a value #when change a value
c.u3 = [1] c.u3 = [1]
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u3' not in values._p_.get_cached(c) assert 'u3' not in values._p_.get_cached()
assert 'u3' in settings._p_.get_cached(c) assert 'u3' in settings._p_.get_cached()
#when append value #when append value
c.u1 c.u1
c.u3 c.u3
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u3' in values._p_.get_cached(c) assert 'u3' in values._p_.get_cached()
assert 'u3' in settings._p_.get_cached(c) assert 'u3' in settings._p_.get_cached()
c.u3.append(1) c.u3.append(1)
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u3' not in values._p_.get_cached(c) assert 'u3' not in values._p_.get_cached()
assert 'u3' in settings._p_.get_cached(c) assert 'u3' in settings._p_.get_cached()
#when pop value #when pop value
c.u1 c.u1
c.u3 c.u3
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u3' in values._p_.get_cached(c) assert 'u3' in values._p_.get_cached()
assert 'u3' in settings._p_.get_cached(c) assert 'u3' in settings._p_.get_cached()
c.u3.pop(1) c.u3.pop(1)
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u3' not in values._p_.get_cached(c) assert 'u3' not in values._p_.get_cached()
assert 'u3' in settings._p_.get_cached(c) assert 'u3' in settings._p_.get_cached()
#when remove a value #when remove a value
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
del(c.u3) del(c.u3)
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u3' not in values._p_.get_cached(c) assert 'u3' not in values._p_.get_cached()
assert 'u3' in settings._p_.get_cached(c) assert 'u3' in settings._p_.get_cached()
def test_reset_cache(): def test_reset_cache():
@ -198,25 +198,25 @@ def test_reset_cache():
values = c.cfgimpl_get_values() values = c.cfgimpl_get_values()
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
c.cfgimpl_reset_cache() c.cfgimpl_reset_cache()
assert 'u1' not in values._p_.get_cached(c) assert 'u1' not in values._p_.get_cached()
assert 'u1' not in settings._p_.get_cached(c) assert 'u1' not in settings._p_.get_cached()
c.u1 c.u1
sleep(1) sleep(1)
c.u1 c.u1
sleep(1) sleep(1)
c.u2 c.u2
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u2' in values._p_.get_cached(c) assert 'u2' in values._p_.get_cached()
assert 'u2' in settings._p_.get_cached(c) assert 'u2' in settings._p_.get_cached()
c.cfgimpl_reset_cache() c.cfgimpl_reset_cache()
assert 'u1' not in values._p_.get_cached(c) assert 'u1' not in values._p_.get_cached()
assert 'u1' not in settings._p_.get_cached(c) assert 'u1' not in settings._p_.get_cached()
assert 'u2' not in values._p_.get_cached(c) assert 'u2' not in values._p_.get_cached()
assert 'u2' not in settings._p_.get_cached(c) assert 'u2' not in settings._p_.get_cached()
def test_reset_cache_subconfig(): def test_reset_cache_subconfig():
@ -225,9 +225,9 @@ def test_reset_cache_subconfig():
c = Config(od2) c = Config(od2)
values = c.cfgimpl_get_values() values = c.cfgimpl_get_values()
c.od1.u1 c.od1.u1
assert 'od1.u1' in values._p_.get_cached(c) assert 'od1.u1' in values._p_.get_cached()
c.od1.cfgimpl_reset_cache() c.od1.cfgimpl_reset_cache()
assert 'od1.u1' not in values._p_.get_cached(c) assert 'od1.u1' not in values._p_.get_cached()
def test_reset_cache_only_expired(): def test_reset_cache_only_expired():
@ -236,24 +236,24 @@ def test_reset_cache_only_expired():
values = c.cfgimpl_get_values() values = c.cfgimpl_get_values()
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
c.cfgimpl_reset_cache(True) c.cfgimpl_reset_cache(True)
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
sleep(1) sleep(1)
c.u1 c.u1
sleep(1) sleep(1)
c.u2 c.u2
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u2' in values._p_.get_cached(c) assert 'u2' in values._p_.get_cached()
assert 'u2' in settings._p_.get_cached(c) assert 'u2' in settings._p_.get_cached()
c.cfgimpl_reset_cache(True) c.cfgimpl_reset_cache(True)
assert 'u1' not in values._p_.get_cached(c) assert 'u1' not in values._p_.get_cached()
assert 'u1' not in settings._p_.get_cached(c) assert 'u1' not in settings._p_.get_cached()
assert 'u2' in values._p_.get_cached(c) assert 'u2' in values._p_.get_cached()
assert 'u2' in settings._p_.get_cached(c) assert 'u2' in settings._p_.get_cached()
def test_cache_not_expire(): def test_cache_not_expire():
@ -263,22 +263,22 @@ def test_cache_not_expire():
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
settings.remove('expire') settings.remove('expire')
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
c.cfgimpl_reset_cache(True) c.cfgimpl_reset_cache(True)
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
sleep(1) sleep(1)
c.u2 c.u2
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u2' in values._p_.get_cached(c) assert 'u2' in values._p_.get_cached()
assert 'u2' in settings._p_.get_cached(c) assert 'u2' in settings._p_.get_cached()
c.cfgimpl_reset_cache(True) c.cfgimpl_reset_cache(True)
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
assert 'u2' in values._p_.get_cached(c) assert 'u2' in values._p_.get_cached()
assert 'u2' in settings._p_.get_cached(c) assert 'u2' in settings._p_.get_cached()
def test_cache_not_cache(): def test_cache_not_cache():
@ -288,8 +288,8 @@ def test_cache_not_cache():
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
settings.remove('cache') settings.remove('cache')
c.u1 c.u1
assert 'u1' not in values._p_.get_cached(c) assert 'u1' not in values._p_.get_cached()
assert 'u1' not in settings._p_.get_cached(c) assert 'u1' not in settings._p_.get_cached()
def test_reset_cache_only(): def test_reset_cache_only():
@ -298,17 +298,17 @@ def test_reset_cache_only():
values = c.cfgimpl_get_values() values = c.cfgimpl_get_values()
settings = c.cfgimpl_get_settings() settings = c.cfgimpl_get_settings()
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
c.cfgimpl_reset_cache(only=('values',)) c.cfgimpl_reset_cache(only=('values',))
assert 'u1' not in values._p_.get_cached(c) assert 'u1' not in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
c.u1 c.u1
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' in settings._p_.get_cached(c) assert 'u1' in settings._p_.get_cached()
c.cfgimpl_reset_cache(only=('settings',)) c.cfgimpl_reset_cache(only=('settings',))
assert 'u1' in values._p_.get_cached(c) assert 'u1' in values._p_.get_cached()
assert 'u1' not in settings._p_.get_cached(c) assert 'u1' not in settings._p_.get_cached()
def test_force_cache(): def test_force_cache():
@ -321,11 +321,11 @@ def test_force_cache():
c.cfgimpl_get_settings().remove('expire') c.cfgimpl_get_settings().remove('expire')
c.cfgimpl_get_values().force_cache() c.cfgimpl_get_values().force_cache()
assert c.cfgimpl_get_values()._p_.get_cached(c) == {'u1': {None: ([], None)}, assert c.cfgimpl_get_values()._p_.get_cached() == {'u1': {None: ([], None)},
'u2': {None: (None, None)}, 'u2': {None: (None, None)},
'u3': {None: ([], None)}, 'u3': {None: ([], None)},
'u4': {None: (None, None)}} 'u4': {None: (None, None)}}
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {None: {None: (set(['cache', 'validator', 'warnings']), None)}, assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'validator', 'warnings']), None)},
'u1': {None: (set(['empty']), None)}, 'u1': {None: (set(['empty']), None)},
'u2': {None: (set([]), None)}, 'u2': {None: (set([]), None)},
'u3': {None: (set(['empty']), None)}, 'u3': {None: (set(['empty']), None)},
@ -333,10 +333,10 @@ def test_force_cache():
c.read_only() c.read_only()
c.cfgimpl_get_values().force_cache() c.cfgimpl_get_values().force_cache()
assert c.cfgimpl_get_values()._p_.get_cached(c) == {'u1': {None: ([], None)}, assert c.cfgimpl_get_values()._p_.get_cached() == {'u1': {None: ([], None)},
'u2': {None: (None, None)}, 'u2': {None: (None, None)},
'u3': {None: ([], None)}} 'u3': {None: ([], None)}}
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {None: {None: (set(['cache', 'disabled', 'empty', 'everything_frozen', 'frozen', 'mandatory', 'validator', 'warnings']), None)}, assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'empty', 'everything_frozen', 'frozen', 'mandatory', 'validator', 'warnings']), None)},
'u1': {None: (set(['empty']), None)}, 'u1': {None: (set(['empty']), None)},
'u2': {None: (set([]), None)}, 'u2': {None: (set([]), None)},
'u3': {None: (set(['empty']), None)}, 'u3': {None: (set(['empty']), None)},
@ -354,20 +354,20 @@ def test_cache_master_slave():
maconfig = OptionDescription('toto', '', [interface1]) maconfig = OptionDescription('toto', '', [interface1])
cfg = Config(maconfig) cfg = Config(maconfig)
cfg.read_write() cfg.read_write()
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {} assert cfg.cfgimpl_get_values()._p_.get_cached() == {}
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {} assert cfg.cfgimpl_get_settings()._p_.get_cached() == {}
# #
cfg.ip_admin_eth0.ip_admin_eth0.append('192.168.1.2') cfg.ip_admin_eth0.ip_admin_eth0.append('192.168.1.2')
cfg.ip_admin_eth0.ip_admin_eth0 cfg.ip_admin_eth0.ip_admin_eth0
cfg.ip_admin_eth0.netmask_admin_eth0 cfg.ip_admin_eth0.netmask_admin_eth0
cache = cfg.cfgimpl_get_values()._p_.get_cached(cfg) cache = cfg.cfgimpl_get_values()._p_.get_cached()
assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0']) assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None]) assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
assert cache['ip_admin_eth0.ip_admin_eth0'][None][0] == ['192.168.1.2'] assert cache['ip_admin_eth0.ip_admin_eth0'][None][0] == ['192.168.1.2']
assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([None, 0]) assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([None, 0])
assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None] assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None]
assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None
cache = cfg.cfgimpl_get_settings()._p_.get_cached(cfg) cache = cfg.cfgimpl_get_settings()._p_.get_cached()
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0']) assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
assert set(cache['ip_admin_eth0'].keys()) == set([None]) assert set(cache['ip_admin_eth0'].keys()) == set([None])
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None]) assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
@ -376,7 +376,7 @@ def test_cache_master_slave():
cfg.ip_admin_eth0.ip_admin_eth0.append('192.168.1.1') cfg.ip_admin_eth0.ip_admin_eth0.append('192.168.1.1')
cfg.ip_admin_eth0.ip_admin_eth0 cfg.ip_admin_eth0.ip_admin_eth0
cfg.ip_admin_eth0.netmask_admin_eth0 cfg.ip_admin_eth0.netmask_admin_eth0
cache = cfg.cfgimpl_get_values()._p_.get_cached(cfg) cache = cfg.cfgimpl_get_values()._p_.get_cached()
assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0']) assert set(cache.keys()) == set(['ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None]) assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
assert cache['ip_admin_eth0.ip_admin_eth0'][None][0] == ['192.168.1.2', '192.168.1.1'] assert cache['ip_admin_eth0.ip_admin_eth0'][None][0] == ['192.168.1.2', '192.168.1.1']
@ -384,7 +384,7 @@ def test_cache_master_slave():
assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None, None] assert cache['ip_admin_eth0.netmask_admin_eth0'][None][0] == [None, None]
assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None assert cache['ip_admin_eth0.netmask_admin_eth0'][0][0] is None
assert cache['ip_admin_eth0.netmask_admin_eth0'][1][0] is None assert cache['ip_admin_eth0.netmask_admin_eth0'][1][0] is None
cache = cfg.cfgimpl_get_settings()._p_.get_cached(cfg) cache = cfg.cfgimpl_get_settings()._p_.get_cached()
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0']) assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
assert set(cache['ip_admin_eth0'].keys()) == set([None]) assert set(cache['ip_admin_eth0'].keys()) == set([None])
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None]) assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
@ -407,101 +407,101 @@ def test_cache_callback():
cfg.cfgimpl_get_settings().remove('expire') cfg.cfgimpl_get_settings().remove('expire')
cfg.read_write() cfg.read_write()
cfg.cfgimpl_get_values().force_cache() cfg.cfgimpl_get_values().force_cache()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val2': {None: (set(['mandatory']), None)}, 'val2': {None: (set(['mandatory']), None)},
'val3': {None: (set([]), None)}, 'val3': {None: (set([]), None)},
'val4': {None: (set([]), None)}, 'val4': {None: (set([]), None)},
'val5': {None: (set(['empty']), None)}} 'val5': {None: (set(['empty']), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1': {None: ('val', None)}, assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('val', None)},
'val2': {None: ('val', None)}, 'val2': {None: ('val', None)},
'val3': {None: ('yes', None)}, 'val3': {None: ('yes', None)},
'val4': {None: ('val', None)}, 'val4': {None: ('val', None)},
'val5': {None: (['yes'], None)}} 'val5': {None: (['yes'], None)}}
cfg.val1 = 'new' cfg.val1 = 'new'
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val3': {None: (set([]), None)}, 'val3': {None: (set([]), None)},
'val5': {None: (set(['empty']), None)}} 'val5': {None: (set(['empty']), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val3': {None: ('yes', None)}, assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val3': {None: ('yes', None)},
'val5': {None: (['yes'], None)}} 'val5': {None: (['yes'], None)}}
cfg.cfgimpl_get_values().force_cache() cfg.cfgimpl_get_values().force_cache()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val2': {None: (set(['mandatory']), None)}, 'val2': {None: (set(['mandatory']), None)},
'val3': {None: (set([]), None)}, 'val3': {None: (set([]), None)},
'val4': {None: (set([]), None)}, 'val4': {None: (set([]), None)},
'val5': {None: (set(['empty']), None)}} 'val5': {None: (set(['empty']), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1': {None: ('new', None)}, assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
'val2': {None: ('new', None)}, 'val2': {None: ('new', None)},
'val3': {None: ('yes', None)}, 'val3': {None: ('yes', None)},
'val4': {None: ('new', None)}, 'val4': {None: ('new', None)},
'val5': {None: (['yes'], None)}} 'val5': {None: (['yes'], None)}}
cfg.val3 = 'new2' cfg.val3 = 'new2'
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val2': {None: (set(['mandatory']), None)}, 'val2': {None: (set(['mandatory']), None)},
'val3': {None: (set([]), None)}, 'val3': {None: (set([]), None)},
'val4': {None: (set([]), None)}, 'val4': {None: (set([]), None)},
'val5': {None: (set(['empty']), None)}} 'val5': {None: (set(['empty']), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1': {None: ('new', None)}, assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
'val2': {None: ('new', None)}, 'val2': {None: ('new', None)},
'val4': {None: ('new', None)}, 'val4': {None: ('new', None)},
'val5': {None: (['yes'], None)}} 'val5': {None: (['yes'], None)}}
cfg.cfgimpl_get_values().force_cache() cfg.cfgimpl_get_values().force_cache()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val2': {None: (set(['mandatory']), None)}, 'val2': {None: (set(['mandatory']), None)},
'val3': {None: (set([]), None)}, 'val3': {None: (set([]), None)},
'val4': {None: (set([]), None)}, 'val4': {None: (set([]), None)},
'val5': {None: (set(['empty']), None)}} 'val5': {None: (set(['empty']), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1': {None: ('new', None)}, assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
'val2': {None: ('new', None)}, 'val2': {None: ('new', None)},
'val3': {None: ('new2', None)}, 'val3': {None: ('new2', None)},
'val4': {None: ('new', None)}, 'val4': {None: ('new', None)},
'val5': {None: (['yes'], None)}} 'val5': {None: (['yes'], None)}}
cfg.val4 = 'new3' cfg.val4 = 'new3'
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val2': {None: (set(['mandatory']), None)}, 'val2': {None: (set(['mandatory']), None)},
'val3': {None: (set([]), None)}, 'val3': {None: (set([]), None)},
'val4': {None: (set([]), None)}, 'val4': {None: (set([]), None)},
'val5': {None: (set(['empty']), None)}} 'val5': {None: (set(['empty']), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1': {None: ('new', None)}, assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
'val2': {None: ('new', None)}, 'val2': {None: ('new', None)},
'val3': {None: ('new2', None)}, 'val3': {None: ('new2', None)},
'val5': {None: (['yes'], None)}} 'val5': {None: (['yes'], None)}}
cfg.cfgimpl_get_values().force_cache() cfg.cfgimpl_get_values().force_cache()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val2': {None: (set(['mandatory']), None)}, 'val2': {None: (set(['mandatory']), None)},
'val3': {None: (set([]), None)}, 'val3': {None: (set([]), None)},
'val4': {None: (set([]), None)}, 'val4': {None: (set([]), None)},
'val5': {None: (set(['empty']), None)}} 'val5': {None: (set(['empty']), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1': {None: ('new', None)}, assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
'val2': {None: ('new', None)}, 'val2': {None: ('new', None)},
'val3': {None: ('new2', None)}, 'val3': {None: ('new2', None)},
'val4': {None: ('new3', None)}, 'val4': {None: ('new3', None)},
'val5': {None: (['yes'], None)}} 'val5': {None: (['yes'], None)}}
cfg.val5.append('new4') cfg.val5.append('new4')
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val2': {None: (set(['mandatory']), None)}, 'val2': {None: (set(['mandatory']), None)},
'val3': {None: (set([]), None)}, 'val3': {None: (set([]), None)},
'val4': {None: (set([]), None)}, 'val4': {None: (set([]), None)},
'val5': {None: (set(['empty']), None)}} 'val5': {None: (set(['empty']), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1': {None: ('new', None)}, assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
'val2': {None: ('new', None)}, 'val2': {None: ('new', None)},
'val3': {None: ('new2', None)}, 'val3': {None: ('new2', None)},
'val4': {None: ('new3', None)}} 'val4': {None: ('new3', None)}}
cfg.cfgimpl_get_values().force_cache() cfg.cfgimpl_get_values().force_cache()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val2': {None: (set(['mandatory']), None)}, 'val2': {None: (set(['mandatory']), None)},
'val3': {None: (set([]), None)}, 'val3': {None: (set([]), None)},
'val4': {None: (set([]), None)}, 'val4': {None: (set([]), None)},
'val5': {None: (set(['empty']), None)}} 'val5': {None: (set(['empty']), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1': {None: ('new', None)}, assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
'val2': {None: ('new', None)}, 'val2': {None: ('new', None)},
'val3': {None: ('new2', None)}, 'val3': {None: ('new2', None)},
'val4': {None: ('new3', None)}, 'val4': {None: ('new3', None)},
@ -518,34 +518,34 @@ def test_cache_master_and_slaves_master():
cfg.cfgimpl_get_settings().remove('expire') cfg.cfgimpl_get_settings().remove('expire')
cfg.read_write() cfg.read_write()
cfg.cfgimpl_get_values().force_cache() cfg.cfgimpl_get_values().force_cache()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val1.val1': {None: (set(['empty']), None)}, 'val1.val1': {None: (set(['empty']), None)},
'val1.val2': {None: (set([]), None)}} 'val1.val2': {None: (set([]), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1.val1': {None: ([], None)}, 'val1.val2': {None: ([], None)}} assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([], None)}, 'val1.val2': {None: ([], None)}}
cfg.val1.val1.append() cfg.val1.val1.append()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}} 'val1': {None: (set([]), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {} assert cfg.cfgimpl_get_values()._p_.get_cached() == {}
cfg.cfgimpl_get_values().force_cache() cfg.cfgimpl_get_values().force_cache()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val1.val1': {None: (set(['empty']), None)}, 'val1.val1': {None: (set(['empty']), None)},
'val1.val2': {None: (set([]), None), 0: (set([]), None)}} 'val1.val2': {None: (set([]), None), 0: (set([]), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1.val1': {None: ([None], None)}, assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None], None)},
'val1.val2': {None: ([None], None), 0: (None, None)}} 'val1.val2': {None: ([None], None), 0: (None, None)}}
cfg.val1.val1.append() cfg.val1.val1.append()
cfg.cfgimpl_get_values().force_cache() cfg.cfgimpl_get_values().force_cache()
cfg.val1.val2[1] = 'oui' cfg.val1.val2[1] = 'oui'
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}} 'val1': {None: (set([]), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {} assert cfg.cfgimpl_get_values()._p_.get_cached() == {}
cfg.cfgimpl_get_values().force_cache() cfg.cfgimpl_get_values().force_cache()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val1.val1': {None: (set(['empty']), None)}, 'val1.val1': {None: (set(['empty']), None)},
'val1.val2': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)}} 'val1.val2': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1.val1': {None: ([None, None], None)}, assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None, None], None)},
'val1.val2': {None: ([None, 'oui'], None), 0: (None, None), 1: ('oui', None)}} 'val1.val2': {None: ([None, 'oui'], None), 0: (None, None), 1: ('oui', None)}}
@ -559,21 +559,21 @@ def test_cache_master_callback():
cfg.cfgimpl_get_settings().remove('expire') cfg.cfgimpl_get_settings().remove('expire')
cfg.read_write() cfg.read_write()
cfg.cfgimpl_get_values().force_cache() cfg.cfgimpl_get_values().force_cache()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val1.val1': {None: (set(['empty']), None)}, 'val1.val1': {None: (set(['empty']), None)},
'val1.val2': {None: (set([]), None)}} 'val1.val2': {None: (set([]), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1.val1': {None: ([], None)}, 'val1.val2': {None: ([], None)}} assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([], None)}, 'val1.val2': {None: ([], None)}}
cfg.val1.val1.append() cfg.val1.val1.append()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}} 'val1': {None: (set([]), None)}}
assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {} assert cfg.cfgimpl_get_values()._p_.get_cached() == {}
cfg.cfgimpl_get_values().force_cache() cfg.cfgimpl_get_values().force_cache()
assert cfg.cfgimpl_get_settings()._p_.get_cached(cfg) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'val1': {None: (set([]), None)}, 'val1': {None: (set([]), None)},
'val1.val1': {None: (set(['empty']), None)}, 'val1.val1': {None: (set(['empty']), None)},
'val1.val2': {None: (set([]), None), 0: (set([]), None)}} 'val1.val2': {None: (set([]), None), 0: (set([]), None)}}
#assert cfg.cfgimpl_get_values()._p_.get_cached(cfg) == {'val1.val1': {None: ([None], None)}, #assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None], None)},
# 'val1.val2': {None: ([None], None), 0: (None, None)}} # 'val1.val2': {None: ([None], None), 0: (None, None)}}
@ -585,45 +585,45 @@ def test_cache_requires():
c = Config(od) c = Config(od)
c.cfgimpl_get_settings().remove('expire') c.cfgimpl_get_settings().remove('expire')
c.read_write() c.read_write()
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {} assert c.cfgimpl_get_settings()._p_.get_cached() == {}
assert c.cfgimpl_get_values()._p_.get_cached(c) == {} assert c.cfgimpl_get_values()._p_.get_cached() == {}
assert c.ip_address_service == None assert c.ip_address_service == None
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'activate_service': {None: (set([]), None)}, 'activate_service': {None: (set([]), None)},
'ip_address_service': {None: (set([]), None)}} 'ip_address_service': {None: (set([]), None)}}
assert c.cfgimpl_get_values()._p_.get_cached(c) == {'ip_address_service': {None: (None, None)}} assert c.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
c.cfgimpl_get_values().force_cache() c.cfgimpl_get_values().force_cache()
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'activate_service': {None: (set([]), None)}, 'activate_service': {None: (set([]), None)},
'ip_address_service': {None: (set([]), None)}} 'ip_address_service': {None: (set([]), None)}}
assert c.cfgimpl_get_values()._p_.get_cached(c) == {'ip_address_service': {None: (None, None)}, assert c.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)},
'activate_service': {None: (True, None)}} 'activate_service': {None: (True, None)}}
c.ip_address_service = '1.1.1.1' c.ip_address_service = '1.1.1.1'
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'activate_service': {None: (set([]), None)}, 'activate_service': {None: (set([]), None)},
'ip_address_service': {None: (set([]), None)}} 'ip_address_service': {None: (set([]), None)}}
assert c.cfgimpl_get_values()._p_.get_cached(c) == {'activate_service': {None: (True, None)}} assert c.cfgimpl_get_values()._p_.get_cached() == {'activate_service': {None: (True, None)}}
c.cfgimpl_get_values().force_cache() c.cfgimpl_get_values().force_cache()
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'activate_service': {None: (set([]), None)}, 'activate_service': {None: (set([]), None)},
'ip_address_service': {None: (set([]), None)}} 'ip_address_service': {None: (set([]), None)}}
assert c.cfgimpl_get_values()._p_.get_cached(c) == {'ip_address_service': {None: ('1.1.1.1', None)}, assert c.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: ('1.1.1.1', None)},
'activate_service': {None: (True, None)}} 'activate_service': {None: (True, None)}}
c.activate_service = False c.activate_service = False
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'activate_service': {None: (set([]), None)}} 'activate_service': {None: (set([]), None)}}
assert c.cfgimpl_get_values()._p_.get_cached(c) == {} assert c.cfgimpl_get_values()._p_.get_cached() == {}
c.cfgimpl_get_values().force_cache() c.cfgimpl_get_values().force_cache()
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'activate_service': {None: (set([]), None)}, 'activate_service': {None: (set([]), None)},
'ip_address_service': {None: (set(['disabled']), None)}} 'ip_address_service': {None: (set(['disabled']), None)}}
assert c.cfgimpl_get_values()._p_.get_cached(c) == {'activate_service': {None: (False, None)}} assert c.cfgimpl_get_values()._p_.get_cached() == {'activate_service': {None: (False, None)}}
def test_cache_global_properties(): def test_cache_global_properties():
@ -634,22 +634,22 @@ def test_cache_global_properties():
c = Config(od) c = Config(od)
c.cfgimpl_get_settings().remove('expire') c.cfgimpl_get_settings().remove('expire')
c.read_write() c.read_write()
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {} assert c.cfgimpl_get_settings()._p_.get_cached() == {}
assert c.cfgimpl_get_values()._p_.get_cached(c) == {} assert c.cfgimpl_get_values()._p_.get_cached() == {}
assert c.ip_address_service == None assert c.ip_address_service == None
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'activate_service': {None: (set([]), None)}, 'activate_service': {None: (set([]), None)},
'ip_address_service': {None: (set([]), None)}} 'ip_address_service': {None: (set([]), None)}}
assert c.cfgimpl_get_values()._p_.get_cached(c) == {'ip_address_service': {None: (None, None)}} assert c.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
c.cfgimpl_get_settings().remove('disabled') c.cfgimpl_get_settings().remove('disabled')
assert c.ip_address_service == None assert c.ip_address_service == None
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings']), None)}, assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings']), None)},
'activate_service': {None: (set([]), None)}, 'activate_service': {None: (set([]), None)},
'ip_address_service': {None: (set([]), None)}} 'ip_address_service': {None: (set([]), None)}}
c.cfgimpl_get_settings().append('test') c.cfgimpl_get_settings().append('test')
assert c.ip_address_service == None assert c.ip_address_service == None
assert c.cfgimpl_get_settings()._p_.get_cached(c) == {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings', 'test']), None)}, assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'frozen', 'hidden', 'validator', 'warnings', 'test']), None)},
'activate_service': {None: (set([]), None)}, 'activate_service': {None: (set([]), None)},
'ip_address_service': {None: (set([]), None)}} 'ip_address_service': {None: (set([]), None)}}

View File

@ -66,7 +66,7 @@ class Cache(object):
"empty the cache" "empty the cache"
self._cache.clear() self._cache.clear()
def get_cached(self, context): def get_cached(self):
"""return all values in a dictionary """return all values in a dictionary
example: {'path1': {'index1': ('value1', 'time1')}, 'path2': {'index2': ('value2', 'time2', )}} example: {'path1': {'index1': ('value1', 'time1')}, 'path2': {'index2': ('value2', 'time2', )}}
""" """