Ejemplo n.º 1
0
 def test_content_map_class_based_view(self):
     content_map = models.ContentMap(
         view='urlographer.sample_views.SampleClassView')
     content_map.options['initkwargs'] = {'test_val': 'testing 1 2 3'}
     content_map.save()
     models.URLMap.objects.create(site=self.site,
                                  path='/test',
                                  content_map=content_map)
     response = views.route(self.factory.get('/test'))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.content, 'test value=testing 1 2 3')
Ejemplo n.º 2
0
 def test_content_map_view_function(self):
     content_map = models.ContentMap(
         view='urlographer.sample_views.sample_view')
     content_map.options['test_val'] = 'testing 1 2 3'
     content_map.save()
     urlmap = models.URLMap.objects.create(site=self.site,
                                           path='/test',
                                           content_map=content_map)
     request = self.factory.get('/test')
     response = views.route(request)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.content, 'test value=testing 1 2 3')
     self.assertEqual(request.urlmap, urlmap)
Ejemplo n.º 3
0
 def test_route_redirect_canonical(self):
     content_map = models.ContentMap(
         view='django.views.generic.base.TemplateView')
     content_map.options['initkwargs'] = {
         'template_name': 'admin/base.html'
     }
     content_map.save()
     models.URLMap.objects.create(site=self.site,
                                  path='/test',
                                  content_map=content_map)
     response = views.route(self.factory.get('/TEST'))
     self.assertEqual(response.status_code, 301)
     self.assertEqual(response._headers['location'][1],
                      'http://example.com/test')
Ejemplo n.º 4
0
 def test_unicode(self):
     content_map = models.ContentMap(view='urlographer.views.route',
                                     options={'article_id': 3})
     self.assertEqual(unicode(content_map),
                      "urlographer.views.route(**{'article_id': 3})")
Ejemplo n.º 5
0
 def test_save_nonexistent_view(self):
     content_map = models.ContentMap(view='urlographer.views.nonexistent')
     self.assertRaisesMessage(ValidationError, 'Please enter a valid view.',
                              content_map.clean)
Ejemplo n.º 6
0
 def test_save_existing_view(self):
     content_map = models.ContentMap(view='urlographer.views.route')
     self.assertEqual(content_map.clean(), None)