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)
|
||||
with pytest.raises(AttributeOptionError):
|
||||
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():
|
||||
|
|
|
|||
|
|
@ -316,12 +316,12 @@ class _TiramisuOptionOptionDescription:
|
|||
"""Test if option is an optiondescription"""
|
||||
return self._subconfig.option.impl_is_optiondescription()
|
||||
|
||||
@option_type(["optiondescription"])
|
||||
@option_type(["optiondescription", "allow_dynoption"])
|
||||
def isleadership(self):
|
||||
"""Test if option is a leader or a follower"""
|
||||
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(
|
||||
self,
|
||||
with_quote: bool = False,
|
||||
|
|
@ -338,7 +338,7 @@ class _TiramisuOptionOptionDescription:
|
|||
None,
|
||||
)
|
||||
|
||||
@option_type(["optiondescription", "option", "symlink", "with_or_without_index"])
|
||||
@option_type(["optiondescription", "option", "symlink", "with_or_without_index", "allow_dynoption"])
|
||||
def name(
|
||||
self,
|
||||
*,
|
||||
|
|
@ -347,9 +347,11 @@ class _TiramisuOptionOptionDescription:
|
|||
"""Get option name"""
|
||||
if uncalculated:
|
||||
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]
|
||||
|
||||
@option_type(["optiondescription", "option", "with_or_without_index", "symlink"])
|
||||
@option_type(["optiondescription", "option", "with_or_without_index", "symlink", "allow_dynoption"])
|
||||
def path(
|
||||
self,
|
||||
*,
|
||||
|
|
@ -358,6 +360,8 @@ class _TiramisuOptionOptionDescription:
|
|||
"""Get option path"""
|
||||
if uncalculated:
|
||||
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
|
||||
|
||||
def parent(self):
|
||||
|
|
@ -439,7 +443,7 @@ class _TiramisuOptionOptionDescription:
|
|||
)
|
||||
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):
|
||||
"""Get de option type"""
|
||||
option = self._subconfig.option
|
||||
|
|
@ -457,12 +461,12 @@ class _TiramisuOptionOptionDescription:
|
|||
type_ = option.get_type(translation=translation)
|
||||
return type_
|
||||
|
||||
@option_type(["option", "symlink", "with_or_without_index"])
|
||||
@option_type(["option", "symlink", "with_or_without_index", "allow_dynoption"])
|
||||
def extra(self, extra):
|
||||
"""Get de option 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):
|
||||
"""Test if option is a dynamic optiondescription"""
|
||||
if not only_self:
|
||||
|
|
|
|||
Loading…
Reference in a new issue