diff --git a/tests/test_leadership.py b/tests/test_leadership.py index e82ca80..888cc26 100644 --- a/tests/test_leadership.py +++ b/tests/test_leadership.py @@ -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', 0).property.get() == ('aproperty', 'newproperty', '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() diff --git a/tiramisu/api.py b/tiramisu/api.py index 5f078eb..19ca5fb 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -218,15 +218,16 @@ def option_type(typ): ): # default is "without_index" 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 self._index is not None + and "with_index_or_uncalculated" not in types ): msg = _("please do not specify index ({0}.{1})").format( self.__class__.__name__, func.__name__ ) 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 = _( "please specify index with a follower option ({0}.{1})" ).format(self.__class__.__name__, func.__name__) @@ -788,7 +789,7 @@ class TiramisuOptionProperty(CommonTiramisuOption): _validate_properties = False @option_type( - ["option", "optiondescription", "with_index", "symlink", "allow_dynoption"] + ["option", "optiondescription", "with_index_or_uncalculated", "symlink", "allow_dynoption"] ) def get( self,