Fix update nonexistent task
Closes-bug: #1326284 Change-Id: I0eeaff7fbf44c975d2aac0a4839ad0f5fecd3276
This commit is contained in:
parent
3f1a17fc4f
commit
f11aa22684
|
@ -225,7 +225,6 @@ class AdvancedNegativeTestsWithExecutionCreate(base.TestCaseAdvanced):
|
||||||
self.assertRaises(exceptions.NotFound, self.client.get_task,
|
self.assertRaises(exceptions.NotFound, self.client.get_task,
|
||||||
'test123', self.execution['id'], str(uuid.uuid4()))
|
'test123', self.execution['id'], str(uuid.uuid4()))
|
||||||
|
|
||||||
@testtools.skip('https://bugs.launchpad.net/mistral/+bug/1326284')
|
|
||||||
@test.attr(type='negative')
|
@test.attr(type='negative')
|
||||||
def test_update_nonexistent_task(self):
|
def test_update_nonexistent_task(self):
|
||||||
|
|
||||||
|
|
|
@ -85,14 +85,15 @@ class TasksController(rest.RestController):
|
||||||
"[workbook_name=%s, execution_id=%s, id=%s, task=%s]" %
|
"[workbook_name=%s, execution_id=%s, id=%s, task=%s]" %
|
||||||
(workbook_name, execution_id, id, task))
|
(workbook_name, execution_id, id, task))
|
||||||
|
|
||||||
# TODO(rakhmerov): pass task result once it's implemented
|
if db_api.task_get(workbook_name, execution_id, id):
|
||||||
engine = pecan.request.context['engine']
|
# TODO(rakhmerov): pass task result once it's implemented
|
||||||
values = engine.convey_task_result(workbook_name,
|
engine = pecan.request.context['engine']
|
||||||
execution_id,
|
values = engine.convey_task_result(workbook_name,
|
||||||
id,
|
execution_id,
|
||||||
task.state, None)
|
id,
|
||||||
|
task.state, None)
|
||||||
|
|
||||||
return Task.from_dict(values)
|
return Task.from_dict(values)
|
||||||
|
|
||||||
@wsme_pecan.wsexpose(Tasks, wtypes.text, wtypes.text)
|
@wsme_pecan.wsexpose(Tasks, wtypes.text, wtypes.text)
|
||||||
def get_all(self, workbook_name, execution_id):
|
def get_all(self, workbook_name, execution_id):
|
||||||
|
|
|
@ -50,14 +50,23 @@ class TestTasksController(base.FunctionalTest):
|
||||||
|
|
||||||
@mock.patch.object(engine.EngineClient, "convey_task_result",
|
@mock.patch.object(engine.EngineClient, "convey_task_result",
|
||||||
mock.MagicMock(return_value=UPDATED_TASK))
|
mock.MagicMock(return_value=UPDATED_TASK))
|
||||||
|
@mock.patch.object(db_api, "task_get",
|
||||||
|
mock.MagicMock(return_value=TASKS[0]))
|
||||||
def test_put(self):
|
def test_put(self):
|
||||||
resp = self.app.put_json(
|
resp = self.app.put_json(
|
||||||
'/v1/workbooks/my_workbook/executions/123/tasks/1',
|
'/v1/workbooks/my_workbook/executions/123/tasks/1',
|
||||||
dict(state='STOPPED'))
|
dict(state='STOPPED'))
|
||||||
|
|
||||||
self.assertEqual(resp.status_int, 200)
|
self.assertEqual(resp.status_int, 200)
|
||||||
self.assertDictEqual(UPDATED_TASK, resp.json)
|
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.patch.object(db_api, "tasks_get",
|
||||||
mock.MagicMock(return_value=TASKS))
|
mock.MagicMock(return_value=TASKS))
|
||||||
def test_get_all(self):
|
def test_get_all(self):
|
||||||
|
|
Loading…
Reference in New Issue