Implementing run-action command in client
* Introduced new command: mistral run-action <name> <input> [--save-result] [--target TARGET] * Short options: -s (--save-result), -t (--target) Implements blueprint mistral-run-individual-action Change-Id: Iad86f805e8bb13027946a7da9b0d79dc220d44d6
This commit is contained in:
@@ -32,6 +32,25 @@ URL_TEMPLATE_ID = '/action_executions/%s'
|
||||
|
||||
|
||||
class TestActionExecutions(base.BaseClientV2Test):
|
||||
def test_create(self):
|
||||
mock = self.mock_http_post(content=ACTION_EXEC)
|
||||
body = {
|
||||
'name': ACTION_EXEC['name']
|
||||
}
|
||||
|
||||
action_execution = self.action_executions.create(
|
||||
'my_action_execution',
|
||||
{}
|
||||
)
|
||||
|
||||
self.assertIsNotNone(action_execution)
|
||||
self.assertEqual(action_executions.ActionExecution(
|
||||
self.action_executions, ACTION_EXEC
|
||||
).__dict__, action_execution.__dict__)
|
||||
|
||||
mock.assert_called_once_with(
|
||||
URL_TEMPLATE, json.dumps(body))
|
||||
|
||||
def test_update(self):
|
||||
mock = self.mock_http_put(content=ACTION_EXEC)
|
||||
body = {
|
||||
|
||||
@@ -50,6 +50,38 @@ ACTION_EX_WITH_INPUT = action_ex.ActionExecution(
|
||||
|
||||
|
||||
class TestCLIActionExecutions(base.BaseCommandTest):
|
||||
@mock.patch(
|
||||
'mistralclient.api.v2.action_executions.ActionExecutionManager.create'
|
||||
)
|
||||
def test_create(self, mock):
|
||||
mock.return_value = ACTION_EX_WITH_OUTPUT
|
||||
|
||||
self.call(
|
||||
action_ex_cmd.Create,
|
||||
app_args=['some', '{"output": "Hello!"}']
|
||||
)
|
||||
|
||||
self.app.stdout.write.assert_called_with(
|
||||
json.dumps(ACTION_EX_RESULT) + "\n")
|
||||
|
||||
@mock.patch(
|
||||
'mistralclient.api.v2.action_executions.ActionExecutionManager.create'
|
||||
)
|
||||
def test_create_save_result(self, mock):
|
||||
mock.return_value = ACTION_EX_WITH_OUTPUT
|
||||
|
||||
result = self.call(
|
||||
action_ex_cmd.Create,
|
||||
app_args=[
|
||||
'some', '{"output": "Hello!"}', '--save-result'
|
||||
]
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
('123', 'some', 'thing', 'task1', 'RUNNING',
|
||||
'RUNNING somehow.', True), result[1]
|
||||
)
|
||||
|
||||
@mock.patch(
|
||||
'mistralclient.api.v2.action_executions.ActionExecutionManager.update'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user