Merge branch 'master' into orm
This commit is contained in:
commit
2f40216fad
@ -10,10 +10,12 @@ from tiramisu.option import IntOption, FloatOption, StrOption, ChoiceOption, \
|
||||
def make_description():
|
||||
gcoption = ChoiceOption('name', 'GC name', ('ref', 'framework'), 'ref')
|
||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||
prop = BoolOption('prop', '', properties=('disabled',))
|
||||
prop2 = BoolOption('prop', '', properties=('hidden',))
|
||||
objspaceoption = ChoiceOption('objspace', 'Object space',
|
||||
('std', 'thunk'), 'std')
|
||||
booloption = BoolOption('bool', 'Test boolean option', default=True)
|
||||
booloption2 = BoolOption('bool', 'Test boolean option', default=True)
|
||||
booloption2 = BoolOption('bool', 'Test boolean option', default=False)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
floatoption2 = FloatOption('float', 'Test float option', default=2.3)
|
||||
floatoption = FloatOption('float', 'Test float option', default=2.3)
|
||||
@ -21,8 +23,8 @@ def make_description():
|
||||
boolop = BoolOption('boolop', 'Test boolean option op', default=True)
|
||||
wantref_option = BoolOption('wantref', 'Tests', default=False)
|
||||
wantframework_option = BoolOption('wantframework', 'Test', default=False)
|
||||
gcgroup2 = OptionDescription('gc2', '', [booloption2])
|
||||
gcgroup = OptionDescription('gc', '', [gcgroup2, gcoption, gcdummy, floatoption])
|
||||
gcgroup2 = OptionDescription('gc2', '', [booloption2, prop])
|
||||
gcgroup = OptionDescription('gc', '', [gcgroup2, gcoption, gcdummy, floatoption, prop2])
|
||||
descr = OptionDescription('tiramisu', '', [gcgroup, booloption, objspaceoption,
|
||||
wantref_option, stroption,
|
||||
wantframework_option,
|
||||
@ -104,15 +106,22 @@ def test_find_in_config():
|
||||
"finds option in config"
|
||||
descr = make_description()
|
||||
conf = Config(descr)
|
||||
conf.read_only()
|
||||
assert conf.find(byname='dummy') == [conf.unwrap_from_path('gc.dummy')]
|
||||
assert conf.find(byname='float') == [conf.unwrap_from_path('gc.float'), conf.unwrap_from_path('float')]
|
||||
assert conf.find_first(byname='bool') == conf.unwrap_from_path('gc.gc2.bool')
|
||||
assert conf.find_first(byname='bool', byvalue=True) == conf.unwrap_from_path('bool')
|
||||
assert conf.find_first(byname='dummy') == conf.unwrap_from_path('gc.dummy')
|
||||
assert conf.find_first(byname='float') == conf.unwrap_from_path('gc.float')
|
||||
assert conf.find(bytype=ChoiceOption) == [conf.unwrap_from_path('gc.name'), conf.unwrap_from_path('objspace')]
|
||||
assert conf.find_first(bytype=ChoiceOption) == conf.unwrap_from_path('gc.name')
|
||||
assert conf.find(byvalue='ref') == [conf.unwrap_from_path('gc.name')]
|
||||
assert conf.find_first(byvalue='ref') == conf.unwrap_from_path('gc.name')
|
||||
assert conf.find(byname='prop') == [conf.unwrap_from_path('gc.prop')]
|
||||
conf.read_write()
|
||||
raises(AttributeError, "assert conf.find(byname='prop')")
|
||||
assert conf.find(byname='prop', check_properties=False) == [conf.unwrap_from_path('gc.gc2.prop'), conf.unwrap_from_path('gc.prop')]
|
||||
#assert conf.find_first(byname='prop') == conf.unwrap_from_path('gc.prop')
|
||||
# combinaison of filters
|
||||
assert conf.find(bytype=BoolOption, byname='dummy') == [conf.unwrap_from_path('gc.dummy')]
|
||||
assert conf.find_first(bytype=BoolOption, byname='dummy') == conf.unwrap_from_path('gc.dummy')
|
||||
@ -122,7 +131,12 @@ def test_find_in_config():
|
||||
assert conf.gc.find(byname='dummy') == [conf.unwrap_from_path('gc.dummy')]
|
||||
assert conf.gc.find(byname='float') == [conf.unwrap_from_path('gc.float')]
|
||||
assert conf.gc.find(byname='bool') == [conf.unwrap_from_path('gc.gc2.bool')]
|
||||
assert conf.gc.find_first(byname='bool', byvalue=False) == conf.unwrap_from_path('gc.gc2.bool')
|
||||
raises(AttributeError, "assert conf.gc.find_first(byname='bool', byvalue=True)")
|
||||
raises(AttributeError, "conf.gc.find(byname='wantref').first()")
|
||||
assert conf.gc.find(byname='prop', check_properties=False) == [conf.unwrap_from_path('gc.gc2.prop'), conf.unwrap_from_path('gc.prop')]
|
||||
conf.read_only()
|
||||
assert conf.gc.find(byname='prop') == [conf.unwrap_from_path('gc.prop')]
|
||||
# not OptionDescription
|
||||
raises(AttributeError, "conf.find_first(byname='gc')")
|
||||
raises(AttributeError, "conf.gc.find_first(byname='gc2')")
|
||||
|
Loading…
Reference in New Issue
Block a user