requirement are now a dictionary (not anymore a tuple)
This commit is contained in:
@ -21,10 +21,10 @@ def make_description_freeze():
|
||||
stroption = StrOption('str', 'Test string option', default="abc")
|
||||
boolop = BoolOption('boolop', 'Test boolean option op', default=[True], multi=True)
|
||||
wantref_option = BoolOption('wantref', 'Test requires', default=False, properties=('force_store_value',),
|
||||
requires=((booloption, True, 'hidden'),))
|
||||
requires=({'option': booloption, 'expected': True, 'action': 'hidden'},))
|
||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||
default=False,
|
||||
requires=((booloption, True, 'hidden'),))
|
||||
requires=({'option': booloption, 'expected': True, 'action': 'hidden'},))
|
||||
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
||||
descr = OptionDescription('tiramisu', '', [gcgroup, booloption, objspaceoption,
|
||||
|
@ -32,10 +32,10 @@ def make_description():
|
||||
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,
|
||||
requires=((boolop, True, 'hidden'),))
|
||||
requires=({'option': boolop, 'expected': True, 'action': 'hidden'},))
|
||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||
default=False,
|
||||
requires=((boolop, True, 'hidden'),))
|
||||
requires=({'option': boolop, 'expected': True, 'action': 'hidden'},))
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption, intoption2])
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption, objspaceoption,
|
||||
wantref_option, stroption,
|
||||
@ -56,10 +56,10 @@ def make_description_duplicates():
|
||||
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,
|
||||
requires=((boolop, True, 'hidden'),))
|
||||
requires=({'option': boolop, 'expected': True, 'action': 'hidden'},))
|
||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||
default=False,
|
||||
requires=((boolop, True, 'hidden'),))
|
||||
requires=({'option': boolop, 'expected': True, 'action': 'hidden'},))
|
||||
# dummy2 (same path)
|
||||
gcdummy2 = BoolOption('dummy', 'dummy2', default=True)
|
||||
# dummy3 (same name)
|
||||
@ -94,11 +94,11 @@ def make_description2():
|
||||
boolop = BoolOption('boolop', 'Test boolean option op', default=True)
|
||||
boolop.enable_multi()
|
||||
wantref_option = BoolOption('wantref', 'Test requires', default=False,
|
||||
requires=((boolop, True, 'hidden'),))
|
||||
requires=({'option': boolop, 'expected': True, 'action': 'hidden'},))
|
||||
# second multi
|
||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||
default=False,
|
||||
requires=((boolop, True, 'hidden'),))
|
||||
requires=({'option': boolop, 'expected': True, 'action': 'hidden'},))
|
||||
wantframework_option.enable_multi()
|
||||
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
||||
@ -167,7 +167,7 @@ def make_description_requires():
|
||||
booloption = BoolOption('bool', 'Test boolean option', default=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
stroption = StrOption('str', 'Test string option', default="abc",
|
||||
requires=((intoption, 1, 'hidden'),))
|
||||
requires=({'option': intoption, 'expected': 1, 'action': 'hidden'},))
|
||||
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption, objspaceoption,
|
||||
@ -200,7 +200,7 @@ def test_hidden_if_in_with_group():
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
stroption = StrOption('str', 'Test string option', default="abc")
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption],
|
||||
requires=((intoption, 1, 'hidden'),))
|
||||
requires=({'option': intoption, 'expected': 1, 'action': 'hidden'},))
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption,
|
||||
objspaceoption, stroption, intoption])
|
||||
cfg = Config(descr)
|
||||
@ -223,7 +223,7 @@ def test_disabled_with_group():
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
stroption = StrOption('str', 'Test string option', default="abc")
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption],
|
||||
requires=((intoption, 1, 'disabled'),))
|
||||
requires=({'option': intoption, 'expected': 1, 'action': 'disabled'},))
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption,
|
||||
objspaceoption, stroption, intoption])
|
||||
cfg = Config(descr)
|
||||
@ -245,10 +245,10 @@ def make_description_callback():
|
||||
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,
|
||||
requires=((boolop, True, 'hidden'),))
|
||||
requires=({'option': boolop, 'expected': True, 'action': 'hidden'},))
|
||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||
default=False,
|
||||
requires=((boolop, True, 'hidden'),))
|
||||
requires=({'option': boolop, 'expected': True, 'action': 'hidden'},))
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption, objspaceoption,
|
||||
wantref_option, stroption,
|
||||
|
@ -131,7 +131,7 @@ def test_multi_with_requires():
|
||||
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=[(intoption, 1, 'hidden')], multi=True)
|
||||
requires=[{'option': intoption, 'expected': 1, 'action': 'hidden'}], multi=True)
|
||||
descr = OptionDescription("options", "", [s, intoption, stroption])
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
@ -146,7 +146,7 @@ def test__requires_with_inverted():
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"], default_multi="abc",
|
||||
requires=[(intoption, 1, 'hide', 'inverted')], multi=True)
|
||||
requires=[{'option': intoption, 'expected': 1, 'action': 'hide', 'inverse': True}], multi=True)
|
||||
descr = OptionDescription("options", "", [s, intoption, stroption])
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
@ -160,7 +160,7 @@ def test_multi_with_requires_in_another_group():
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[(intoption, 1, 'hidden')], multi=True)
|
||||
requires=[{'option': intoption, 'expected': 1, 'action': 'hidden'}], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
config = Config(descr2)
|
||||
@ -177,7 +177,7 @@ def test_apply_requires_from_config():
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[(intoption, 1, 'hidden')], multi=True)
|
||||
requires=[{'option': intoption, 'expected': 1, 'action': 'hidden'}], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
config = Config(descr2)
|
||||
@ -194,7 +194,7 @@ def test_apply_requires_with_disabled():
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[(intoption, 1, 'disabled')], multi=True)
|
||||
requires=[{'option': intoption, 'expected': 1, 'action': 'disabled'}], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
config = Config(descr2)
|
||||
@ -211,7 +211,7 @@ def test_multi_with_requires_with_disabled_in_another_group():
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[(intoption, 1, 'disabled')], multi=True)
|
||||
requires=[{'option': intoption, 'expected': 1, 'action': 'disabled'}], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
config = Config(descr2)
|
||||
@ -226,7 +226,7 @@ def test_multi_with_requires_with_disabled_in_another_group():
|
||||
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)
|
||||
raises(ValueError, "StrOption('str', 'Test string option', default=['abc'], requires=[(intoption, 1, 'hidden')], multi=True)")
|
||||
raises(ValueError, "StrOption('str', 'Test string option', default=['abc'], requires=[{'option': intoption, 'expected': 1, 'action': 'hidden'}], multi=True)")
|
||||
|
||||
|
||||
def test_multi_with_bool():
|
||||
|
@ -20,10 +20,10 @@ def make_description():
|
||||
stroption = StrOption('str', 'Test string option', default="abc")
|
||||
|
||||
wantref_option = BoolOption('wantref', 'Test requires', default=False,
|
||||
requires=((gcoption, 'ref', 'hidden'),))
|
||||
requires=({'option': gcoption, 'expected': 'ref', 'action': 'hidden'},))
|
||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||
default=False,
|
||||
requires=((gcoption, 'framework', 'hidden'),))
|
||||
requires=({'option': gcoption, 'expected': 'framework', 'action': 'hidden'},))
|
||||
|
||||
# ____________________________________________________________
|
||||
booloptiontwo = BoolOption('booltwo', 'Test boolean option two', default=False)
|
||||
|
@ -1,5 +1,6 @@
|
||||
# coding: utf-8
|
||||
import autopath
|
||||
from copy import copy
|
||||
from tiramisu import setting
|
||||
setting.expires_time = 1
|
||||
from tiramisu.option import IPOption, OptionDescription, BoolOption, IntOption
|
||||
@ -11,7 +12,7 @@ from py.test import raises
|
||||
def test_requires():
|
||||
a = BoolOption('activate_service', '', True)
|
||||
b = IPOption('ip_address_service', '',
|
||||
requires=[(a, False, 'disabled')])
|
||||
requires=[{'option': a, 'expected': False, 'action': 'disabled'}])
|
||||
od = OptionDescription('service', '', [a, b])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
@ -28,10 +29,12 @@ def test_requires():
|
||||
def test_requires_same_action():
|
||||
a = BoolOption('activate_service', '', True)
|
||||
b = BoolOption('activate_service_web', '', True,
|
||||
requires=[(a, False, 'new')])
|
||||
requires=[{'option': a, 'expected': False, 'action': 'new'}])
|
||||
|
||||
d = IPOption('ip_address_service_web', '',
|
||||
requires=[(b, False, 'disabled', False, True, False)])
|
||||
requires=[{'option': b, 'expected': False,
|
||||
'action': 'disabled', 'inverse': False,
|
||||
'transitive': True, 'same_action': False}])
|
||||
od = OptionDescription('service', '', [a, b, d])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
@ -59,10 +62,10 @@ def test_requires_same_action():
|
||||
def test_requires_transitive():
|
||||
a = BoolOption('activate_service', '', True)
|
||||
b = BoolOption('activate_service_web', '', True,
|
||||
requires=[(a, False, 'disabled')])
|
||||
requires=[{'option': a, 'expected': False, 'action': 'disabled'}])
|
||||
|
||||
d = IPOption('ip_address_service_web', '',
|
||||
requires=[(b, False, 'disabled')])
|
||||
requires=[{'option': b, 'expected': False, 'action': 'disabled'}])
|
||||
od = OptionDescription('service', '', [a, b, d])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
@ -90,10 +93,10 @@ def test_requires_transitive_bis():
|
||||
a = BoolOption('activate_service', '', True)
|
||||
abis = BoolOption('activate_service_bis', '', True)
|
||||
b = BoolOption('activate_service_web', '', True,
|
||||
requires=[(a, True, 'disabled', True)])
|
||||
requires=[{'option': a, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
||||
|
||||
d = IPOption('ip_address_service_web', '',
|
||||
requires=[(b, True, 'disabled', True)])
|
||||
requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
||||
od = OptionDescription('service', '', [a, abis, b, d])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
@ -120,9 +123,9 @@ def test_requires_transitive_bis():
|
||||
def test_requires_transitive_hidden_disabled():
|
||||
a = BoolOption('activate_service', '', True)
|
||||
b = BoolOption('activate_service_web', '', True,
|
||||
requires=[(a, False, 'hidden')])
|
||||
requires=[{'option': a, 'expected': False, 'action': 'hidden'}])
|
||||
d = IPOption('ip_address_service_web', '',
|
||||
requires=[(b, False, 'disabled')])
|
||||
requires=[{'option': b, 'expected': False, 'action': 'disabled'}])
|
||||
od = OptionDescription('service', '', [a, b, d])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
@ -143,9 +146,10 @@ def test_requires_transitive_hidden_disabled():
|
||||
def test_requires_not_transitive():
|
||||
a = BoolOption('activate_service', '', True)
|
||||
b = BoolOption('activate_service_web', '', True,
|
||||
requires=[(a, False, 'disabled')])
|
||||
requires=[{'option': a, 'expected': False, 'action': 'disabled'}])
|
||||
d = IPOption('ip_address_service_web', '',
|
||||
requires=[(b, False, 'disabled', False, False)])
|
||||
requires=[{'option': b, 'expected': False,
|
||||
'action': 'disabled', 'transitive': False}])
|
||||
od = OptionDescription('service', '', [a, b, d])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
@ -167,7 +171,7 @@ def test_requires_not_transitive():
|
||||
def test_requires_None():
|
||||
a = BoolOption('activate_service', '')
|
||||
b = IPOption('ip_address_service', '',
|
||||
requires=[(a, None, 'disabled')])
|
||||
requires=[{'option': a, 'expected': None, 'action': 'disabled'}])
|
||||
od = OptionDescription('service', '', [a, b])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
@ -185,7 +189,8 @@ def test_requires_multi_disabled():
|
||||
a = BoolOption('activate_service', '')
|
||||
b = IntOption('num_service', '')
|
||||
c = IPOption('ip_address_service', '',
|
||||
requires=[(a, True, 'disabled'), (b, 1, 'disabled')])
|
||||
requires=[{'option': a, 'expected': True, 'action': 'disabled'},
|
||||
{'option': b, 'expected': 1, 'action': 'disabled'}])
|
||||
od = OptionDescription('service', '', [a, b, c])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
@ -219,11 +224,15 @@ def test_requires_multi_disabled():
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
|
||||
|
||||
def test_requires_multi_disabled_inverse():
|
||||
a = BoolOption('activate_service', '')
|
||||
b = IntOption('num_service', '')
|
||||
c = IPOption('ip_address_service', '',
|
||||
requires=[(a, True, 'disabled', True), (b, 1, 'disabled', True)])
|
||||
requires=[{'option': a, 'expected': True,
|
||||
'action': 'disabled', 'inverse': True},
|
||||
{'option': b, 'expected': 1,
|
||||
'action': 'disabled', 'inverse': True}])
|
||||
od = OptionDescription('service', '', [a, b, c])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
@ -261,3 +270,103 @@ def test_requires_multi_disabled_inverse():
|
||||
|
||||
c.activate_service = True
|
||||
c.ip_address_service
|
||||
|
||||
|
||||
def test_requires_multi_disabled_2():
|
||||
a = BoolOption('a', '')
|
||||
b = BoolOption('b', '')
|
||||
c = BoolOption('c', '')
|
||||
d = BoolOption('d', '')
|
||||
e = BoolOption('e', '')
|
||||
f = BoolOption('f', '')
|
||||
g = BoolOption('g', '')
|
||||
h = BoolOption('h', '')
|
||||
i = BoolOption('i', '')
|
||||
j = BoolOption('j', '')
|
||||
k = BoolOption('k', '')
|
||||
l = BoolOption('l', '')
|
||||
m = BoolOption('m', '')
|
||||
list_bools = [a, b, c, d, e, f, g, h, i, j, k, l, m]
|
||||
requires = []
|
||||
for boo in list_bools:
|
||||
requires.append({'option': boo, 'expected': True, 'action': 'disabled'})
|
||||
z = IPOption('z', '', requires=requires)
|
||||
y = copy(list_bools)
|
||||
y.append(z)
|
||||
od = OptionDescription('service', '', y)
|
||||
cfg = Config(od)
|
||||
cfg.read_write()
|
||||
|
||||
cfg.z
|
||||
for boo in list_bools:
|
||||
setattr(cfg, boo._name, True)
|
||||
props = []
|
||||
try:
|
||||
cfg.z
|
||||
except PropertiesOptionError, err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
for boo in list_bools:
|
||||
setattr(cfg, boo._name, False)
|
||||
if boo == m:
|
||||
cfg.z
|
||||
else:
|
||||
props = []
|
||||
try:
|
||||
cfg.z
|
||||
except PropertiesOptionError, err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
|
||||
|
||||
def test_requires_multi_disabled_inverse_2():
|
||||
a = BoolOption('a', '')
|
||||
b = BoolOption('b', '')
|
||||
c = BoolOption('c', '')
|
||||
d = BoolOption('d', '')
|
||||
e = BoolOption('e', '')
|
||||
f = BoolOption('f', '')
|
||||
g = BoolOption('g', '')
|
||||
h = BoolOption('h', '')
|
||||
i = BoolOption('i', '')
|
||||
j = BoolOption('j', '')
|
||||
k = BoolOption('k', '')
|
||||
l = BoolOption('l', '')
|
||||
m = BoolOption('m', '')
|
||||
list_bools = [a, b, c, d, e, f, g, h, i, j, k, l, m]
|
||||
requires = []
|
||||
for boo in list_bools:
|
||||
requires.append({'option': boo, 'expected': True, 'action': 'disabled',
|
||||
'inverse': True})
|
||||
z = IPOption('z', '', requires=requires)
|
||||
y = copy(list_bools)
|
||||
y.append(z)
|
||||
od = OptionDescription('service', '', y)
|
||||
cfg = Config(od)
|
||||
cfg.read_write()
|
||||
|
||||
props = []
|
||||
try:
|
||||
cfg.z
|
||||
except PropertiesOptionError, err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
for boo in list_bools:
|
||||
setattr(cfg, boo._name, True)
|
||||
if boo == m:
|
||||
cfg.z
|
||||
else:
|
||||
props = []
|
||||
try:
|
||||
cfg.z
|
||||
except PropertiesOptionError, err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
for boo in list_bools:
|
||||
setattr(cfg, boo._name, False)
|
||||
props = []
|
||||
try:
|
||||
cfg.z
|
||||
except PropertiesOptionError, err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
|
@ -30,7 +30,9 @@ def test_symlink_option():
|
||||
|
||||
def test_symlink_requires():
|
||||
boolopt = BoolOption('b', '', default=True)
|
||||
stropt = StrOption('s', '', requires=[(boolopt, False, 'disabled')])
|
||||
stropt = StrOption('s', '', requires=[{'option': boolopt,
|
||||
'expected': False,
|
||||
'action': 'disabled'}])
|
||||
linkopt = SymLinkOption("c", stropt)
|
||||
descr = OptionDescription('opt', '', [boolopt, stropt, linkopt])
|
||||
config = Config(descr)
|
||||
|
Reference in New Issue
Block a user