Fix update nonexistent task

Closes-bug: #1326284

Change-Id: I0eeaff7fbf44c975d2aac0a4839ad0f5fecd3276
This commit is contained in:
Nikolay Mahotkin 2014-06-09 17:23:20 +04:00
parent 3f1a17fc4f
commit f11aa22684
3 changed files with 18 additions and 9 deletions

View File

@ -225,7 +225,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):