diff --git a/mistral/api/controllers/v2/execution.py b/mistral/api/controllers/v2/execution.py index 669e1328..1f990d88 100644 --- a/mistral/api/controllers/v2/execution.py +++ b/mistral/api/controllers/v2/execution.py @@ -153,7 +153,7 @@ class ExecutionsController(rest.RestController): if new_description: wf_ex = db_api.update_workflow_execution( id, - description=new_description + {"description": new_description} ) elif new_state == states.PAUSED: diff --git a/mistral/tests/functional/api/v2/test_mistral_basic_v2.py b/mistral/tests/functional/api/v2/test_mistral_basic_v2.py index 888e3275..cb785b35 100644 --- a/mistral/tests/functional/api/v2/test_mistral_basic_v2.py +++ b/mistral/tests/functional/api/v2/test_mistral_basic_v2.py @@ -321,6 +321,15 @@ class ExecutionTestsV2(base.TestCase): self.assertEqual(200, resp.status) self.assertEqual('PAUSED', body['state']) + @test.attr(type='sanity') + def test_update_execution_description(self): + _, execution = self.client.create_execution(self.direct_wf) + resp, body = self.client.update_execution( + execution['id'], '{"description": "description"}') + + self.assertEqual(200, resp.status) + self.assertEqual('description', body['description']) + @test.attr(type='sanity') def test_update_execution_fail(self): _, execution = self.client.create_execution(self.direct_wf) diff --git a/mistral/tests/unit/api/v2/test_executions.py b/mistral/tests/unit/api/v2/test_executions.py index 1ac4e1a5..049c8622 100644 --- a/mistral/tests/unit/api/v2/test_executions.py +++ b/mistral/tests/unit/api/v2/test_executions.py @@ -145,6 +145,18 @@ class TestExecutionsController(base.FunctionalTest): WF_EX_JSON_WITH_DESC ) + @mock.patch('mistral.db.v2.api.ensure_workflow_execution_exists') + @mock.patch('mistral.db.v2.api.update_workflow_execution', + return_value=WF_EX) + def test_put_description(self, mock_update, mock_ensure): + update_params = {'description': 'execution description.'} + + resp = self.app.put_json('/v2/executions/123', update_params) + + self.assertEqual(resp.status_int, 200) + mock_ensure.assert_called_once_with('123') + mock_update.assert_called_once_with('123', update_params) + @mock.patch.object(rpc.EngineClient, 'start_workflow') def test_post(self, f): f.return_value = WF_EX.to_dict()