From 161c5d5c2be2051111a6f2466e9b0a3d331c489f Mon Sep 17 00:00:00 2001 From: alexAubin Date: Fri, 23 Dec 2022 23:01:46 +0000 Subject: [PATCH 1/2] :art: Format Python code with Black --- moulinette/interfaces/cli.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/moulinette/interfaces/cli.py b/moulinette/interfaces/cli.py index efb37aba..8f577092 100644 --- a/moulinette/interfaces/cli.py +++ b/moulinette/interfaces/cli.py @@ -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, From 7f4e8b394cf3ffbc8aa9e8debb3d1694870e0c6b Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 24 Dec 2022 00:07:03 +0100 Subject: [PATCH 2/2] Remove old test about old callback mechanism --- test/actionsmap/moulitest.yml | 15 --------------- test/src/testauth.py | 4 ---- test/test_auth.py | 19 ------------------- 3 files changed, 38 deletions(-) diff --git a/test/actionsmap/moulitest.yml b/test/actionsmap/moulitest.yml index 9802037d..4bb760b9 100644 --- a/test/actionsmap/moulitest.yml +++ b/test/actionsmap/moulitest.yml @@ -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 # diff --git a/test/src/testauth.py b/test/src/testauth.py index ffd5583d..cbcb3c5b 100644 --- a/test/src/testauth.py +++ b/test/src/testauth.py @@ -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" diff --git a/test/test_auth.py b/test/test_auth.py index b5537bb7..1f557329 100644 --- a/test/test_auth.py +++ b/test/test_auth.py @@ -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")