From 4485f72c4ccc9bf8fbd0129e58a653f81140aad7 Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Thu, 11 Sep 2014 13:03:31 +0400 Subject: [PATCH] Fixed execution create method * Fixed passing 'params' and 'input' parameters to API Change-Id: Ic28e4a727f2fc2f454c02ed03ff17a7da00eb0d1 --- mistralclient/api/v2/executions.py | 7 +++++-- mistralclient/tests/unit/v2/test_executions.py | 16 +++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/mistralclient/api/v2/executions.py b/mistralclient/api/v2/executions.py index 86d25146..8f3b54d0 100644 --- a/mistralclient/api/v2/executions.py +++ b/mistralclient/api/v2/executions.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json + from mistralclient.api import base @@ -28,9 +30,10 @@ class ExecutionManager(base.ResourceManager): data = {'workflow_name': workflow_name} if workflow_input: - data.update({'workflow_input': workflow_input}) + data.update({'input': json.dumps(workflow_input)}) - data.update(params) + if params: + data.update({'params': json.dumps(params)}) return self._create('/executions', data) diff --git a/mistralclient/tests/unit/v2/test_executions.py b/mistralclient/tests/unit/v2/test_executions.py index 33aba2c3..cac41684 100644 --- a/mistralclient/tests/unit/v2/test_executions.py +++ b/mistralclient/tests/unit/v2/test_executions.py @@ -24,14 +24,12 @@ EXEC = { 'id': "123", 'workflow_name': 'my_wf', 'state': 'RUNNING', - 'workflow_input': """ - { - "person": { - "first_name": "John", - "last_name": "Doe" - } + 'input': { + "person": { + "first_name": "John", + "last_name": "Doe" } - """ + } } @@ -44,11 +42,11 @@ class TestExecutionsV2(base.BaseClientV2Test): mock = self.mock_http_post(content=EXEC) body = { 'workflow_name': EXEC['workflow_name'], - 'workflow_input': EXEC['workflow_input'], + 'input': json.dumps(EXEC['input']), } ex = self.executions.create(EXEC['workflow_name'], - EXEC['workflow_input']) + EXEC['input']) self.assertIsNotNone(ex) self.assertEqual(executions.Execution(self.executions, EXEC).__dict__,