From b413aa087eb89dc17812fe2d70f23b9db5ca0fa8 Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Thu, 8 Nov 2018 20:53:24 +0700 Subject: [PATCH] Allow None for 'params' when starting a workflow execution Change-Id: Ic28352d9acbe9e3f53a9d33a4ff0a5f99261f53f Closes-Bug: #1793651 --- mistral/api/controllers/v2/execution.py | 2 +- mistral/tests/unit/api/v2/test_executions.py | 17 +++++++++++++++++ ...kflow_execution_params-f25b752e207d51d7.yaml | 6 ++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/allow_none_for_workflow_execution_params-f25b752e207d51d7.yaml diff --git a/mistral/api/controllers/v2/execution.py b/mistral/api/controllers/v2/execution.py index 675fb0c32..945feb908 100644 --- a/mistral/api/controllers/v2/execution.py +++ b/mistral/api/controllers/v2/execution.py @@ -274,7 +274,7 @@ class ExecutionsController(rest.RestController): result_exec_dict.get('id'), result_exec_dict.get('input'), description=result_exec_dict.get('description', ''), - **result_exec_dict.get('params', {}) + **result_exec_dict.get('params') or {} ) return resources.Execution.from_dict(result) diff --git a/mistral/tests/unit/api/v2/test_executions.py b/mistral/tests/unit/api/v2/test_executions.py index 6a02391a4..c696d1152 100644 --- a/mistral/tests/unit/api/v2/test_executions.py +++ b/mistral/tests/unit/api/v2/test_executions.py @@ -683,6 +683,23 @@ class TestExecutionsController(base.APITest): **json.loads(exec_dict['params']) ) + @mock.patch.object(rpc_clients.EngineClient, 'start_workflow') + def test_post_with_params_none(self, start_wf_func): + wf_ex_dict = WF_EX.to_dict() + + start_wf_func.return_value = wf_ex_dict + + json_body = WF_EX_JSON_WITH_DESC.copy() + + json_body['params'] = None + + expected_json = WF_EX_JSON_WITH_DESC + + resp = self.app.post_json('/v2/executions', json_body) + + self.assertEqual(201, resp.status_int) + self.assertDictEqual(expected_json, resp.json) + @mock.patch.object( rpc_clients.EngineClient, 'start_workflow', diff --git a/releasenotes/notes/allow_none_for_workflow_execution_params-f25b752e207d51d7.yaml b/releasenotes/notes/allow_none_for_workflow_execution_params-f25b752e207d51d7.yaml new file mode 100644 index 000000000..69f4d9ce4 --- /dev/null +++ b/releasenotes/notes/allow_none_for_workflow_execution_params-f25b752e207d51d7.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixed a backward compatibility issue: there was a change made in Rocky + that disallowed the 'params' property of a workflow execution to be None + when one wants to start a workflow.