list_template_functions raises NotFound exception
Let list_template_functions raise NotFound exception instead, while a nonexistent template version provided. Change-Id: I1eff0f511abb0c1e098946e1d90b6bda9f59b249 Closes-Bug: #1505050
This commit is contained in:
parent
c2eb03de5a
commit
48ed305b4e
@ -1172,7 +1172,12 @@ class EngineService(service.Service):
|
||||
|
||||
def list_template_functions(self, cnxt, template_version):
|
||||
mgr = templatem._get_template_extension_manager()
|
||||
tmpl_class = mgr[template_version]
|
||||
try:
|
||||
tmpl_class = mgr[template_version]
|
||||
except KeyError:
|
||||
raise exception.NotFound(_("Template with version %s not found") %
|
||||
template_version)
|
||||
|
||||
functions = []
|
||||
for func_name, func in six.iteritems(tmpl_class.plugin.functions):
|
||||
if func is not hot_functions.Removed:
|
||||
|
@ -989,6 +989,21 @@ class StackServiceTest(common.HeatTestCase):
|
||||
self.assertEqual(sorted(expected, key=lambda k: k['functions']),
|
||||
sorted(functions, key=lambda k: k['functions']))
|
||||
|
||||
@mock.patch('heat.engine.template._get_template_extension_manager')
|
||||
def test_list_template_functions_version_not_found(self, templ_mock):
|
||||
class DummyMgr(object):
|
||||
def __getitem__(self, item):
|
||||
raise KeyError()
|
||||
|
||||
templ_mock.return_value = DummyMgr()
|
||||
version = 'dummytemplate'
|
||||
ex = self.assertRaises(exception.NotFound,
|
||||
self.eng.list_template_functions,
|
||||
self.ctx,
|
||||
version)
|
||||
msg = "Template with version %s not found" % version
|
||||
self.assertEqual(msg, six.text_type(ex))
|
||||
|
||||
def test_stack_list_all_empty(self):
|
||||
sl = self.eng.list_stacks(self.ctx)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user