tiramisu/tests/test_state.py

48 lines
1.6 KiB
Python
Raw Normal View History

2020-01-22 20:46:18 +01:00
from .autopath import do_autopath
do_autopath()
2019-12-08 09:09:48 +01:00
from tiramisu import BoolOption, StrOption, SymLinkOption, OptionDescription, DynOptionDescription, \
2019-09-01 09:41:53 +02:00
Calculation, Params, ParamOption, ParamValue, calc_value, Config
2017-07-21 18:46:11 +02:00
from pickle import dumps
2019-12-24 15:24:20 +01:00
import pytest
import sys, warnings
2018-10-31 08:00:19 +01:00
from tiramisu.storage import list_sessions
2020-01-22 20:46:18 +01:00
from .config import event_loop
2013-09-30 16:22:08 +02:00
2014-04-14 22:53:40 +02:00
def test_diff_opt():
b = BoolOption('b', '')
2019-09-01 09:41:53 +02:00
disabled_property = Calculation(calc_value,
Params(ParamValue('disabled'),
kwargs={'condition': ParamOption(b),
'expected': ParamValue(True),
2019-12-08 09:09:48 +01:00
'reverse_condition': ParamValue(True)}))
u = StrOption('u', '', properties=(disabled_property,))
2014-04-14 22:53:40 +02:00
s = SymLinkOption('s', u)
o = OptionDescription('o', '', [b, u, s])
o1 = OptionDescription('o1', '', [o])
2020-01-22 20:46:18 +01:00
with pytest.raises(NotImplementedError):
dumps(o1)
2019-12-24 15:24:20 +01:00
@pytest.mark.asyncio
async def test_diff_information_config():
b = BoolOption('b', '')
b.impl_set_information('info', 'oh')
b.impl_set_information('info1', 'oh')
b.impl_set_information('info2', 'oh')
o = OptionDescription('o', '', [b])
o1 = OptionDescription('o1', '', [o])
2020-01-22 20:46:18 +01:00
async with await Config(o1) as cfg:
c = cfg._config_bag.context
with pytest.raises(NotImplementedError):
dumps(c)
assert not await list_sessions()
2015-10-30 22:51:36 +01:00
2014-04-14 22:53:40 +02:00
def test_only_optiondescription():
b = BoolOption('b', '')
2015-07-24 17:54:10 +02:00
b
2020-01-22 20:46:18 +01:00
with pytest.raises(NotImplementedError):
dumps(b)