Fix execution update description error

Fix the wrong param of db update execution api, add some tests accordingly.

Change-Id: I7c389e781f9982703115d82d0336ddb0df6b2b99
Closes-Bug: #1467114
This commit is contained in:
kong 2015-06-20 22:55:56 +08:00 committed by Lingxian Kong
parent 029b1f2ddf
commit 834f69839a
3 changed files with 22 additions and 1 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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()