def _no_template_file(self, function): env = environment.Environment() info = environment.ResourceInfo(env.registry, ['ResourceWithWrongRefOnFile'], 'not_existing.yaml') mock_iterable = mock.MagicMock(return_value=iter([info])) with mock.patch('heat.engine.environment.ResourceRegistry.iterable_by', new=mock_iterable): ex = self.assertRaises(exception.TemplateNotFound, function, self.ctx, type_name='ResourceWithWrongRefOnFile') msg = 'Could not fetch remote template "not_existing.yaml"' self.assertIn(msg, six.text_type(ex))
def _no_template_file(self, function): env = environment.Environment() info = environment.ResourceInfo(env.registry, ['ResourceWithWrongRefOnFile'], 'not_existing.yaml') mock_iterable = mock.MagicMock(return_value=iter([info])) with mock.patch('heat.engine.environment.ResourceRegistry.iterable_by', new=mock_iterable): ex = self.assertRaises(exception.InvalidGlobalResource, function, self.ctx, type_name='ResourceWithWrongRefOnFile') msg = ('There was an error loading the definition of the global ' 'resource type ResourceWithWrongRefOnFile.') self.assertIn(msg, six.text_type(ex))