Merge "Different formatters for "action-execution-get" and "action-execution-list""
This commit is contained in:
@@ -26,10 +26,33 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def format_list(action_ex=None):
|
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('<none>' for _ in range(len(columns))),)
|
||||||
|
|
||||||
|
return columns, data
|
||||||
|
|
||||||
|
|
||||||
def format(action_ex=None, lister=False):
|
def format(action_ex=None):
|
||||||
columns = (
|
columns = (
|
||||||
'ID',
|
'ID',
|
||||||
'Name',
|
'Name',
|
||||||
@@ -42,11 +65,6 @@ def format(action_ex=None, lister=False):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if action_ex:
|
if action_ex:
|
||||||
state_info = (
|
|
||||||
action_ex.state_info if not lister
|
|
||||||
else base.cut(action_ex.state_info)
|
|
||||||
)
|
|
||||||
|
|
||||||
data = (
|
data = (
|
||||||
action_ex.id,
|
action_ex.id,
|
||||||
action_ex.name,
|
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_name if hasattr(action_ex, 'task_name') else None,
|
||||||
action_ex.task_execution_id,
|
action_ex.task_execution_id,
|
||||||
action_ex.state,
|
action_ex.state,
|
||||||
state_info,
|
action_ex.state_info,
|
||||||
action_ex.accepted,
|
action_ex.accepted,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@@ -93,7 +93,7 @@ class SimpleMistralCLITests(base.MistralCLIAuth):
|
|||||||
self.mistral('action-execution-list'))
|
self.mistral('action-execution-list'))
|
||||||
self.assertTableStruct(
|
self.assertTableStruct(
|
||||||
act_execs,
|
act_execs,
|
||||||
['ID', 'Name', 'Workflow name', 'State', 'State info', 'Accepted']
|
['ID', 'Name', 'Workflow name', 'State', 'Accepted']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -105,8 +105,7 @@ class TestCLIActionExecutions(base.BaseCommandTest):
|
|||||||
result = self.call(action_ex_cmd.List)
|
result = self.call(action_ex_cmd.List)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[('123', 'some', 'thing', 'task1', '1-2-3-4', 'RUNNING',
|
[('123', 'some', 'thing', 'task1', '1-2-3-4', 'RUNNING', True)],
|
||||||
'RUNNING somehow.', True)],
|
|
||||||
result[1]
|
result[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user