From d3c129270a4d0171866dde1608b18884feaa82a2 Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Sat, 23 Jul 2016 09:46:15 +0700 Subject: [PATCH] Different formatters for "action-execution-get" and "action-execution-list" * In list representation it doesn't make a lot of sense to show state info (even in shrinked form) because one will be looking at it most likely if state is not SUCCESS, individually for every action execution object. Removing this field though allows to represent this table in a more consistent form. Change-Id: Iee5aabf386b79fdc8aaca7528d22a4675dd303a4 --- .../commands/v2/action_executions.py | 34 ++++++++++++++----- .../tests/functional/cli/v2/cli_tests_v2.py | 2 +- .../tests/unit/v2/test_cli_action_execs.py | 3 +- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/mistralclient/commands/v2/action_executions.py b/mistralclient/commands/v2/action_executions.py index 7dea2cd8..e45cb19c 100644 --- a/mistralclient/commands/v2/action_executions.py +++ b/mistralclient/commands/v2/action_executions.py @@ -26,10 +26,33 @@ LOG = logging.getLogger(__name__) def format_list(action_ex=None): - return format(action_ex, lister=True) + columns = ( + 'ID', + 'Name', + 'Workflow name', + 'Task name', + 'Task ID', + 'State', + 'Accepted', + ) + + if action_ex: + data = ( + action_ex.id, + action_ex.name, + action_ex.workflow_name, + action_ex.task_name if hasattr(action_ex, 'task_name') else None, + action_ex.task_execution_id, + action_ex.state, + action_ex.accepted, + ) + else: + data = (tuple('' for _ in range(len(columns))),) + + return columns, data -def format(action_ex=None, lister=False): +def format(action_ex=None): columns = ( 'ID', 'Name', @@ -42,11 +65,6 @@ def format(action_ex=None, lister=False): ) if action_ex: - state_info = ( - action_ex.state_info if not lister - else base.cut(action_ex.state_info) - ) - data = ( action_ex.id, action_ex.name, @@ -54,7 +72,7 @@ def format(action_ex=None, lister=False): action_ex.task_name if hasattr(action_ex, 'task_name') else None, action_ex.task_execution_id, action_ex.state, - state_info, + action_ex.state_info, action_ex.accepted, ) else: diff --git a/mistralclient/tests/functional/cli/v2/cli_tests_v2.py b/mistralclient/tests/functional/cli/v2/cli_tests_v2.py index e8076a21..28867af5 100644 --- a/mistralclient/tests/functional/cli/v2/cli_tests_v2.py +++ b/mistralclient/tests/functional/cli/v2/cli_tests_v2.py @@ -93,7 +93,7 @@ class SimpleMistralCLITests(base.MistralCLIAuth): self.mistral('action-execution-list')) self.assertTableStruct( act_execs, - ['ID', 'Name', 'Workflow name', 'State', 'State info', 'Accepted'] + ['ID', 'Name', 'Workflow name', 'State', 'Accepted'] ) diff --git a/mistralclient/tests/unit/v2/test_cli_action_execs.py b/mistralclient/tests/unit/v2/test_cli_action_execs.py index a1304623..6872f03c 100644 --- a/mistralclient/tests/unit/v2/test_cli_action_execs.py +++ b/mistralclient/tests/unit/v2/test_cli_action_execs.py @@ -105,8 +105,7 @@ class TestCLIActionExecutions(base.BaseCommandTest): result = self.call(action_ex_cmd.List) self.assertEqual( - [('123', 'some', 'thing', 'task1', '1-2-3-4', 'RUNNING', - 'RUNNING somehow.', True)], + [('123', 'some', 'thing', 'task1', '1-2-3-4', 'RUNNING', True)], result[1] )