Ejemplo n.º 1
0
 def test_get_generic_template(self):
     """
     Test a completely generic view that renders a template on GET
     with the template name as an argument at instantiation.
     """
     self._assert_about(TemplateView.as_view(template_name='tests:templates/about.html')(
         DummyRequest(path='/about/', method='GET')
     ))
Ejemplo n.º 2
0
 def test_content_type(self):
     view = TemplateView.as_view(template_name='tests:templates/robots.txt', content_type='text/plain')
     response = view(DummyRequest(path='/', method='GET'))
     self.assertEqual(response.headers['Content-Type'], 'text/plain; charset=UTF-8')
Ejemplo n.º 3
0
 def test_template_name_required(self):
     """
     A template view must provide a template name
     """
     view = TemplateView.as_view()
     self.assertRaises(ImproperlyConfigured, view, DummyRequest(path='/', method='GET'))