feat: can get properties without index when uncalculated is set to true
This commit is contained in:
parent
3ed96ef2ad
commit
849cff522b
2 changed files with 9 additions and 4 deletions
|
|
@ -1094,6 +1094,10 @@ def test_follower_properties():
|
||||||
cfg.option('ip_admin_eth0.netmask_admin_eth0').property.add('newproperty1')
|
cfg.option('ip_admin_eth0.netmask_admin_eth0').property.add('newproperty1')
|
||||||
cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).property.get() == ('aproperty', 'newproperty', 'newproperty1')
|
cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).property.get() == ('aproperty', 'newproperty', 'newproperty1')
|
||||||
cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).property.get() == ('aproperty', 'newproperty1')
|
cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).property.get() == ('aproperty', 'newproperty1')
|
||||||
|
#
|
||||||
|
with pytest.raises(ConfigError):
|
||||||
|
cfg.option('ip_admin_eth0.netmask_admin_eth0').property.get()
|
||||||
|
cfg.option('ip_admin_eth0.netmask_admin_eth0').property.get(uncalculated=True) == ('aproperty', 'newproperty1')
|
||||||
# assert not list_sessions()
|
# assert not list_sessions()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -218,15 +218,16 @@ def option_type(typ):
|
||||||
):
|
):
|
||||||
# default is "without_index"
|
# default is "without_index"
|
||||||
if (
|
if (
|
||||||
"with_index" not in types
|
self._index is not None
|
||||||
|
and "with_index" not in types
|
||||||
and "with_or_without_index" not in types
|
and "with_or_without_index" not in types
|
||||||
and self._index is not None
|
and "with_index_or_uncalculated" not in types
|
||||||
):
|
):
|
||||||
msg = _("please do not specify index ({0}.{1})").format(
|
msg = _("please do not specify index ({0}.{1})").format(
|
||||||
self.__class__.__name__, func.__name__
|
self.__class__.__name__, func.__name__
|
||||||
)
|
)
|
||||||
raise ConfigError(msg)
|
raise ConfigError(msg)
|
||||||
if self._index is None and "with_index" in types:
|
if self._index is None and ("with_index" in types or ("with_index_or_uncalculated" in types and kwargs.get("uncalculated", False) is False)):
|
||||||
msg = _(
|
msg = _(
|
||||||
"please specify index with a follower option ({0}.{1})"
|
"please specify index with a follower option ({0}.{1})"
|
||||||
).format(self.__class__.__name__, func.__name__)
|
).format(self.__class__.__name__, func.__name__)
|
||||||
|
|
@ -788,7 +789,7 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
||||||
_validate_properties = False
|
_validate_properties = False
|
||||||
|
|
||||||
@option_type(
|
@option_type(
|
||||||
["option", "optiondescription", "with_index", "symlink", "allow_dynoption"]
|
["option", "optiondescription", "with_index_or_uncalculated", "symlink", "allow_dynoption"]
|
||||||
)
|
)
|
||||||
def get(
|
def get(
|
||||||
self,
|
self,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue