Fixing task CLI
* Added command for retrieving task published * Deleted command task-get-input Closes-Bug: #1436751 Change-Id: I650e5af15bbf02413d3d91670ec307a808e52e35
This commit is contained in:
@@ -112,21 +112,20 @@ class GetResult(command.Command):
|
||||
self.app.stdout.write(result or "\n")
|
||||
|
||||
|
||||
class GetInput(command.Command):
|
||||
"""Show task input."""
|
||||
class GetPublished(command.Command):
|
||||
"""Show task published variables."""
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(GetInput, self).get_parser(prog_name)
|
||||
parser = super(GetPublished, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'id',
|
||||
help='Task ID'
|
||||
)
|
||||
help='Task ID')
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
result = tasks.TaskManager(self.app.client).get(
|
||||
parsed_args.id).input
|
||||
parsed_args.id).published
|
||||
|
||||
try:
|
||||
result = json.loads(result)
|
||||
|
||||
@@ -283,7 +283,7 @@ class MistralShell(app.App):
|
||||
mistralclient.commands.v2.executions.GetOutput,
|
||||
'task-list': mistralclient.commands.v2.tasks.List,
|
||||
'task-get': mistralclient.commands.v2.tasks.Get,
|
||||
'task-get-input': mistralclient.commands.v2.tasks.GetInput,
|
||||
'task-get-published': mistralclient.commands.v2.tasks.GetPublished,
|
||||
'task-get-result': mistralclient.commands.v2.tasks.GetResult,
|
||||
'action-list': mistralclient.commands.v2.actions.List,
|
||||
'action-get': mistralclient.commands.v2.actions.Get,
|
||||
|
||||
@@ -31,16 +31,16 @@ TASK_DICT = {
|
||||
}
|
||||
|
||||
TASK_RESULT = {"test": "is", "passed": "successfully"}
|
||||
TASK_INPUT = {"param1": "val1", "param2": 2}
|
||||
TASK_PUBLISHED = {"bar1": "val1", "var2": 2}
|
||||
|
||||
TASK_WITH_RESULT_DICT = TASK_DICT.copy()
|
||||
TASK_WITH_RESULT_DICT.update({'result': json.dumps(TASK_RESULT)})
|
||||
TASK_WITH_INPUT_DICT = TASK_DICT.copy()
|
||||
TASK_WITH_INPUT_DICT.update({'input': json.dumps(TASK_INPUT)})
|
||||
TASK_WITH_PUBLISHED_DICT = TASK_DICT.copy()
|
||||
TASK_WITH_PUBLISHED_DICT.update({'published': json.dumps(TASK_PUBLISHED)})
|
||||
|
||||
TASK = tasks.Task(mock, TASK_DICT)
|
||||
TASK_WITH_RESULT = tasks.Task(mock, TASK_WITH_RESULT_DICT)
|
||||
TASK_WITH_INPUT = tasks.Task(mock, TASK_WITH_INPUT_DICT)
|
||||
TASK_WITH_PUBLISHED = tasks.Task(mock, TASK_WITH_PUBLISHED_DICT)
|
||||
|
||||
|
||||
class TestCLITasksV2(base.BaseCommandTest):
|
||||
@@ -81,11 +81,11 @@ class TestCLITasksV2(base.BaseCommandTest):
|
||||
json.dumps(TASK_RESULT, indent=4) + "\n")
|
||||
|
||||
@mock.patch('mistralclient.api.v2.tasks.TaskManager.get')
|
||||
def test_get_input(self, mock):
|
||||
mock.return_value = TASK_WITH_INPUT
|
||||
def test_get_published(self, mock):
|
||||
mock.return_value = TASK_WITH_PUBLISHED
|
||||
|
||||
self.call(task_cmd.GetInput, app_args=['id'])
|
||||
self.call(task_cmd.GetPublished, app_args=['id'])
|
||||
|
||||
self.app.stdout.write.assert_called_with(
|
||||
json.dumps(TASK_INPUT, indent=4) + "\n"
|
||||
json.dumps(TASK_PUBLISHED, indent=4) + "\n"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user