Fix get execution list when workbook does not exist

Closes-bug: #1325933

Change-Id: I72dd6631b661f270a91f363e7a049a632f820e24
This commit is contained in:
Nikolay Mahotkin 2014-06-09 15:26:18 +04:00
parent 3f1a17fc4f
commit 7770099626
3 changed files with 14 additions and 4 deletions

View File

@ -122,7 +122,6 @@ class SanityTests(base.TestCase):
self.client.get_workbook_definition,
'fksn')
@testtools.skip('https://bugs.launchpad.net/mistral/+bug/1325933')
@test.attr(type='negative')
def test_get_executions_list_from_nonexistent_workbook(self):
self.assertRaises(exceptions.NotFound, self.client.get_list_obj,

View File

@ -140,7 +140,8 @@ class ExecutionsController(rest.RestController):
"""Return all Executions."""
LOG.debug("Fetch executions [workbook_name=%s]" % workbook_name)
executions = [Execution.from_dict(values)
for values in db_api.executions_get(workbook_name)]
if db_api.workbook_get(workbook_name):
executions = [Execution.from_dict(values)
for values in db_api.executions_get(workbook_name)]
return Executions(executions=executions)
return Executions(executions=executions)

View File

@ -122,6 +122,8 @@ class TestExecutionsController(base.FunctionalTest):
@mock.patch.object(db_api, 'executions_get',
mock.MagicMock(return_value=EXECS))
@mock.patch.object(db_api, 'workbook_get',
mock.MagicMock(return_value={'name': 'my_workbook'}))
def test_get_all(self):
resp = self.app.get('/v1/workbooks/my_workbook/executions')
@ -129,3 +131,11 @@ class TestExecutionsController(base.FunctionalTest):
self.assertEqual(len(resp.json), 1)
self.assertDictEqual(EXECS[0], canonize(resp.json['executions'][0]))
@mock.patch.object(db_api, 'executions_get',
mock.MagicMock(return_value=EXECS))
def test_get_all_no_workbook(self):
resp = self.app.get('/v1/workbooks/my_workbook/executions',
expect_errors=True)
self.assertEqual(resp.status_int, 404)