Fix get task list of nonexistent execution

Closes-bug: #1326287

Change-Id: Ib532e32066223969cf39a023151f7a648f29e010
This commit is contained in:
Nikolay Mahotkin 2014-06-06 12:00:14 +04:00
parent 787c48aef0
commit bb2f984d23
5 changed files with 18 additions and 3 deletions

View File

@ -15,7 +15,6 @@
# under the License.
import json
import testtools
import uuid
from tempest import exceptions
@ -203,7 +202,6 @@ class AdvancedTests(base.TestCaseAdvanced):
self.assertRaises(exceptions.NotFound, self.client.update_execution,
'test123', id, put_body)
@testtools.skip('https://bugs.launchpad.net/mistral/+bug/1326287')
@test.attr(type='negative')
def test_get_tasks_list_of_nonexistent_execution(self):
@ -218,7 +216,6 @@ class AdvancedNegativeTestsWithExecutionCreate(base.TestCaseAdvanced):
self.execution = self._create_execution('test123', 'aloha')[1]
@testtools.skip('https://bugs.launchpad.net/mistral/+bug/1326278')
@test.attr(type='negative')
def test_get_nonexistent_task(self):
self.assertRaises(exceptions.NotFound, self.client.get_task,

View File

@ -114,9 +114,12 @@ class TasksController(rest.RestController):
return Task.from_dict(values)
@rest_utils.wrap_wsme_controller_exception
@wsme_pecan.wsexpose(Tasks, wtypes.text, wtypes.text)
def get_all(self, workbook_name, execution_id):
"""Return all tasks within the execution."""
db_api.ensure_execution_exists(workbook_name, execution_id)
LOG.debug("Fetch tasks [workbook_name=%s, execution_id=%s]" %
(workbook_name, execution_id))

View File

@ -98,6 +98,10 @@ def execution_get(workbook_name, id):
return IMPL.execution_get(workbook_name, id)
def ensure_execution_exists(workbook_name, execution_id):
return IMPL.ensure_execution_exists(workbook_name, execution_id)
def execution_create(workbook_name, values):
return IMPL.execution_create(workbook_name, values)

View File

@ -405,6 +405,10 @@ def execution_get(workbook_name, execution_id):
return execution
def ensure_execution_exists(workbook_name, execution_id):
execution_get(workbook_name, execution_id)
@to_dict
def executions_get_all(**kwargs):
return _executions_get_all(**kwargs)

View File

@ -85,6 +85,8 @@ class TestTasksController(base.FunctionalTest):
@mock.patch.object(db_api, "tasks_get",
mock.MagicMock(return_value=TASKS))
@mock.patch.object(db_api, "ensure_execution_exists",
mock.MagicMock(return_value={'id': "abc123"}))
def test_get_all(self):
resp = self.app.get('/v1/workbooks/my_workbook/executions/123/tasks')
@ -92,3 +94,8 @@ class TestTasksController(base.FunctionalTest):
self.assertEqual(len(resp.json), 1)
self.assertDictEqual(TASKS[0], canonize(resp.json['tasks'][0]))
@mock.patch.object(db_api, "tasks_get",
mock.MagicMock(return_value=TASKS))
def test_get_all_nonexistent_execution(self):
self.assertNotFound('/v1/workbooks/my_workbook/executions/123/tasks')