allow caching with the demoting_error_warning property
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user