transitive in apply_requires should only by apply if properties are same has testing action
This commit is contained in:
parent
c31590c2ac
commit
2e4fdbca03
|
@ -1,6 +1,8 @@
|
|||
Wed Oct 12 21:55:53 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||
* consistency is now check "not_equal" if one option has
|
||||
PropertiesOptionError
|
||||
* transitive in apply_requires should only by apply if properties are
|
||||
same has testing action
|
||||
|
||||
Mon Oct 10 21:39:04 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||
* consistency with default value for all values now works
|
||||
|
|
|
@ -349,6 +349,31 @@ def test_requires_not_transitive():
|
|||
c.ip_address_service_web
|
||||
|
||||
|
||||
def test_requires_not_transitive_not_same_action():
|
||||
a = BoolOption('activate_service', '', True)
|
||||
b = BoolOption('activate_service_web', '', True,
|
||||
requires=[{'option': a, 'expected': False, 'action': 'disabled'}])
|
||||
d = IPOption('ip_address_service_web', '',
|
||||
requires=[{'option': b, 'expected': False,
|
||||
'action': 'hidden', 'transitive': False}])
|
||||
od = OptionDescription('service', '', [a, b, d])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
c.activate_service
|
||||
c.activate_service_web
|
||||
c.ip_address_service_web
|
||||
c.activate_service = False
|
||||
#
|
||||
props = []
|
||||
try:
|
||||
c.activate_service_web
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
#
|
||||
raises(RequirementError, "c.ip_address_service_web")
|
||||
|
||||
|
||||
def test_requires_None():
|
||||
a = BoolOption('activate_service', '')
|
||||
b = IPOption('ip_address_service', '',
|
||||
|
|
|
@ -633,6 +633,7 @@ class Settings(object):
|
|||
else:
|
||||
calc_properties = set()
|
||||
context = self._getcontext()
|
||||
all_properties = None
|
||||
for requires in opt.impl_getrequires():
|
||||
for require in requires:
|
||||
option, expected, action, inverse, \
|
||||
|
@ -653,6 +654,12 @@ class Settings(object):
|
|||
if isinstance(value, Exception):
|
||||
if isinstance(value, PropertiesOptionError):
|
||||
if not transitive:
|
||||
if all_properties is None:
|
||||
all_properties = []
|
||||
for requires in opt.impl_getrequires():
|
||||
for require in requires:
|
||||
all_properties.append(require[2])
|
||||
if not set(value.proptype) - set(all_properties):
|
||||
continue
|
||||
properties = value.proptype
|
||||
if same_action and action not in properties: # pragma: optional cover
|
||||
|
|
Loading…
Reference in New Issue