allow caching with the demoting_error_warning property

This commit is contained in:
2021-03-21 14:51:12 +01:00
parent 12174045a2
commit 3b1dccd844
3 changed files with 60 additions and 25 deletions

View File

@ -559,6 +559,8 @@ async def test_cache_global_properties():
@pytest.mark.asyncio
async def test_callback_value_incr():
global incr
incr = -1
val1 = IntOption('val1', "", Calculation(return_incr), properties=('expire',))
val2 = IntOption('val2', "", Calculation(calc_value, Params(ParamOption(val1))))
od1 = OptionDescription('rootconfig', '', [val1, val2])
@ -579,3 +581,30 @@ async def test_callback_value_incr():
assert await cfg.option('val1').value.get() == 2
assert await cfg.option('val2').value.get() == 2
assert not await list_sessions()
@pytest.mark.asyncio
async def test_callback_value_incr_demoting():
global incr
incr = -1
val1 = IntOption('val1', "", Calculation(return_incr), properties=('expire',))
val2 = IntOption('val2', "", Calculation(calc_value, Params(ParamOption(val1))))
od1 = OptionDescription('rootconfig', '', [val1, val2])
async with await Config(od1) as cfg:
await cfg.property.add('demoting_error_warning')
assert await cfg.cache.get_expiration_time() == 5
await cfg.cache.set_expiration_time(1)
assert await cfg.cache.get_expiration_time() == 1
await cfg.property.read_write()
assert await cfg.option('val1').value.get() == 1
sleep(1)
assert await cfg.option('val2').value.get() == 1
sleep(1)
assert await cfg.option('val1').value.get() == 1
assert await cfg.option('val2').value.get() == 1
sleep(2)
assert await cfg.option('val1').value.get() == 2
assert await cfg.option('val2').value.get() == 2
assert await cfg.option('val1').value.get() == 2
assert await cfg.option('val2').value.get() == 2
assert not await list_sessions()