information for optiondescription
This commit is contained in:
parent
a16dbb60aa
commit
d2e790a2e2
3 changed files with 33 additions and 11 deletions
|
@ -200,6 +200,29 @@ async def test_information_option():
|
|||
assert not await list_sessions()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_information_optiondescription():
|
||||
descr = make_description()
|
||||
async with await Config(descr) as cfg:
|
||||
string = 'some informations'
|
||||
#
|
||||
assert list(await cfg.option('gc').information.list()) == ['doc']
|
||||
await cfg.option('gc').information.set('info', string)
|
||||
assert await cfg.option('gc').information.get('info') == string
|
||||
assert set(await cfg.option('gc').information.list()) == {'doc', 'info'}
|
||||
#
|
||||
with pytest.raises(ValueError):
|
||||
await cfg.option('gc').information.get('noinfo')
|
||||
assert await cfg.option('gc').information.get('noinfo', 'default') == 'default'
|
||||
await cfg.option('gc').information.reset('info')
|
||||
with pytest.raises(ValueError):
|
||||
await cfg.option('gc').information.get('info')
|
||||
with pytest.raises(ValueError):
|
||||
await cfg.option('gc').information.reset('noinfo')
|
||||
assert list(await cfg.option('gc').information.list()) == ['doc']
|
||||
assert not await list_sessions()
|
||||
|
||||
|
||||
def compare(val1, val2):
|
||||
assert len(val1[0]) == len(val2[0])
|
||||
for idx1, val_1 in enumerate(val1[0]):
|
||||
|
|
|
@ -221,8 +221,7 @@ class Base:
|
|||
return dico[key]
|
||||
if default is not undefined:
|
||||
return default
|
||||
raise ValueError(_("information's item not found: {0}").format(
|
||||
key))
|
||||
raise ValueError(_(f'information\'s item for "{self.impl_get_display_name()}" not found: "{key}"'))
|
||||
|
||||
def impl_set_information(self,
|
||||
key: str,
|
||||
|
@ -334,3 +333,12 @@ class BaseOption(Base):
|
|||
|
||||
def impl_is_symlinkoption(self) -> bool:
|
||||
return False
|
||||
|
||||
def get_dependencies_information(self,
|
||||
itself=False,
|
||||
) -> List[str]:
|
||||
if itself:
|
||||
idx = 1
|
||||
else:
|
||||
idx = 0
|
||||
return getattr(self, '_dependencies_information', [[], []])[idx]
|
||||
|
|
|
@ -207,15 +207,6 @@ class Option(BaseOption):
|
|||
def impl_is_dynsymlinkoption(self) -> bool:
|
||||
return False
|
||||
|
||||
def get_dependencies_information(self,
|
||||
itself=False,
|
||||
) -> List[str]:
|
||||
if itself:
|
||||
idx = 1
|
||||
else:
|
||||
idx = 0
|
||||
return getattr(self, '_dependencies_information', [[], []])[idx]
|
||||
|
||||
def get_type(self) -> str:
|
||||
# _display_name for compatibility with older version than 3.0rc3
|
||||
return getattr(self, '_type', self._display_name)
|
||||
|
|
Loading…
Reference in a new issue