fix: allow_dynoption for option informations
This commit is contained in:
parent
e0f16b14c7
commit
acca0bc040
2 changed files with 39 additions and 7 deletions
|
|
@ -487,6 +487,34 @@ def test_dyndescription_subdyn():
|
||||||
cfg.option('od.dod2.dodval1.st').property.get(uncalculated=True)
|
cfg.option('od.dod2.dodval1.st').property.get(uncalculated=True)
|
||||||
with pytest.raises(AttributeOptionError):
|
with pytest.raises(AttributeOptionError):
|
||||||
cfg.option('od.dod2val1.dod.st').property.get(uncalculated=True)
|
cfg.option('od.dod2val1.dod.st').property.get(uncalculated=True)
|
||||||
|
#
|
||||||
|
with pytest.raises(AttributeOptionError):
|
||||||
|
cfg.option('od.dod2.dod.st').name()
|
||||||
|
with pytest.raises(AttributeOptionError):
|
||||||
|
cfg.option('od.dod2val1.dod.st').name()
|
||||||
|
assert cfg.option('od.dod2.dod.st').name(uncalculated=True) == 'st'
|
||||||
|
with pytest.raises(AttributeOptionError):
|
||||||
|
cfg.option('od.dod2val1.dod.st').name(uncalculated=True)
|
||||||
|
#
|
||||||
|
with pytest.raises(AttributeOptionError):
|
||||||
|
cfg.option('od.dod2.dod.st').path()
|
||||||
|
with pytest.raises(AttributeOptionError):
|
||||||
|
cfg.option('od.dod2val1.dod.st').path()
|
||||||
|
assert cfg.option('od.dod2.dod.st').path(uncalculated=True) == 'od.dod2.dod.st'
|
||||||
|
with pytest.raises(AttributeOptionError):
|
||||||
|
cfg.option('od.dod2val1.dod.st').path(uncalculated=True)
|
||||||
|
#
|
||||||
|
assert cfg.option('od.dod2.dod.st').isoptiondescription() is False
|
||||||
|
assert cfg.option('od.dod2val1.dodval1.st').isoptiondescription() is False
|
||||||
|
assert cfg.option('od.dod2.dod').isoptiondescription() is True
|
||||||
|
assert cfg.option('od.dod2val1.dodval1').isoptiondescription() is True
|
||||||
|
assert cfg.option('od.dod2.dod').isleadership() is False
|
||||||
|
assert cfg.option('od.dod2val1.dodval1').isleadership() is False
|
||||||
|
#
|
||||||
|
assert cfg.option('od.dod2.dod.st').type() == "string"
|
||||||
|
assert cfg.option('od.dod2val1.dodval1.st').type() == "string"
|
||||||
|
assert cfg.option('od.dod2.dod').type() == "optiondescription"
|
||||||
|
assert cfg.option('od.dod2val1.dodval1').type() == "optiondescription"
|
||||||
|
|
||||||
|
|
||||||
def test_callback_dyndescription_subdyn():
|
def test_callback_dyndescription_subdyn():
|
||||||
|
|
|
||||||
|
|
@ -316,12 +316,12 @@ class _TiramisuOptionOptionDescription:
|
||||||
"""Test if option is an optiondescription"""
|
"""Test if option is an optiondescription"""
|
||||||
return self._subconfig.option.impl_is_optiondescription()
|
return self._subconfig.option.impl_is_optiondescription()
|
||||||
|
|
||||||
@option_type(["optiondescription"])
|
@option_type(["optiondescription", "allow_dynoption"])
|
||||||
def isleadership(self):
|
def isleadership(self):
|
||||||
"""Test if option is a leader or a follower"""
|
"""Test if option is a leader or a follower"""
|
||||||
return self._subconfig.option.impl_is_leadership()
|
return self._subconfig.option.impl_is_leadership()
|
||||||
|
|
||||||
@option_type(["optiondescription", "option", "with_or_without_index", "symlink"])
|
@option_type(["optiondescription", "option", "with_or_without_index", "symlink", "allow_dynoption"])
|
||||||
def description(
|
def description(
|
||||||
self,
|
self,
|
||||||
with_quote: bool = False,
|
with_quote: bool = False,
|
||||||
|
|
@ -338,7 +338,7 @@ class _TiramisuOptionOptionDescription:
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@option_type(["optiondescription", "option", "symlink", "with_or_without_index"])
|
@option_type(["optiondescription", "option", "symlink", "with_or_without_index", "allow_dynoption"])
|
||||||
def name(
|
def name(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
|
|
@ -347,9 +347,11 @@ class _TiramisuOptionOptionDescription:
|
||||||
"""Get option name"""
|
"""Get option name"""
|
||||||
if uncalculated:
|
if uncalculated:
|
||||||
return self._subconfig.option.impl_getname()
|
return self._subconfig.option.impl_getname()
|
||||||
|
if self._subconfig.is_dynamic_without_identifiers:
|
||||||
|
raise AttributeOptionError(self._subconfig.path, "option-dynamic")
|
||||||
return self._subconfig.true_path.rsplit(".", 1)[-1]
|
return self._subconfig.true_path.rsplit(".", 1)[-1]
|
||||||
|
|
||||||
@option_type(["optiondescription", "option", "with_or_without_index", "symlink"])
|
@option_type(["optiondescription", "option", "with_or_without_index", "symlink", "allow_dynoption"])
|
||||||
def path(
|
def path(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
|
|
@ -358,6 +360,8 @@ class _TiramisuOptionOptionDescription:
|
||||||
"""Get option path"""
|
"""Get option path"""
|
||||||
if uncalculated:
|
if uncalculated:
|
||||||
return self._subconfig.option.impl_getpath()
|
return self._subconfig.option.impl_getpath()
|
||||||
|
if self._subconfig.is_dynamic_without_identifiers:
|
||||||
|
raise AttributeOptionError(self._subconfig.path, "option-dynamic")
|
||||||
return self._subconfig.true_path
|
return self._subconfig.true_path
|
||||||
|
|
||||||
def parent(self):
|
def parent(self):
|
||||||
|
|
@ -439,7 +443,7 @@ class _TiramisuOptionOptionDescription:
|
||||||
)
|
)
|
||||||
return options
|
return options
|
||||||
|
|
||||||
@option_type(["option", "optiondescription", "symlink", "with_or_without_index"])
|
@option_type(["option", "optiondescription", "symlink", "with_or_without_index", "allow_dynoption"])
|
||||||
def type(self, only_self=False, translation=False):
|
def type(self, only_self=False, translation=False):
|
||||||
"""Get de option type"""
|
"""Get de option type"""
|
||||||
option = self._subconfig.option
|
option = self._subconfig.option
|
||||||
|
|
@ -457,12 +461,12 @@ class _TiramisuOptionOptionDescription:
|
||||||
type_ = option.get_type(translation=translation)
|
type_ = option.get_type(translation=translation)
|
||||||
return type_
|
return type_
|
||||||
|
|
||||||
@option_type(["option", "symlink", "with_or_without_index"])
|
@option_type(["option", "symlink", "with_or_without_index", "allow_dynoption"])
|
||||||
def extra(self, extra):
|
def extra(self, extra):
|
||||||
"""Get de option extra"""
|
"""Get de option extra"""
|
||||||
return self._subconfig.option.impl_get_extra(extra)
|
return self._subconfig.option.impl_get_extra(extra)
|
||||||
|
|
||||||
@option_type(["option", "optiondescription", "symlink", "with_or_without_index"])
|
@option_type(["option", "optiondescription", "symlink", "with_or_without_index", "allow_dynoption"])
|
||||||
def isdynamic(self, *, only_self: bool = False):
|
def isdynamic(self, *, only_self: bool = False):
|
||||||
"""Test if option is a dynamic optiondescription"""
|
"""Test if option is a dynamic optiondescription"""
|
||||||
if not only_self:
|
if not only_self:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue