Merge "Fix update nonexistent task"

This commit is contained in:
Jenkins 2014-06-11 17:52:44 +00:00 committed by Gerrit Code Review
commit 6061b8297c
3 changed files with 18 additions and 9 deletions

View File

@ -224,7 +224,6 @@ class AdvancedNegativeTestsWithExecutionCreate(base.TestCaseAdvanced):
self.assertRaises(exceptions.NotFound, self.client.get_task,
'test123', self.execution['id'], str(uuid.uuid4()))
@testtools.skip('https://bugs.launchpad.net/mistral/+bug/1326284')
@test.attr(type='negative')
def test_update_nonexistent_task(self):

View File

@ -85,14 +85,15 @@ class TasksController(rest.RestController):
"[workbook_name=%s, execution_id=%s, id=%s, task=%s]" %
(workbook_name, execution_id, id, task))
# TODO(rakhmerov): pass task result once it's implemented
engine = pecan.request.context['engine']
values = engine.convey_task_result(workbook_name,
execution_id,
id,
task.state, None)
if db_api.task_get(workbook_name, execution_id, id):
# TODO(rakhmerov): pass task result once it's implemented
engine = pecan.request.context['engine']
values = engine.convey_task_result(workbook_name,
execution_id,
id,
task.state, None)
return Task.from_dict(values)
return Task.from_dict(values)
@wsme_pecan.wsexpose(Tasks, wtypes.text, wtypes.text)
def get_all(self, workbook_name, execution_id):

View File

@ -50,14 +50,23 @@ class TestTasksController(base.FunctionalTest):
@mock.patch.object(engine.EngineClient, "convey_task_result",
mock.MagicMock(return_value=UPDATED_TASK))
@mock.patch.object(db_api, "task_get",
mock.MagicMock(return_value=TASKS[0]))
def test_put(self):
resp = self.app.put_json(
'/v1/workbooks/my_workbook/executions/123/tasks/1',
dict(state='STOPPED'))
self.assertEqual(resp.status_int, 200)
self.assertDictEqual(UPDATED_TASK, resp.json)
@mock.patch.object(engine.EngineClient, "convey_task_result",
mock.MagicMock(return_value=UPDATED_TASK))
def test_put_no_task(self):
resp = self.app.put_json(
'/v1/workbooks/my_workbook/executions/123/tasks/1',
dict(state='STOPPED'), expect_errors=True)
self.assertEqual(resp.status_int, 404)
@mock.patch.object(db_api, "tasks_get",
mock.MagicMock(return_value=TASKS))
def test_get_all(self):