2012-07-13 09:42:14 +02:00
|
|
|
#this test is much more to test that **it's there** and answers attribute access
|
2017-07-09 09:49:03 +02:00
|
|
|
from .autopath import do_autopath
|
2015-07-24 17:54:10 +02:00
|
|
|
do_autopath()
|
|
|
|
|
2019-12-24 15:24:20 +01:00
|
|
|
import pytest
|
2018-03-19 08:33:53 +01:00
|
|
|
from tiramisu import BoolOption, OptionDescription, ChoiceOption,\
|
2018-08-14 23:07:07 +02:00
|
|
|
IntOption, FloatOption, StrOption, Config
|
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 config_type, get_config, event_loop
|
2013-04-20 17:30:05 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
|
|
|
|
def make_description():
|
|
|
|
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
|
|
|
gcdummy2 = BoolOption('hide', 'dummy', default=True)
|
|
|
|
objspaceoption = ChoiceOption('objspace', 'Object space',
|
2013-04-20 17:30:05 +02:00
|
|
|
['std', 'thunk'], 'std')
|
2012-07-13 09:42:14 +02:00
|
|
|
booloption = BoolOption('bool', 'Test boolean option', default=True)
|
|
|
|
intoption = IntOption('int', 'Test int option', default=0)
|
|
|
|
floatoption = FloatOption('float', 'Test float option', default=2.3)
|
|
|
|
stroption = StrOption('str', 'Test string option', default="abc")
|
|
|
|
boolop = BoolOption('boolop', 'Test boolean option op', default=True)
|
|
|
|
wantref_option = BoolOption('wantref', 'Test requires', default=False)
|
|
|
|
wantframework_option = BoolOption('wantframework', 'Test requires',
|
|
|
|
default=False)
|
2012-11-12 12:06:58 +01:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption, gcdummy2])
|
|
|
|
descr = OptionDescription('tiram', '', [gcgroup, booloption, objspaceoption,
|
2013-04-20 17:30:05 +02:00
|
|
|
wantref_option, stroption,
|
|
|
|
wantframework_option,
|
|
|
|
intoption, boolop])
|
2012-07-13 09:42:14 +02:00
|
|
|
return descr
|
|
|
|
|
|
|
|
|
2019-12-24 15:24:20 +01:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
async def test_root_config_answers_ok(config_type):
|
2012-07-13 09:42:14 +02:00
|
|
|
"if you hide the root config, the options in this namespace behave normally"
|
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
|
|
|
boolop = BoolOption('boolop', 'Test boolean option op', default=True)
|
|
|
|
descr = OptionDescription('tiramisu', '', [gcdummy, boolop])
|
2020-01-22 20:46:18 +01:00
|
|
|
async with await Config(descr) as cfg:
|
|
|
|
cfg = await get_config(cfg, config_type)
|
|
|
|
#settings = await cfg.cfgimpl_get_settings()
|
|
|
|
#settings.append('hidden')
|
2018-03-19 08:33:53 +01:00
|
|
|
|
2020-01-22 20:46:18 +01:00
|
|
|
assert await cfg.option('dummy').value.get() is False
|
|
|
|
assert await cfg.option('boolop').value.get() is True
|
|
|
|
assert not await list_sessions()
|
2013-04-20 17:30:05 +02:00
|
|
|
|
2013-02-25 11:33:20 +01:00
|
|
|
|
2019-12-24 15:24:20 +01:00
|
|
|
#@pytest.mark.asyncio
|
|
|
|
# async def test_optname_shall_not_start_with_numbers():
|
2018-12-07 23:33:54 +01:00
|
|
|
# raises(ValueError, "gcdummy = BoolOption('123dummy', 'dummy', default=False)")
|
|
|
|
# raises(ValueError, "descr = OptionDescription('123tiramisu', '', [])")
|
|
|
|
#
|
|
|
|
#
|
2019-12-24 15:24:20 +01:00
|
|
|
@pytest.mark.asyncio
|
|
|
|
async def test_option_has_an_api_name(config_type):
|
2018-11-15 16:17:39 +01:00
|
|
|
b = BoolOption('impl_has_dependency', 'dummy', default=True)
|
|
|
|
descr = OptionDescription('tiramisu', '', [b])
|
2020-01-22 20:46:18 +01:00
|
|
|
async with await Config(descr) as cfg:
|
|
|
|
cfg = await get_config(cfg, config_type)
|
|
|
|
assert await cfg.option('impl_has_dependency').value.get() is True
|
|
|
|
assert b.impl_has_dependency() is False
|
|
|
|
assert not await list_sessions()
|