Ejemplo n.º 1
0
 def test_template_data_in_create_without_template_file(self):
     self.res.action = self.res.CREATE
     self.res.nested = mock.MagicMock()
     self.res.get_template_file = mock.Mock(
         side_effect=exception.TemplateNotFound(
             message='test_resource.template'))
     self.assertEqual('{}', self.res.template_data())
Ejemplo n.º 2
0
 def test_template_data_in_update_without_template_file(self):
     self.res.action = self.res.UPDATE
     self.res.nested = mock.MagicMock()
     self.res.get_template_file = mock.Mock(
         side_effect=exception.TemplateNotFound(
             message='test_resource.template'))
     self.assertRaises(exception.TemplateNotFound, self.res.template_data)
Ejemplo n.º 3
0
 def get_template_file(template_name, allowed_schemes):
     try:
         return urlfetch.get(template_name, allowed_schemes=allowed_schemes)
     except (IOError, exceptions.RequestException) as r_exc:
         args = {'name': template_name, 'exc': six.text_type(r_exc)}
         msg = _('Could not fetch remote template '
                 '"%(name)s": %(exc)s') % args
         raise exception.TemplateNotFound(message=msg)