2012-07-13 09:42:14 +02:00
|
|
|
"config.set() or config.setoption() or option.setoption()"
|
2017-07-09 09:49:03 +02:00
|
|
|
from .autopath import do_autopath
|
2015-07-24 17:54:10 +02:00
|
|
|
do_autopath()
|
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
from py.test import raises
|
|
|
|
|
2016-09-14 20:17:25 +02:00
|
|
|
from tiramisu.i18n import _
|
2017-07-21 18:03:34 +02:00
|
|
|
from tiramisu.error import display_list, ConfigError
|
2015-11-29 23:03:08 +01:00
|
|
|
from tiramisu.setting import owners, groups
|
2018-03-19 08:33:53 +01:00
|
|
|
from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
2019-02-23 19:06:23 +01:00
|
|
|
StrOption, OptionDescription, Leadership, Config, undefined
|
2013-04-20 21:58:52 +02:00
|
|
|
from tiramisu.error import PropertiesOptionError
|
2018-10-31 08:00:19 +01:00
|
|
|
from tiramisu.storage import list_sessions
|
|
|
|
|
|
|
|
|
|
|
|
def teardown_function(function):
|
|
|
|
assert list_sessions() == [], 'session list is not empty when leaving "{}"'.format(function.__name__)
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
|
|
|
|
def make_description():
|
2013-04-03 12:20:26 +02:00
|
|
|
gcoption = ChoiceOption('name', 'GC name', ('ref', 'framework'), 'ref')
|
2012-07-13 09:42:14 +02:00
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
|
|
|
objspaceoption = ChoiceOption('objspace', 'Object space',
|
2013-04-17 21:50:31 +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',
|
2012-11-12 12:06:58 +01:00
|
|
|
default=False)
|
2012-07-13 09:42:14 +02:00
|
|
|
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
|
|
|
descr = OptionDescription('tiramisu', '', [gcgroup, booloption, objspaceoption,
|
2013-04-17 21:50:31 +02:00
|
|
|
wantref_option, stroption,
|
|
|
|
wantframework_option,
|
|
|
|
intoption, boolop])
|
2012-07-13 09:42:14 +02:00
|
|
|
return descr
|
2013-04-17 21:50:31 +02:00
|
|
|
|
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
#____________________________________________________________
|
|
|
|
# change with __setattr__
|
|
|
|
def test_attribute_access():
|
|
|
|
"Once set, option values can't be changed again by attribute access"
|
|
|
|
s = StrOption("string", "", default="string")
|
|
|
|
descr = OptionDescription("options", "", [s])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2012-07-13 09:42:14 +02:00
|
|
|
# let's try to change it again
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('string').value.set('foo')
|
|
|
|
assert api.option('string').value.get() == 'foo'
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2019-02-22 06:55:34 +01:00
|
|
|
def test_mod_read_only_write():
|
|
|
|
"default with multi is a list"
|
|
|
|
s = StrOption("string", "", default=[], default_multi="string", multi=True)
|
|
|
|
descr = OptionDescription("options", "", [s])
|
|
|
|
config = Config(descr)
|
|
|
|
config2 = Config(descr)
|
|
|
|
assert config.property.getdefault() == {'cache', 'validator', 'warnings'}
|
|
|
|
assert config.property.getdefault('read_only', 'append') == {'frozen',
|
|
|
|
'disabled',
|
|
|
|
'validator',
|
|
|
|
'everything_frozen',
|
|
|
|
'mandatory',
|
|
|
|
'empty',
|
|
|
|
'force_store_value'}
|
|
|
|
assert config.property.getdefault('read_only', 'remove') == {'permissive',
|
|
|
|
'hidden'}
|
|
|
|
assert config.property.getdefault('read_write', 'append') == {'frozen',
|
|
|
|
'disabled',
|
|
|
|
'validator',
|
|
|
|
'hidden',
|
|
|
|
'force_store_value'}
|
|
|
|
assert config.property.getdefault('read_write', 'remove') == {'permissive',
|
|
|
|
'everything_frozen',
|
|
|
|
'mandatory',
|
|
|
|
'empty'}
|
|
|
|
#
|
|
|
|
config.property.setdefault({'cache'})
|
|
|
|
config.property.setdefault(type='read_only', when='append', properties={'disabled'})
|
|
|
|
config.property.setdefault(type='read_only', when='remove', properties={'hidden'})
|
|
|
|
config.property.setdefault(type='read_write', when='append', properties={'disabled',
|
|
|
|
'hidden'})
|
|
|
|
config.property.setdefault(type='read_write', when='remove', properties=set([]))
|
2019-02-24 20:23:16 +01:00
|
|
|
raises(ValueError, "config.property.setdefault(type='unknown', when='append', properties={'disabled'})")
|
|
|
|
raises(ValueError, "config.property.setdefault(type='read_only', when='unknown', properties={'disabled'})")
|
|
|
|
raises(TypeError, "config.property.setdefault(type='read_only', when='append', properties=['disabled'])")
|
2019-02-22 06:55:34 +01:00
|
|
|
|
|
|
|
assert config.property.getdefault() == {'cache'}
|
|
|
|
assert config.property.getdefault('read_only', 'append') == {'disabled'}
|
|
|
|
assert config.property.getdefault('read_only', 'remove') == {'hidden'}
|
|
|
|
assert config.property.getdefault('read_write', 'append') == {'disabled',
|
|
|
|
'hidden'}
|
|
|
|
assert config.property.getdefault('read_write', 'remove') == set([])
|
|
|
|
#
|
|
|
|
config.property.read_only()
|
|
|
|
assert config.property.get() == {'cache', 'disabled'}
|
|
|
|
config.property.read_write()
|
|
|
|
assert config.property.get() == {'cache', 'disabled', 'hidden'}
|
|
|
|
config.property.read_only()
|
|
|
|
assert config.property.get() == {'cache', 'disabled'}
|
|
|
|
#
|
|
|
|
assert config2.property.getdefault() == {'cache', 'validator', 'warnings'}
|
|
|
|
assert config2.property.getdefault('read_only', 'append') == {'frozen',
|
|
|
|
'disabled',
|
|
|
|
'validator',
|
|
|
|
'everything_frozen',
|
|
|
|
'mandatory',
|
|
|
|
'empty',
|
|
|
|
'force_store_value'}
|
|
|
|
assert config2.property.getdefault('read_only', 'remove') == {'permissive',
|
|
|
|
'hidden'}
|
|
|
|
assert config2.property.getdefault('read_write', 'append') == {'frozen',
|
|
|
|
'disabled',
|
|
|
|
'validator',
|
|
|
|
'hidden',
|
|
|
|
'force_store_value'}
|
|
|
|
assert config2.property.getdefault('read_write', 'remove') == {'permissive',
|
|
|
|
'everything_frozen',
|
|
|
|
'mandatory',
|
|
|
|
'empty'}
|
2019-02-24 20:23:16 +01:00
|
|
|
raises(ValueError, "config2.property.getdefault('unknown', 'remove')")
|
|
|
|
raises(ValueError, "config2.property.getdefault('read_write', 'unknown')")
|
2019-02-22 06:55:34 +01:00
|
|
|
|
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_setitem():
|
|
|
|
s = StrOption("string", "", default=["string", "sdfsdf"], default_multi="prout", multi=True)
|
|
|
|
descr = OptionDescription("options", "", [s])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('string').value.set([undefined, 'foo'])
|
|
|
|
assert api.option('string').value.get() == ['string', 'foo']
|
2012-11-12 12:06:58 +01:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_reset():
|
|
|
|
"if value is None, resets to default owner"
|
|
|
|
s = StrOption("string", "", default="string")
|
|
|
|
descr = OptionDescription("options", "", [s])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('string').value.set('foo')
|
|
|
|
assert api.option('string').value.get() == "foo"
|
|
|
|
assert api.option('string').owner.get() ==owners.user
|
|
|
|
api.option('string').value.reset()
|
|
|
|
assert api.option('string').value.get() == 'string'
|
|
|
|
assert api.option('string').owner.get() ==owners.default
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_reset_with_multi():
|
2013-04-17 21:50:31 +02:00
|
|
|
s = StrOption("string", "", default=["string"], default_multi="string", multi=True)
|
2012-07-13 09:42:14 +02:00
|
|
|
descr = OptionDescription("options", "", [s])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
# api.option('string').value.set([])
|
|
|
|
api.option('string').value.reset()
|
|
|
|
assert api.option('string').value.get() == ["string"]
|
|
|
|
assert api.option('string').owner.get() =='default'
|
|
|
|
api.option('string').value.set(["eggs", "spam", "foo"])
|
|
|
|
assert api.option('string').owner.get() =='user'
|
|
|
|
api.option('string').value.set([])
|
|
|
|
api.option('string').value.reset()
|
|
|
|
# assert api.option('string').value.get() == ["string"]
|
|
|
|
assert api.option('string').owner.get() =='default'
|
|
|
|
raises(ValueError, "api.option('string').value.set(None)")
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2018-10-29 21:01:01 +01:00
|
|
|
def test_property_only_raises():
|
|
|
|
s = StrOption("string", "", default=["string"], default_multi="string", multi=True)
|
|
|
|
intoption = IntOption('int', 'Test int option', default=0)
|
|
|
|
stroption = StrOption('str', 'Test string option', default=["abc"], default_multi="abc",
|
|
|
|
requires=[{'option': intoption, 'expected': 1, 'action': 'hidden'}], multi=True)
|
|
|
|
descr = OptionDescription("options", "", [s, intoption, stroption])
|
|
|
|
api = Config(descr)
|
|
|
|
api.property.read_write()
|
|
|
|
assert api.option('str').property.get() == {'empty'}
|
|
|
|
assert api.option('str').property.get(only_raises=True) == set()
|
|
|
|
|
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_default_with_multi():
|
|
|
|
"default with multi is a list"
|
2013-04-17 21:50:31 +02:00
|
|
|
s = StrOption("string", "", default=[], default_multi="string", multi=True)
|
2012-07-13 09:42:14 +02:00
|
|
|
descr = OptionDescription("options", "", [s])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
assert api.option('string').value.get() == []
|
2013-04-17 21:50:31 +02:00
|
|
|
s = StrOption("string", "", default=None, default_multi="string", multi=True)
|
2012-07-13 09:42:14 +02:00
|
|
|
descr = OptionDescription("options", "", [s])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
assert api.option('string').value.get() == []
|
2012-11-12 12:06:58 +01:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_idontexist():
|
|
|
|
descr = make_description()
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-09-09 12:21:47 +02:00
|
|
|
api.value.dict()
|
2018-03-19 08:33:53 +01:00
|
|
|
raises(AttributeError, "api.option('idontexist').value.get()")
|
2013-04-17 21:50:31 +02:00
|
|
|
|
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
# ____________________________________________________________
|
|
|
|
def test_attribute_access_with_multi():
|
2013-04-17 21:50:31 +02:00
|
|
|
s = StrOption("string", "", default=["string"], default_multi="string", multi=True)
|
2012-07-13 09:42:14 +02:00
|
|
|
descr = OptionDescription("options", "", [s])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('string').value.set(["foo", "bar"])
|
|
|
|
assert api.option('string').value.get() == ["foo", "bar"]
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_item_access_with_multi():
|
|
|
|
s = StrOption("string", "", default=["string"], multi=True)
|
|
|
|
descr = OptionDescription("options", "", [s])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('string').value.set(["foo", "bar"])
|
|
|
|
assert api.option('string').value.get() == ["foo", "bar"]
|
|
|
|
api.option('string').value.set(["changetest", "bar"])
|
|
|
|
assert api.option('string').value.get() == ["changetest", "bar"]
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_access_with_multi_default():
|
|
|
|
s = StrOption("string", "", default=["string"], multi=True)
|
|
|
|
descr = OptionDescription("options", "", [s])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
assert api.option('string').owner.get() =='default'
|
|
|
|
api.option('string').value.set(["foo", "bar"])
|
|
|
|
assert api.option('string').value.get() == ["foo", "bar"]
|
|
|
|
assert api.option('string').owner.get() =='user'
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_multi_with_requires():
|
|
|
|
s = StrOption("string", "", default=["string"], default_multi="string", multi=True)
|
|
|
|
intoption = IntOption('int', 'Test int option', default=0)
|
2013-04-17 21:50:31 +02:00
|
|
|
stroption = StrOption('str', 'Test string option', default=["abc"], default_multi="abc",
|
2013-06-29 18:41:14 +02:00
|
|
|
requires=[{'option': intoption, 'expected': 1, 'action': 'hidden'}], multi=True)
|
2012-07-13 09:42:14 +02:00
|
|
|
descr = OptionDescription("options", "", [s, intoption, stroption])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.read_write()
|
|
|
|
assert not 'hidden' in api.option('str').property.get()
|
|
|
|
api.option('int').value.set(1)
|
|
|
|
raises(PropertiesOptionError, "api.option('str').value.set(['a', 'b'])")
|
2018-04-06 08:30:32 +02:00
|
|
|
assert 'hidden' in api.forcepermissive.option('str').property.get()
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test__requires_with_inverted():
|
|
|
|
s = StrOption("string", "", default=["string"], multi=True)
|
|
|
|
intoption = IntOption('int', 'Test int option', default=0)
|
2013-04-17 21:50:31 +02:00
|
|
|
stroption = StrOption('str', 'Test string option', default=["abc"], default_multi="abc",
|
2013-06-29 18:41:14 +02:00
|
|
|
requires=[{'option': intoption, 'expected': 1, 'action': 'hide', 'inverse': True}], multi=True)
|
2012-07-13 09:42:14 +02:00
|
|
|
descr = OptionDescription("options", "", [s, intoption, stroption])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
assert not 'hidden' in api.option('str').property.get()
|
|
|
|
api.option('int').value.set(1)
|
|
|
|
assert not 'hidden' in api.option('str').property.get()
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_multi_with_requires_in_another_group():
|
|
|
|
s = StrOption("string", "", default=["string"], multi=True)
|
|
|
|
intoption = IntOption('int', 'Test int option', default=0)
|
2012-11-12 12:06:58 +01:00
|
|
|
stroption = StrOption('str', 'Test string option', default=["abc"],
|
2013-06-29 18:41:14 +02:00
|
|
|
requires=[{'option': intoption, 'expected': 1, 'action': 'hidden'}], multi=True)
|
2012-07-13 09:42:14 +02:00
|
|
|
descr = OptionDescription("opt", "", [stroption])
|
|
|
|
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr2)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.read_write()
|
|
|
|
assert not 'hidden' in api.option('opt.str').property.get()
|
|
|
|
api.option('int').value.set(1)
|
|
|
|
raises(PropertiesOptionError, "api.option('opt.str').value.set(['a', 'b'])")
|
2018-04-06 08:30:32 +02:00
|
|
|
assert 'hidden' in api.forcepermissive.option('opt.str').property.get()
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2017-01-30 19:23:52 +01:00
|
|
|
def test_multi_with_requires_in_another_group_inverse():
|
|
|
|
s = StrOption("string", "", default=["string"], multi=True)
|
|
|
|
intoption = IntOption('int', 'Test int option', default=0)
|
|
|
|
stroption = StrOption('str', 'Test string option', default=["abc"],
|
|
|
|
requires=[{'option': intoption, 'expected': 0, 'action': 'hidden', 'inverse': True}], multi=True)
|
|
|
|
descr = OptionDescription("opt", "", [stroption])
|
|
|
|
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr2)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.read_write()
|
|
|
|
assert not 'hidden' in api.option('opt.str').property.get()
|
|
|
|
api.option('int').value.set(1)
|
|
|
|
raises(PropertiesOptionError, "api.option('opt.str').value.set(['a', 'b'])")
|
2018-04-06 08:30:32 +02:00
|
|
|
assert 'hidden' in api.forcepermissive.option('opt.str').property.get()
|
2017-01-30 19:23:52 +01:00
|
|
|
|
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_apply_requires_from_config():
|
|
|
|
s = StrOption("string", "", default=["string"], multi=True)
|
|
|
|
intoption = IntOption('int', 'Test int option', default=0)
|
2012-11-12 12:06:58 +01:00
|
|
|
stroption = StrOption('str', 'Test string option', default=["abc"],
|
2013-06-29 18:41:14 +02:00
|
|
|
requires=[{'option': intoption, 'expected': 1, 'action': 'hidden'}], multi=True)
|
2012-07-13 09:42:14 +02:00
|
|
|
descr = OptionDescription("opt", "", [stroption])
|
|
|
|
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr2)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.read_write()
|
|
|
|
assert not 'hidden' in api.option('opt.str').property.get()
|
|
|
|
api.option('int').value.set(1)
|
|
|
|
raises(PropertiesOptionError, "api.option('opt.str').value.get()")
|
2018-04-06 08:30:32 +02:00
|
|
|
assert 'hidden' in api.forcepermissive.option('opt.str').property.get()
|
2018-12-08 00:02:23 +01:00
|
|
|
assert 'hidden' not in api.forcepermissive.option('opt.str').option.properties()
|
2019-02-24 20:23:16 +01:00
|
|
|
assert 'hidden' not in api.forcepermissive.option('opt.str').option.properties(only_raises=True)
|
2012-11-12 12:06:58 +01:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
|
|
|
|
def test_apply_requires_with_disabled():
|
|
|
|
s = StrOption("string", "", default=["string"], multi=True)
|
|
|
|
intoption = IntOption('int', 'Test int option', default=0)
|
2012-11-12 12:06:58 +01:00
|
|
|
stroption = StrOption('str', 'Test string option', default=["abc"],
|
2013-06-29 18:41:14 +02:00
|
|
|
requires=[{'option': intoption, 'expected': 1, 'action': 'disabled'}], multi=True)
|
2012-07-13 09:42:14 +02:00
|
|
|
descr = OptionDescription("opt", "", [stroption])
|
|
|
|
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr2)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.read_write()
|
|
|
|
assert not 'disabled' in api.option('opt.str').property.get()
|
|
|
|
api.option('int').value.set(1)
|
|
|
|
raises(PropertiesOptionError, "api.option('opt.str').value.get()")
|
2018-12-08 00:02:23 +01:00
|
|
|
assert 'disabled' not in api.unrestraint.option('opt.str').option.properties()
|
2019-02-24 20:23:16 +01:00
|
|
|
assert 'disabled' not in api.unrestraint.option('opt.str').option.properties(only_raises=True)
|
2018-04-06 08:30:32 +02:00
|
|
|
assert 'disabled' in api.unrestraint.option('opt.str').property.get()
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_multi_with_requires_with_disabled_in_another_group():
|
|
|
|
s = StrOption("string", "", default=["string"], multi=True)
|
|
|
|
intoption = IntOption('int', 'Test int option', default=0)
|
2012-11-12 12:06:58 +01:00
|
|
|
stroption = StrOption('str', 'Test string option', default=["abc"],
|
2013-06-29 18:41:14 +02:00
|
|
|
requires=[{'option': intoption, 'expected': 1, 'action': 'disabled'}], multi=True)
|
2012-07-13 09:42:14 +02:00
|
|
|
descr = OptionDescription("opt", "", [stroption])
|
|
|
|
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr2)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.read_write()
|
|
|
|
assert not 'disabled' in api.option('opt.str').property.get()
|
|
|
|
api.option('int').value.set(1)
|
|
|
|
raises(PropertiesOptionError, "api.option('opt.str').value.set(['a', 'b'])")
|
2018-04-06 08:30:32 +02:00
|
|
|
assert 'disabled' in api.unrestraint.option('opt.str').property.get()
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_multi_with_requires_that_is_multi():
|
2015-11-29 23:03:08 +01:00
|
|
|
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
|
|
|
c = StrOption('str', 'Test string option', default=['abc'], requires=[{'option': b, 'expected': 1, 'action': 'hidden'}], multi=True)
|
|
|
|
descr = OptionDescription("opt", "", [b, c])
|
|
|
|
descr
|
|
|
|
raises(ValueError, "Config(descr)")
|
|
|
|
|
|
|
|
|
2017-01-30 19:23:52 +01:00
|
|
|
def test_multi_with_requires_that_is_multi_inverse():
|
|
|
|
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
|
|
|
c = StrOption('str', 'Test string option', default=['abc'], requires=[{'option': b, 'expected': 0, 'action': 'hidden', 'inverse': True}], multi=True)
|
|
|
|
descr = OptionDescription("opt", "", [b, c])
|
|
|
|
descr
|
|
|
|
raises(ValueError, "Config(descr)")
|
|
|
|
|
|
|
|
|
2019-02-23 19:06:23 +01:00
|
|
|
def test_multi_with_requires_that_is_leadership():
|
2015-11-29 23:03:08 +01:00
|
|
|
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
|
|
|
c = StrOption('str', 'Test string option', requires=[{'option': b, 'expected': 1, 'action': 'hidden'}], multi=True)
|
2019-02-23 19:06:23 +01:00
|
|
|
descr = Leadership("int", "", [b, c])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [descr])
|
|
|
|
Config(od)
|
2015-11-29 23:03:08 +01:00
|
|
|
|
|
|
|
|
2019-02-23 19:06:23 +01:00
|
|
|
def test_multi_with_requires_that_is_leadership_leader():
|
2015-11-29 23:03:08 +01:00
|
|
|
b = IntOption('int', 'Test int option', multi=True)
|
|
|
|
c = StrOption('str', 'Test string option', requires=[{'option': b, 'expected': 1, 'action': 'hidden'}], multi=True)
|
2019-02-23 19:06:23 +01:00
|
|
|
raises(ValueError, "Leadership('str', '', [c, b])")
|
2015-11-29 23:03:08 +01:00
|
|
|
|
|
|
|
|
2019-02-23 19:06:23 +01:00
|
|
|
def test_multi_with_requires_that_is_leadership_follower():
|
2015-11-29 23:03:08 +01:00
|
|
|
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
|
|
|
c = StrOption('str', 'Test string option', multi=True)
|
|
|
|
d = StrOption('str1', 'Test string option', requires=[{'option': c, 'expected': '1', 'action': 'hidden'}], multi=True)
|
2019-02-23 19:06:23 +01:00
|
|
|
descr = Leadership("int", "", [b, c, d])
|
2018-03-19 08:33:53 +01:00
|
|
|
descr2 = OptionDescription('od', '', [descr])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr2)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.read_write()
|
|
|
|
assert api.option('int.int').value.get() == [0]
|
|
|
|
assert api.option('int.str', 0).value.get() == None
|
|
|
|
assert api.option('int.str1', 0).value.get() == None
|
|
|
|
api.option('int.int').value.set([0, 1])
|
|
|
|
assert api.option('int.int').value.get() == [0, 1]
|
|
|
|
assert api.option('int.str', 0).value.get() == None
|
|
|
|
assert api.option('int.str', 1).value.get() == None
|
|
|
|
assert api.option('int.str1', 0).value.get() == None
|
|
|
|
assert api.option('int.str1', 1).value.get() == None
|
|
|
|
api.option('int.str', 1).value.set('1')
|
|
|
|
api.property.read_only()
|
|
|
|
assert api.option('int.str1', 0).value.get() == None
|
|
|
|
assert api.option('int.str1', 1).value.get() == None
|
|
|
|
api.property.read_write()
|
|
|
|
assert api.option('int.str1', 0).value.get() == None
|
|
|
|
raises(PropertiesOptionError, "api.option('int.str1', 1).value.get()")
|
2015-11-29 23:03:08 +01:00
|
|
|
|
2017-01-30 19:23:52 +01:00
|
|
|
|
2019-02-23 19:06:23 +01:00
|
|
|
def test_multi_with_requires_that_is_leadership_follower_inverse():
|
2017-01-30 19:23:52 +01:00
|
|
|
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
|
|
|
c = StrOption('str', 'Test string option', multi=True)
|
|
|
|
d = StrOption('str1', 'Test string option', requires=[{'option': c, 'expected': None, 'action': 'hidden', 'inverse': True}], multi=True)
|
2019-02-23 19:06:23 +01:00
|
|
|
descr = Leadership("int", "", [b, c, d])
|
2018-03-19 08:33:53 +01:00
|
|
|
descr2 = OptionDescription('od', '', [descr])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr2)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.read_write()
|
|
|
|
assert api.option('int.int').value.get() == [0]
|
|
|
|
assert api.option('int.str', 0).value.get() is None
|
|
|
|
assert api.option('int.str1', 0).value.get() is None
|
|
|
|
api.option('int.int').value.set([0, 1])
|
|
|
|
assert api.option('int.int').value.get() == [0, 1]
|
|
|
|
assert api.option('int.str', 0).value.get() is None
|
|
|
|
assert api.option('int.str', 1).value.get() is None
|
|
|
|
assert api.option('int.str1', 0).value.get() is None
|
|
|
|
assert api.option('int.str1', 1).value.get() is None
|
|
|
|
api.option('int.str', 1).value.set('1')
|
|
|
|
api.property.read_only()
|
|
|
|
assert api.option('int.str1', 0).value.get() is None
|
|
|
|
assert api.option('int.str1', 1).value.get() is None
|
|
|
|
api.property.read_write()
|
|
|
|
assert api.option('int.str1', 0).value.get() is None
|
|
|
|
raises(PropertiesOptionError, "api.option('int.str1', 1).value.get()")
|
2017-01-30 19:23:52 +01:00
|
|
|
|
|
|
|
|
2019-02-23 19:06:23 +01:00
|
|
|
def test_multi_with_requires_that_is_not_same_leadership():
|
2015-11-29 23:03:08 +01:00
|
|
|
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
|
|
|
c = StrOption('str', 'Test string option', requires=[{'option': b, 'expected': 1, 'action': 'hidden'}], multi=True)
|
2019-02-23 19:06:23 +01:00
|
|
|
descr1 = Leadership("int", "", [b, c])
|
2015-11-29 23:03:08 +01:00
|
|
|
d = IntOption('int1', 'Test int option', default=[0], multi=True)
|
|
|
|
e = StrOption('str', 'Test string option', requires=[{'option': b, 'expected': 1, 'action': 'hidden'}], multi=True)
|
2019-02-23 19:06:23 +01:00
|
|
|
descr2 = Leadership("int1", "", [d, e])
|
2015-11-29 23:03:08 +01:00
|
|
|
descr3 = OptionDescription('val', '', [descr1, descr2])
|
|
|
|
descr3
|
|
|
|
raises(ValueError, "Config(descr3)")
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_multi_with_bool():
|
|
|
|
s = BoolOption("bool", "", default=[False], multi=True)
|
|
|
|
descr = OptionDescription("options", "", [s])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('bool').value.set([True, False])
|
|
|
|
assert api.option('bool').value.get() == [True, False]
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_choice_access_with_multi():
|
2013-04-03 12:20:26 +02:00
|
|
|
ch = ChoiceOption("t1", "", ("a", "b"), default=["a"], multi=True)
|
2012-07-13 09:42:14 +02:00
|
|
|
descr = OptionDescription("options", "", [ch])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('t1').value.set(["a", "b", "a", "b"])
|
|
|
|
assert api.option('t1').value.get() == ["a", "b", "a", "b"]
|
2013-04-17 21:50:31 +02:00
|
|
|
|
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
#____________________________________________________________
|
2013-04-22 09:19:05 +02:00
|
|
|
def test_accepts_multiple_changes_from_option():
|
|
|
|
s = StrOption("string", "", default="string")
|
|
|
|
descr = OptionDescription("options", "", [s])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('string').value.set("egg")
|
|
|
|
assert api.option('string').option.default() == "string"
|
|
|
|
assert api.option('string').value.get() == "egg"
|
|
|
|
api.option('string').value.set('blah')
|
|
|
|
assert api.option('string').option.default() == "string"
|
|
|
|
assert api.option('string').value.get() == "blah"
|
|
|
|
api.option('string').value.set('bol')
|
|
|
|
assert api.option('string').value.get() == 'bol'
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_allow_multiple_changes_from_config():
|
|
|
|
"""
|
2012-11-12 12:06:58 +01:00
|
|
|
a `setoption` from the config object is much like the attribute access,
|
|
|
|
except the fact that value owner can bet set
|
2012-07-13 09:42:14 +02:00
|
|
|
"""
|
|
|
|
s = StrOption("string", "", default="string")
|
|
|
|
s2 = StrOption("string2", "", default="string")
|
|
|
|
suboption = OptionDescription("bip", "", [s2])
|
|
|
|
descr = OptionDescription("options", "", [s, suboption])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('string').value.set("oh")
|
|
|
|
assert api.option('string').value.get() == "oh"
|
|
|
|
api.option('string').value.set("blah")
|
|
|
|
assert api.option('string').value.get() == "blah"
|
2013-04-17 21:50:31 +02:00
|
|
|
|
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
# ____________________________________________________________
|
2012-12-10 14:10:05 +01:00
|
|
|
# accessing a value by the get method
|
2012-07-13 09:42:14 +02:00
|
|
|
def test_access_by_get():
|
|
|
|
descr = make_description()
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-10-07 10:55:52 +02:00
|
|
|
raises(AttributeError, "list(api.option.find('idontexist'))")
|
2018-04-10 12:33:51 +02:00
|
|
|
assert api.option.find('wantref', first=True).value.get() is False
|
|
|
|
assert api.option.find('dummy', first=True).value.get() is False
|
2013-04-17 21:50:31 +02:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
|
|
|
|
def test_access_by_get_whith_hide():
|
2013-04-03 12:20:26 +02:00
|
|
|
b1 = BoolOption("b1", "", properties=(('hidden'),))
|
2013-04-17 21:50:31 +02:00
|
|
|
descr = OptionDescription("opt", "",
|
|
|
|
[OptionDescription("sub", "",
|
|
|
|
[b1, ChoiceOption("c1", "", ('a', 'b', 'c'), 'a'),
|
|
|
|
BoolOption("d1", "")]),
|
|
|
|
BoolOption("b2", ""),
|
|
|
|
BoolOption("d1", "")])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.read_write()
|
2018-04-10 12:33:51 +02:00
|
|
|
raises(AttributeError, "api.option.find('b1').value.get()")
|
2014-03-08 18:53:22 +01:00
|
|
|
|
|
|
|
|
2013-07-13 10:42:10 +02:00
|
|
|
def test_append_properties():
|
|
|
|
descr = make_description()
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
assert api.option('gc.dummy').property.get() == set()
|
|
|
|
api.option('gc.dummy').property.add('test')
|
|
|
|
assert api.option('gc.dummy').property.get() == {'test'}
|
|
|
|
raises(ConfigError, "api.option('gc.dummy').property.add('force_store_value')")
|
|
|
|
assert api.option('gc.dummy').property.get() == {'test'}
|
2013-07-13 10:42:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_reset_properties():
|
|
|
|
descr = make_description()
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
assert api.option('gc.dummy').property.get() == set()
|
|
|
|
api.option('gc.dummy').property.add('frozen')
|
|
|
|
assert api.option('gc.dummy').property.get() == {'frozen'}
|
|
|
|
api.option('gc.dummy').property.reset()
|
|
|
|
assert api.option('gc.dummy').property.get() == set()
|
2014-02-20 14:27:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_properties_cached():
|
|
|
|
b1 = BoolOption("b1", "", properties=('test',))
|
|
|
|
descr = OptionDescription("opt", "", [OptionDescription("sub", "", [b1])])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.read_write()
|
|
|
|
assert api.option('sub.b1').property.get() == {'test'}
|
2016-01-25 15:49:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_append_properties_force_store_value():
|
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False, properties=('force_store_value',))
|
|
|
|
gcgroup = OptionDescription('gc', '', [gcdummy])
|
|
|
|
descr = OptionDescription('tiramisu', '', [gcgroup])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
assert api.option('gc.dummy').property.get() == {'force_store_value'}
|
|
|
|
api.option('gc.dummy').property.add('test')
|
|
|
|
assert api.option('gc.dummy').property.get() == {'force_store_value', 'test'}
|
2016-01-25 15:49:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_reset_properties_force_store_value():
|
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False, properties=('force_store_value',))
|
|
|
|
gcgroup = OptionDescription('gc', '', [gcdummy])
|
|
|
|
descr = OptionDescription('tiramisu', '', [gcgroup])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-04-04 21:51:18 +02:00
|
|
|
assert api.property.exportation() == {}
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.add('frozen')
|
2018-10-31 08:00:19 +01:00
|
|
|
assert api.property.exportation() == \
|
|
|
|
{None: set(('frozen', 'cache', 'validator', 'warnings'))}
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.reset()
|
2018-04-04 21:51:18 +02:00
|
|
|
assert api.property.exportation() == {}
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('gc.dummy').property.add('test')
|
2018-04-04 21:51:18 +02:00
|
|
|
assert api.property.exportation() == {'gc.dummy': set(('test', 'force_store_value'))}
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.reset()
|
2018-04-04 21:51:18 +02:00
|
|
|
assert api.property.exportation() == {'gc.dummy': set(('test', 'force_store_value'))}
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.add('frozen')
|
2018-10-31 08:00:19 +01:00
|
|
|
assert api.property.exportation() == \
|
|
|
|
{None: set(('frozen', 'validator', 'cache', 'warnings')),
|
|
|
|
'gc.dummy': set(('test', 'force_store_value'))}
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.add('frozen')
|
2018-10-31 08:00:19 +01:00
|
|
|
assert api.property.exportation() == \
|
|
|
|
{None: set(('frozen', 'validator', 'cache', 'warnings')),
|
|
|
|
'gc.dummy': set(('test', 'force_store_value'))}
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('gc.dummy').property.add('test')
|
2018-10-31 08:00:19 +01:00
|
|
|
assert api.property.exportation() == \
|
|
|
|
{None: set(('frozen', 'validator', 'cache', 'warnings')),
|
|
|
|
'gc.dummy': set(('test', 'force_store_value'))}
|
2016-09-14 20:17:25 +02:00
|
|
|
|
|
|
|
|
2019-02-25 08:46:58 +01:00
|
|
|
def test_importation_force_store_value():
|
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False,
|
|
|
|
properties=('force_store_value',))
|
|
|
|
gcgroup = OptionDescription('gc', '', [gcdummy])
|
|
|
|
descr = OptionDescription('tiramisu', '', [gcgroup])
|
|
|
|
config1 = Config(descr)
|
|
|
|
assert config1.value.exportation() == [[], [], [], []]
|
|
|
|
config1.property.add('frozen')
|
|
|
|
assert config1.value.exportation() == [[], [], [], []]
|
|
|
|
config1.property.add('force_store_value')
|
|
|
|
assert config1.value.exportation() == [['gc.dummy'], [None], [False], ['forced']]
|
|
|
|
exportation = config1.property.exportation()
|
|
|
|
config2 = Config(descr)
|
|
|
|
assert config2.value.exportation() == [[], [], [], []]
|
|
|
|
config2.property.importation(exportation)
|
|
|
|
assert config2.value.exportation() == [['gc.dummy'], [None], [False], ['forced']]
|
|
|
|
config2.property.importation(exportation)
|
|
|
|
assert config2.value.exportation() == [['gc.dummy'], [None], [False], ['forced']]
|
|
|
|
|
|
|
|
|
2017-07-13 22:04:06 +02:00
|
|
|
def test_set_modified_value():
|
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False, properties=('force_store_value',))
|
|
|
|
gcgroup = OptionDescription('gc', '', [gcdummy])
|
|
|
|
descr = OptionDescription('tiramisu', '', [gcgroup])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-04-04 21:51:18 +02:00
|
|
|
assert api.property.exportation() == {}
|
|
|
|
api.property.importation({None: set(('frozen', 'cache', 'validator', 'warnings'))})
|
|
|
|
assert api.property.exportation() == \
|
2018-03-19 08:33:53 +01:00
|
|
|
{None: set(('frozen', 'cache', 'validator', 'warnings'))}
|
2017-07-13 22:04:06 +02:00
|
|
|
|
|
|
|
|
2016-09-14 20:17:25 +02:00
|
|
|
def test_pprint():
|
2018-10-31 08:00:19 +01:00
|
|
|
msg_error = _("cannot access to {0} \"{1}\" because has {2} {3}")
|
|
|
|
msg_is_not = _('the value of "{0}" is not {1}')
|
2019-04-08 08:41:33 +02:00
|
|
|
msg_is = _('the value of "{0}" is {1}')
|
2017-01-19 21:38:16 +01:00
|
|
|
properties = _('properties')
|
|
|
|
prop = _('property')
|
2016-09-14 20:17:25 +02:00
|
|
|
|
|
|
|
s = StrOption("string", "", default=["string"], default_multi="string", multi=True, properties=('hidden', 'disabled'))
|
|
|
|
s2 = StrOption("string2", "", default="string")
|
|
|
|
s3 = StrOption("string3", "", default=["string"], default_multi="string", multi=True, properties=('hidden',))
|
|
|
|
intoption = IntOption('int', 'Test int option', default=0)
|
|
|
|
stroption = StrOption('str', 'Test string option', default="abc",
|
|
|
|
requires=[{'option': intoption, 'expected': 2, 'action': 'hidden', 'inverse': True},
|
|
|
|
{'option': intoption, 'expected': 3, 'action': 'hidden', 'inverse': True},
|
|
|
|
{'option': intoption, 'expected': 4, 'action': 'hidden', 'inverse': True},
|
|
|
|
{'option': intoption, 'expected': 1, 'action': 'disabled'},
|
|
|
|
{'option': s2, 'expected': 'string', 'action': 'disabled'}])
|
|
|
|
|
|
|
|
val2 = StrOption('val2', "")
|
|
|
|
descr2 = OptionDescription("options", "", [val2], requires=[{'option': intoption, 'expected': 1, 'action': 'hidden'}])
|
|
|
|
|
|
|
|
val3 = StrOption('val3', "", requires=[{'option': stroption, 'expected': '2', 'action': 'hidden', 'inverse': True}])
|
|
|
|
|
|
|
|
descr = OptionDescription("options", "", [s, s2, s3, intoption, stroption, descr2, val3])
|
2018-08-14 23:07:07 +02:00
|
|
|
api = Config(descr)
|
2018-03-19 08:33:53 +01:00
|
|
|
api.property.read_write()
|
|
|
|
api.option('int').value.set(1)
|
2017-07-09 09:49:03 +02:00
|
|
|
err = None
|
2016-09-14 20:17:25 +02:00
|
|
|
try:
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('str').value.get()
|
|
|
|
except PropertiesOptionError as error:
|
2017-07-09 09:49:03 +02:00
|
|
|
err = error
|
2016-09-14 20:17:25 +02:00
|
|
|
|
2019-04-13 22:04:49 +02:00
|
|
|
list_disabled = '"disabled" (' + display_list([msg_is.format('Test int option', '"1"'), msg_is.format('string2', '"string"')], add_quote=False) + ')'
|
2018-10-31 08:00:19 +01:00
|
|
|
list_hidden = '"hidden" (' + msg_is_not.format('Test int option', display_list([2, 3, 4], 'or', add_quote=True)) + ')'
|
2019-04-13 22:04:49 +02:00
|
|
|
assert str(err) == _(msg_error.format('option', 'Test string option', properties, display_list([list_disabled, list_hidden], add_quote=False)))
|
2018-10-31 08:00:19 +01:00
|
|
|
del err
|
2016-09-14 20:17:25 +02:00
|
|
|
|
2017-07-09 09:49:03 +02:00
|
|
|
err = None
|
2016-09-14 20:17:25 +02:00
|
|
|
try:
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('options.val2').value.get()
|
|
|
|
except PropertiesOptionError as error:
|
2017-07-09 09:49:03 +02:00
|
|
|
err = error
|
2016-09-14 20:17:25 +02:00
|
|
|
|
2019-04-08 08:41:33 +02:00
|
|
|
assert str(err) == msg_error.format('optiondescription', 'options', prop, '"hidden" (' + msg_is.format('Test int option', '"1"') + ')')
|
2016-09-14 20:17:25 +02:00
|
|
|
|
2018-03-31 23:09:40 +02:00
|
|
|
#err = None
|
|
|
|
#try:
|
|
|
|
# api.option('val3').value.get()
|
|
|
|
#except PropertiesOptionError as error:
|
|
|
|
# err = error
|
|
|
|
|
|
|
|
#msg_1 = msg_is.format('string2', 'string')
|
|
|
|
#msg_2 = msg_is.format('Test int option', 1)
|
2018-10-31 08:00:19 +01:00
|
|
|
#msg_3 = msg_is_not.format('Test int option', display_list([2, 3, 4], 'or', add_quote=True))
|
|
|
|
#list_hidden = '"hidden" (' + display_list([msg_2, msg_3, msg_1]) + ')'
|
2018-03-31 23:09:40 +02:00
|
|
|
|
|
|
|
#assert str(err) == msg_error.format('option', 'val3', prop, list_hidden)
|
2016-09-14 20:17:25 +02:00
|
|
|
|
2017-07-09 09:49:03 +02:00
|
|
|
err = None
|
2016-09-14 20:17:25 +02:00
|
|
|
try:
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('string').value.get()
|
2017-07-09 09:49:03 +02:00
|
|
|
except Exception as error:
|
|
|
|
err = error
|
2016-09-14 20:17:25 +02:00
|
|
|
|
2018-10-31 08:00:19 +01:00
|
|
|
assert str(err) == msg_error.format('option', 'string', properties, display_list(['disabled', 'hidden'], add_quote=True))
|
|
|
|
del err
|
2016-09-14 20:17:25 +02:00
|
|
|
|
2017-07-09 09:49:03 +02:00
|
|
|
err = None
|
2016-09-14 20:17:25 +02:00
|
|
|
try:
|
2018-03-19 08:33:53 +01:00
|
|
|
api.option('string3').value.get()
|
2017-07-09 09:49:03 +02:00
|
|
|
except Exception as error:
|
|
|
|
err = error
|
2016-09-14 20:17:25 +02:00
|
|
|
|
2018-10-31 08:00:19 +01:00
|
|
|
assert str(err) == msg_error.format('option', 'string3', prop, '"hidden"')
|
|
|
|
del err
|