From 5171cdd63a7731a684f8146997f28136ab3a6483 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Wed, 29 Jan 2020 16:51:54 -0700 Subject: [PATCH] Create client for interactive shell The client allows you to run an interactive mode that doesn't exit between calls and reuses the client which is handy for end users. Currently the code doesn't actually create a workflow engine client in the interactive mode so all the mistral actions fail. We should create a client if the client doesn't pass any args to the shell because that enters interactive mode. Change-Id: I8b4c56277f0f172da712f777c4c856dba6fa0b0b Closes-Bug: #1861357 --- mistralclient/shell.py | 3 +-- mistralclient/tests/unit/test_shell.py | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mistralclient/shell.py b/mistralclient/shell.py index e1fe93e6..0847ba73 100644 --- a/mistralclient/shell.py +++ b/mistralclient/shell.py @@ -565,8 +565,7 @@ class MistralShell(app.App): ('bash-completion' in argv) or ('help' in argv) or ('-h' in argv) or - ('--help' in argv) or - not argv) + ('--help' in argv)) # Set default for auth_url if not supplied. The default is not # set at the parser to support use cases where auth is not enabled. diff --git a/mistralclient/tests/unit/test_shell.py b/mistralclient/tests/unit/test_shell.py index edc21b90..61823ae3 100644 --- a/mistralclient/tests/unit/test_shell.py +++ b/mistralclient/tests/unit/test_shell.py @@ -39,6 +39,13 @@ class TestShell(base.BaseShellTests): params = client_mock.call_args self.assertEqual('', params[1]['mistral_url']) + @mock.patch('mistralclient.api.client.client') + def test_command_interactive_mode(self, client_mock): + self.shell('') + self.assertTrue(client_mock.called) + params = client_mock.call_args + self.assertEqual('', params[1]['mistral_url']) + @mock.patch('mistralclient.api.client.client') def test_command_with_mistral_url(self, client_mock): self.shell(