transitivity in the requirements
This commit is contained in:
parent
418de157e8
commit
1c70a07d7e
|
@ -25,10 +25,11 @@ def test_requires():
|
||||||
assert props == ['disabled']
|
assert props == ['disabled']
|
||||||
|
|
||||||
|
|
||||||
def test_requires_transitif():
|
def test_requires_transitive():
|
||||||
a = BoolOption('activate_service', '', True)
|
a = BoolOption('activate_service', '', True)
|
||||||
b = BoolOption('activate_service_web', '', True,
|
b = BoolOption('activate_service_web', '', True,
|
||||||
requires=[(a, False, 'disabled')])
|
requires=[(a, False, 'disabled')])
|
||||||
|
|
||||||
d = IPOption('ip_address_service_web', '',
|
d = IPOption('ip_address_service_web', '',
|
||||||
requires=[(b, False, 'disabled')])
|
requires=[(b, False, 'disabled')])
|
||||||
od = OptionDescription('service', '', [a, b, d])
|
od = OptionDescription('service', '', [a, b, d])
|
||||||
|
@ -54,7 +55,38 @@ def test_requires_transitif():
|
||||||
assert props == ['disabled']
|
assert props == ['disabled']
|
||||||
|
|
||||||
|
|
||||||
def test_requires_transitif_hidden_disabled():
|
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)])
|
||||||
|
|
||||||
|
d = IPOption('ip_address_service_web', '',
|
||||||
|
requires=[(b, True, 'disabled', True)])
|
||||||
|
od = OptionDescription('service', '', [a, abis, b, d])
|
||||||
|
c = Config(od)
|
||||||
|
c.read_write()
|
||||||
|
#
|
||||||
|
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 == ['disabled']
|
||||||
|
#
|
||||||
|
props = []
|
||||||
|
try:
|
||||||
|
c.ip_address_service_web
|
||||||
|
except PropertiesOptionError, err:
|
||||||
|
props = err.proptype
|
||||||
|
assert props == ['disabled']
|
||||||
|
|
||||||
|
|
||||||
|
def test_requires_transitive_hidden_disabled():
|
||||||
a = BoolOption('activate_service', '', True)
|
a = BoolOption('activate_service', '', True)
|
||||||
b = BoolOption('activate_service_web', '', True,
|
b = BoolOption('activate_service_web', '', True,
|
||||||
requires=[(a, False, 'hidden')])
|
requires=[(a, False, 'hidden')])
|
||||||
|
@ -77,7 +109,7 @@ def test_requires_transitif_hidden_disabled():
|
||||||
raises(RequirementError, 'c.ip_address_service_web')
|
raises(RequirementError, 'c.ip_address_service_web')
|
||||||
|
|
||||||
|
|
||||||
def test_requires_not_transitif():
|
def test_requires_not_transitive():
|
||||||
a = BoolOption('activate_service', '', True)
|
a = BoolOption('activate_service', '', True)
|
||||||
b = BoolOption('activate_service_web', '', True,
|
b = BoolOption('activate_service_web', '', True,
|
||||||
requires=[(a, False, 'disabled')])
|
requires=[(a, False, 'disabled')])
|
||||||
|
|
|
@ -377,6 +377,7 @@ def apply_requires(opt, config):
|
||||||
"{1} {2}").format(opt._name, path, properties), properties)
|
"{1} {2}").format(opt._name, path, properties), properties)
|
||||||
#transitive action, force expected
|
#transitive action, force expected
|
||||||
value = expected
|
value = expected
|
||||||
|
inverse = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise AttributeError(_("required option not found: "
|
raise AttributeError(_("required option not found: "
|
||||||
"{0}").format(path))
|
"{0}").format(path))
|
||||||
|
@ -386,6 +387,8 @@ def apply_requires(opt, config):
|
||||||
else:
|
else:
|
||||||
setting.append(action)
|
setting.append(action)
|
||||||
matches = True
|
matches = True
|
||||||
|
# the calculation cannot be carried out
|
||||||
|
break
|
||||||
# no requirement has been triggered, then just reverse the action
|
# no requirement has been triggered, then just reverse the action
|
||||||
if not matches:
|
if not matches:
|
||||||
if inverse:
|
if inverse:
|
||||||
|
|
Loading…
Reference in New Issue