From 9c84cb4523436317139f89dcba19df4a30afcc09 Mon Sep 17 00:00:00 2001 From: Erick Sapp Date: Mon, 4 Feb 2019 14:16:53 -0600 Subject: [PATCH 1/4] Added fix to shell help. --- SoftLayer/shell/cmd_help.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SoftLayer/shell/cmd_help.py b/SoftLayer/shell/cmd_help.py index eeceef068..806467f2d 100644 --- a/SoftLayer/shell/cmd_help.py +++ b/SoftLayer/shell/cmd_help.py @@ -9,7 +9,7 @@ from SoftLayer.shell import routes -@click.command() +@click.command(short_help="Print shell help text.") @environment.pass_env @click.pass_context def cli(ctx, env): @@ -22,6 +22,8 @@ def cli(ctx, env): shell_commands = [] for name in cli_core.cli.list_commands(ctx): command = cli_core.cli.get_command(ctx, name) + if command.short_help is None: + command.short_help = command.help details = (name, command.short_help) if name in dict(routes.ALL_ROUTES): shell_commands.append(details) From bd55687a98e3006cf7eef5a363decb46db6551ba Mon Sep 17 00:00:00 2001 From: Erick Sapp Date: Tue, 5 Feb 2019 09:46:40 -0600 Subject: [PATCH 2/4] Changes to shell_tests. --- SoftLayer/shell/cmd_help.py | 2 +- tests/CLI/modules/shell_tests.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/SoftLayer/shell/cmd_help.py b/SoftLayer/shell/cmd_help.py index 806467f2d..7575f88b1 100644 --- a/SoftLayer/shell/cmd_help.py +++ b/SoftLayer/shell/cmd_help.py @@ -16,7 +16,7 @@ def cli(ctx, env): """Print shell help text.""" env.out("Welcome to the SoftLayer shell.") env.out("") - + env.out("This is working.") formatter = formatting.HelpFormatter() commands = [] shell_commands = [] diff --git a/tests/CLI/modules/shell_tests.py b/tests/CLI/modules/shell_tests.py index 5f4b82c03..c2f0532b5 100644 --- a/tests/CLI/modules/shell_tests.py +++ b/tests/CLI/modules/shell_tests.py @@ -8,10 +8,19 @@ import mock - class ShellTests(testing.TestCase): @mock.patch('prompt_toolkit.shortcuts.prompt') def test_shell_quit(self, prompt): prompt.return_value = "quit" result = self.run_command(['shell']) self.assertEqual(result.exit_code, 0) + + @mock.patch('prompt_toolkit.shortcuts.prompt') + @mock.patch('shlex.split') + def test_shell_help(self, prompt, split): + split.side_effect = [(['help']), (['vs', 'list']), (False), (['quit'])] + prompt.return_value = "none" + result = self.run_command(['shell']) + if split.call_count is not 5: + raise Exception("Split not called correctly. Count: " + str(split.call_count)) + self.assertEqual(result.exit_code, 1) \ No newline at end of file From a324f1180d208cf5c386576c9dab584dc5649acb Mon Sep 17 00:00:00 2001 From: Erick Sapp Date: Tue, 5 Feb 2019 09:48:19 -0600 Subject: [PATCH 3/4] Removed a debug statement that was missing from 'git diff' before the previous commit. --- SoftLayer/shell/cmd_help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SoftLayer/shell/cmd_help.py b/SoftLayer/shell/cmd_help.py index 7575f88b1..806467f2d 100644 --- a/SoftLayer/shell/cmd_help.py +++ b/SoftLayer/shell/cmd_help.py @@ -16,7 +16,7 @@ def cli(ctx, env): """Print shell help text.""" env.out("Welcome to the SoftLayer shell.") env.out("") - env.out("This is working.") + formatter = formatting.HelpFormatter() commands = [] shell_commands = [] From 21c5a8e03e77bac3a1f8da229e8f9c92c372887a Mon Sep 17 00:00:00 2001 From: Erick Sapp Date: Tue, 5 Feb 2019 10:05:08 -0600 Subject: [PATCH 4/4] Updates for pylint. --- SoftLayer/CLI/virt/placementgroup/__init__.py | 1 - SoftLayer/shell/cmd_help.py | 4 ++-- tests/CLI/modules/shell_tests.py | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SoftLayer/CLI/virt/placementgroup/__init__.py b/SoftLayer/CLI/virt/placementgroup/__init__.py index 02d5da986..aa748a5b1 100644 --- a/SoftLayer/CLI/virt/placementgroup/__init__.py +++ b/SoftLayer/CLI/virt/placementgroup/__init__.py @@ -44,4 +44,3 @@ def get_command(self, ctx, cmd_name): @click.group(cls=PlacementGroupCommands, context_settings=CONTEXT) def cli(): """Base command for all capacity related concerns""" - pass diff --git a/SoftLayer/shell/cmd_help.py b/SoftLayer/shell/cmd_help.py index 806467f2d..2f548d75d 100644 --- a/SoftLayer/shell/cmd_help.py +++ b/SoftLayer/shell/cmd_help.py @@ -9,7 +9,7 @@ from SoftLayer.shell import routes -@click.command(short_help="Print shell help text.") +@click.command() @environment.pass_env @click.pass_context def cli(ctx, env): @@ -23,7 +23,7 @@ def cli(ctx, env): for name in cli_core.cli.list_commands(ctx): command = cli_core.cli.get_command(ctx, name) if command.short_help is None: - command.short_help = command.help + command.short_help = command.help details = (name, command.short_help) if name in dict(routes.ALL_ROUTES): shell_commands.append(details) diff --git a/tests/CLI/modules/shell_tests.py b/tests/CLI/modules/shell_tests.py index c2f0532b5..bf71d7004 100644 --- a/tests/CLI/modules/shell_tests.py +++ b/tests/CLI/modules/shell_tests.py @@ -8,6 +8,7 @@ import mock + class ShellTests(testing.TestCase): @mock.patch('prompt_toolkit.shortcuts.prompt') def test_shell_quit(self, prompt): @@ -23,4 +24,4 @@ def test_shell_help(self, prompt, split): result = self.run_command(['shell']) if split.call_count is not 5: raise Exception("Split not called correctly. Count: " + str(split.call_count)) - self.assertEqual(result.exit_code, 1) \ No newline at end of file + self.assertEqual(result.exit_code, 1)