add type list for value owners
This commit is contained in:
@ -81,29 +81,30 @@ def test_cannot_override_special_owners():
|
||||
config.gc.setoption('dummy', True, 'auto')
|
||||
raises(SpecialOwnersError, "config.override({'gc.dummy': True})")
|
||||
|
||||
def test_fill_owner():
|
||||
"fill option"
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
assert config.bool == False
|
||||
assert config.gc.dummy == False
|
||||
# 'fill' special values
|
||||
config.gc.setoption('dummy', True, 'fill')
|
||||
assert config.gc.dummy == False
|
||||
# FIXME have to test the fills anyway
|
||||
#def test_fill_owner():
|
||||
# "fill option"
|
||||
# descr = make_description()
|
||||
# config = Config(descr, bool=False)
|
||||
# assert config.bool == False
|
||||
# assert config.gc.dummy == False
|
||||
# # 'fill' special values
|
||||
# config.gc.setoption('dummy', True, 'fill')
|
||||
# assert config.gc.dummy == False
|
||||
|
||||
def test_auto_fill_and_override():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
booloption = config.unwrap_from_path('bool')
|
||||
booloption.callback = 'identical'
|
||||
booloption.setowner(config, 'auto')
|
||||
assert config.bool == 'identicalbool'
|
||||
gcdummy = config.unwrap_from_path('gc.dummy')
|
||||
gcdummy.callback = 'identical'
|
||||
gcdummy.setowner(config.gc, 'fill')
|
||||
raises(SpecialOwnersError, "config.override({'gc.dummy':True})")
|
||||
config.gc.setoption('dummy', False, 'fill')
|
||||
# value is returned
|
||||
assert config.gc.dummy == False
|
||||
#def test_auto_fill_and_override():
|
||||
# descr = make_description()
|
||||
# config = Config(descr, bool=False)
|
||||
# booloption = config.unwrap_from_path('bool')
|
||||
# booloption.callback = 'identical'
|
||||
# booloption.setowner(config, 'auto')
|
||||
# assert config.bool == 'identicalbool'
|
||||
# gcdummy = config.unwrap_from_path('gc.dummy')
|
||||
# gcdummy.callback = 'identical'
|
||||
# gcdummy.setowner(config.gc, 'fill')
|
||||
# raises(SpecialOwnersError, "config.override({'gc.dummy':True})")
|
||||
# config.gc.setoption('dummy', False, 'fill')
|
||||
# # value is returned
|
||||
# assert config.gc.dummy == False
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ def test_idontexist():
|
||||
raises(AttributeError, "cfg.idontexist")
|
||||
# ____________________________________________________________
|
||||
def test_attribute_access_with_multi():
|
||||
s = StrOption("string", "", default="string", multi=True)
|
||||
s = StrOption("string", "", default=["string"], default_multi= "string" , multi=True)
|
||||
descr = OptionDescription("options", "", [s])
|
||||
config = Config(descr)
|
||||
config.string = ["foo", "bar"]
|
||||
@ -60,6 +60,16 @@ def test_item_access_with_multi():
|
||||
assert config.string[0] == 'changetest'
|
||||
# assert config.string[
|
||||
|
||||
def test_access_with_multi_default():
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
descr = OptionDescription("options", "", [s])
|
||||
config = Config(descr)
|
||||
assert config._cfgimpl_value_owners["string"] == ['default']
|
||||
config.string = ["foo", "bar"]
|
||||
assert config.string == ["foo", "bar"]
|
||||
assert config._cfgimpl_value_owners["string"] == ['user', 'user']
|
||||
# assert config.string[
|
||||
|
||||
#def test_attribute_access_with_multi2():
|
||||
# s = StrOption("string", "", default="string", multi=True)
|
||||
# descr = OptionDescription("options", "", [s])
|
||||
@ -68,9 +78,9 @@ def test_item_access_with_multi():
|
||||
# assert config.string == ["foo", "bar"]
|
||||
|
||||
def test_multi_with_requires():
|
||||
s = StrOption("string", "", default="string", multi=True)
|
||||
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",
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"], default_multi = "abc",
|
||||
requires=[('int', 1, 'hide')], multi=True)
|
||||
descr = OptionDescription("options", "", [s, intoption, stroption])
|
||||
config = Config(descr)
|
||||
@ -80,9 +90,9 @@ def test_multi_with_requires():
|
||||
assert stroption._is_hidden()
|
||||
|
||||
def test__requires_with_inverted():
|
||||
s = StrOption("string", "", default="string", multi=True)
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
stroption = StrOption('str', 'Test string option', default="abc",
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"], default_multi = "abc",
|
||||
requires=[('int', 1, 'hide', 'inverted')], multi=True)
|
||||
descr = OptionDescription("options", "", [s, intoption, stroption])
|
||||
config = Config(descr)
|
||||
@ -91,10 +101,10 @@ def test__requires_with_inverted():
|
||||
assert stroption._is_hidden() == False
|
||||
|
||||
def test_multi_with_requires_in_another_group():
|
||||
s = StrOption("string", "", default="string", multi=True)
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default="abc",
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[('int', 1, 'hide')], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
@ -105,10 +115,10 @@ def test_multi_with_requires_in_another_group():
|
||||
assert stroption._is_hidden()
|
||||
|
||||
def test_apply_requires_from_config():
|
||||
s = StrOption("string", "", default="string", multi=True)
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default="abc",
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[('int', 1, 'hide')], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
@ -123,10 +133,10 @@ def test_apply_requires_from_config():
|
||||
|
||||
|
||||
def test_apply_requires_with_disabled():
|
||||
s = StrOption("string", "", default="string", multi=True)
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default="abc",
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[('int', 1, 'disable')], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
@ -140,10 +150,10 @@ def test_apply_requires_with_disabled():
|
||||
assert stroption._is_disabled()
|
||||
|
||||
def test_multi_with_requires_with_disabled_in_another_group():
|
||||
s = StrOption("string", "", default="string", multi=True)
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default="abc",
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[('int', 1, 'disable')], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
@ -154,9 +164,9 @@ def test_multi_with_requires_with_disabled_in_another_group():
|
||||
assert stroption._is_disabled()
|
||||
|
||||
def test_multi_with_requires_that_is_multi():
|
||||
s = StrOption("string", "", default="string", multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0, multi=True)
|
||||
stroption = StrOption('str', 'Test string option', default="abc",
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=[0], multi=True)
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[('int', [1, 1], 'hide')], multi=True)
|
||||
descr = OptionDescription("options", "", [s, intoption, stroption])
|
||||
config = Config(descr)
|
||||
@ -166,7 +176,7 @@ def test_multi_with_requires_that_is_multi():
|
||||
assert stroption._is_hidden()
|
||||
|
||||
def test_multi_with_bool():
|
||||
s = BoolOption("bool", "", default=False, multi=True)
|
||||
s = BoolOption("bool", "", default=[False], multi=True)
|
||||
descr = OptionDescription("options", "", [s])
|
||||
config = Config(descr)
|
||||
assert descr.bool.multi == True
|
||||
@ -175,14 +185,14 @@ def test_multi_with_bool():
|
||||
assert config.bool == [True, False]
|
||||
|
||||
def test_multi_with_bool_two():
|
||||
s = BoolOption("bool", "", default=False, multi=True)
|
||||
s = BoolOption("bool", "", default=[False], multi=True)
|
||||
descr = OptionDescription("options", "", [s])
|
||||
config = Config(descr)
|
||||
assert descr.bool.multi == True
|
||||
raises(ConfigError, "config.bool = True")
|
||||
|
||||
def test_choice_access_with_multi():
|
||||
ch = ChoiceOption("t1", "", ["a", "b"], default="a", multi=True)
|
||||
ch = ChoiceOption("t1", "", ["a", "b"], default=["a"], multi=True)
|
||||
descr = OptionDescription("options", "", [ch])
|
||||
config = Config(descr)
|
||||
config.t1 = ["a", "b", "a", "b"]
|
||||
|
Reference in New Issue
Block a user