if option with requires has a property, calculated properties are store in storage
This commit is contained in:
parent
9d92ab84d7
commit
6f5d471db1
|
@ -24,6 +24,28 @@ def test_requires():
|
||||||
except PropertiesOptionError as err:
|
except PropertiesOptionError as err:
|
||||||
props = err.proptype
|
props = err.proptype
|
||||||
assert props == ['disabled']
|
assert props == ['disabled']
|
||||||
|
c.activate_service = True
|
||||||
|
c.ip_address_service
|
||||||
|
|
||||||
|
|
||||||
|
def test_requires_with_requires():
|
||||||
|
a = BoolOption('activate_service', '', True)
|
||||||
|
b = IPOption('ip_address_service', '',
|
||||||
|
requires=[{'option': a, 'expected': False, 'action': 'disabled'}])
|
||||||
|
od = OptionDescription('service', '', [a, b])
|
||||||
|
c = Config(od)
|
||||||
|
c.read_write()
|
||||||
|
c.cfgimpl_get_settings()[b].append('test')
|
||||||
|
c.ip_address_service
|
||||||
|
c.activate_service = False
|
||||||
|
props = []
|
||||||
|
try:
|
||||||
|
c.ip_address_service
|
||||||
|
except PropertiesOptionError as err:
|
||||||
|
props = err.proptype
|
||||||
|
assert props == ['disabled']
|
||||||
|
c.activate_service = True
|
||||||
|
c.ip_address_service
|
||||||
|
|
||||||
|
|
||||||
def test_requires_invalid():
|
def test_requires_invalid():
|
||||||
|
|
|
@ -361,7 +361,7 @@ class Settings(object):
|
||||||
|
|
||||||
def _getproperties(self, opt=None, path=None, is_apply_req=True):
|
def _getproperties(self, opt=None, path=None, is_apply_req=True):
|
||||||
if opt is None:
|
if opt is None:
|
||||||
props = self._p_.getproperties(path, default_properties)
|
props = copy(self._p_.getproperties(path, default_properties))
|
||||||
else:
|
else:
|
||||||
if path is None:
|
if path is None:
|
||||||
raise ValueError(_('if opt is not None, path should not be'
|
raise ValueError(_('if opt is not None, path should not be'
|
||||||
|
@ -372,8 +372,8 @@ class Settings(object):
|
||||||
ntime = int(time())
|
ntime = int(time())
|
||||||
is_cached, props = self._p_.getcache(path, ntime)
|
is_cached, props = self._p_.getcache(path, ntime)
|
||||||
if is_cached:
|
if is_cached:
|
||||||
return props
|
return copy(props)
|
||||||
props = self._p_.getproperties(path, opt._properties)
|
props = copy(self._p_.getproperties(path, opt._properties))
|
||||||
if is_apply_req:
|
if is_apply_req:
|
||||||
props |= self.apply_requires(opt, path)
|
props |= self.apply_requires(opt, path)
|
||||||
if 'cache' in self:
|
if 'cache' in self:
|
||||||
|
@ -435,8 +435,8 @@ class Settings(object):
|
||||||
(typically with the `frozen` property)
|
(typically with the `frozen` property)
|
||||||
"""
|
"""
|
||||||
# opt properties
|
# opt properties
|
||||||
properties = copy(self._getproperties(opt_or_descr, path))
|
properties = self._getproperties(opt_or_descr, path)
|
||||||
self_properties = copy(self._getproperties())
|
self_properties = self._getproperties()
|
||||||
# remove opt permissive
|
# remove opt permissive
|
||||||
# permissive affect option's permission with or without permissive
|
# permissive affect option's permission with or without permissive
|
||||||
# global property
|
# global property
|
||||||
|
|
Loading…
Reference in New Issue