diff --git a/test/test_requires.py b/test/test_requires.py index 5fdcbdd..cfad1c3 100644 --- a/test/test_requires.py +++ b/test/test_requires.py @@ -25,6 +25,37 @@ def test_requires(): assert props == ['disabled'] +def test_requires_same_action(): + a = BoolOption('activate_service', '', True) + b = BoolOption('activate_service_web', '', True, + requires=[(a, False, 'new')]) + + d = IPOption('ip_address_service_web', '', + requires=[(b, False, 'disabled', False, True, False)]) + od = OptionDescription('service', '', [a, b, d]) + c = Config(od) + c.read_write() + c.cfgimpl_get_settings().append('new') + c.activate_service + c.activate_service_web + c.ip_address_service_web + c.activate_service = False + # + props = [] + try: + c.activate_service_web + except PropertiesOptionError, err: + props = err.proptype + assert props == ['new'] + # + props = [] + try: + c.ip_address_service_web + except PropertiesOptionError, err: + props = err.proptype + assert props == ['disabled'] + + def test_requires_transitive(): a = BoolOption('activate_service', '', True) b = BoolOption('activate_service_web', '', True, diff --git a/tiramisu/option.py b/tiramisu/option.py index f392b07..2185a7d 100644 --- a/tiramisu/option.py +++ b/tiramisu/option.py @@ -820,7 +820,7 @@ def validate_requires_arg(requires, name): if len(req) == 3: action = req[2] inverse = False - elif len(req) in [4, 5]: + elif len(req) in [4, 5, 6]: action = req[2] inverse = req[3] else: diff --git a/tiramisu/setting.py b/tiramisu/setting.py index 52c82bf..ac50e2e 100644 --- a/tiramisu/setting.py +++ b/tiramisu/setting.py @@ -356,11 +356,16 @@ def apply_requires(opt, config): option, expected, action = require inverse = False transitive = True + same_action = True elif len(require) == 4: option, expected, action, inverse = require transitive = True + same_action = True elif len(require) == 5: option, expected, action, inverse, transitive = require + same_action = True + elif len(require) == 6: + option, expected, action, inverse, transitive, same_action = require path = descr.impl_get_path_by_opt(option) if path == optpath or path.startswith(optpath + '.'): raise RequirementError(_("malformed requirements " @@ -372,9 +377,9 @@ def apply_requires(opt, config): if not transitive: continue properties = err.proptype - if action not in err.proptype: + if same_action and action not in properties: raise RequirementError(_("option '{0}' has requirement's property error: " - "{1} {2}").format(opt._name, path, properties), properties) + "{1} {2}").format(opt._name, path, properties)) #transitive action, force expected value = expected inverse = False