Merge branch 'dev' into dont-take-lock-for-read-operations

This commit is contained in:
Alexandre Aubin 2022-12-24 00:52:08 +01:00
commit ac0ac24996
4 changed files with 13 additions and 41 deletions

View file

@ -288,7 +288,9 @@ class ActionsMapParser(BaseActionsMapParser):
"""
def __init__(self, parent=None, parser=None, subparser_kwargs=None, top_parser=None):
def __init__(
self, parent=None, parser=None, subparser_kwargs=None, top_parser=None
):
super(ActionsMapParser, self).__init__(parent)
@ -334,7 +336,11 @@ class ActionsMapParser(BaseActionsMapParser):
parser = self._subparsers.add_parser(
name, description=category_help, help=category_help, **kwargs
)
return self.__class__(parent=self, parser=parser, subparser_kwargs={"title": "subcommands", "required": True})
return self.__class__(
parent=self,
parser=parser,
subparser_kwargs={"title": "subcommands", "required": True},
)
def add_subcategory_parser(self, name, subcategory_help=None, **kwargs):
"""Add a parser for a subcategory
@ -353,7 +359,11 @@ class ActionsMapParser(BaseActionsMapParser):
help=subcategory_help,
**kwargs,
)
return self.__class__(parent=self, parser=parser, subparser_kwargs={"title": "actions", "required": True})
return self.__class__(
parent=self,
parser=parser,
subparser_kwargs={"title": "actions", "required": True},
)
def add_action_parser(
self,

View file

@ -7,21 +7,6 @@ _global:
authentication:
api: dummy
cli: dummy
arguments:
-v:
full: --version
help: Display Yoloswag versions
action: callback
callback:
method: test.src.testauth.yoloswag_version
return: true
-w:
full: --wersion
help: Not existing function
action: callback
callback:
method: test.src.testauth.not_existing_function
return: true
#############################
# Test Actions #

View file

@ -44,7 +44,3 @@ def testauth_with_extra_str_only(only_a_str):
def testauth_with_type_int(only_an_int):
return only_an_int
def yoloswag_version(*args, **kwargs):
return "666"

View file

@ -255,25 +255,6 @@ class TestAuthCLI:
assert "invalid_password" in str(exception)
def test_request_with_callback(self, moulinette_cli, capsys, mocker):
mocker.patch("os.isatty", return_value=True)
mocker.patch("prompt_toolkit.prompt", return_value="dummy")
moulinette_cli.run(["--version"], output_as="plain")
message = capsys.readouterr()
assert "666" in message.out
moulinette_cli.run(["-v"], output_as="plain")
message = capsys.readouterr()
assert "666" in message.out
with pytest.raises(MoulinetteError):
moulinette_cli.run(["--wersion"], output_as="plain")
message = capsys.readouterr()
assert "cannot get value from callback method" in message.err
def test_request_with_arg(self, moulinette_cli, capsys, mocker):
mocker.patch("os.isatty", return_value=True)
mocker.patch("prompt_toolkit.prompt", return_value="dummy")