当前位置: 首页>>代码示例>>Python>>正文


Python views.route函数代码示例

本文整理汇总了Python中urlographer.views.route函数的典型用法代码示例。如果您正苦于以下问题:Python route函数的具体用法?Python route怎么用?Python route使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了route函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_redirect

 def test_redirect(self):
     target = models.URLMap.objects.create(
         site=self.site, path='/target', status_code=204)
     models.URLMap.objects.create(
         site=self.site, path='/source', redirect=target, status_code=302)
     response = views.route(self.factory.get('/source'))
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response._headers['location'][1],
                      'http://example.com/target')
开发者ID:jgmize,项目名称:django-urlographer,代码行数:9,代码来源:tests.py

示例2: test_content_map_class_based_view

 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')
开发者ID:jgmize,项目名称:django-urlographer,代码行数:11,代码来源:tests.py

示例3: test_handler_as_func_newrelic

 def test_handler_as_func_newrelic(self):
     self.mox.StubOutWithMock(views, 'newrelic')
     models.URLMap.objects.create(
         site=self.site, path='/page', status_code=206)
     views.newrelic.agent = self.mox.CreateMockAnything()
     views.newrelic.agent.set_transaction_name(
         'urlographer.sample_views:sample_handler.get',
         'Python/urlographer')
     self.mox.ReplayAll()
     response = views.route(self.factory.get('/page'))
     self.assertContains(response, 'modified content', status_code=206)
开发者ID:jvzammit,项目名称:django-urlographer,代码行数:11,代码来源:tests.py

示例4: test_content_map_view_function

 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)
开发者ID:jgmize,项目名称:django-urlographer,代码行数:12,代码来源:tests.py

示例5: test_route_redirect_canonical

 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')
开发者ID:jgmize,项目名称:django-urlographer,代码行数:12,代码来源:tests.py

示例6: test_force_cache_invalidation

 def test_force_cache_invalidation(self):
     path = '/test'
     request = self.factory.get(path)
     site = get_current_site(request)
     url_map = models.URLMap(site=site, path=path, status_code=204)
     self.mox.StubOutWithMock(views, 'force_cache_invalidation')
     self.mox.StubOutWithMock(models.URLMapManager, 'cached_get')
     views.force_cache_invalidation(request).AndReturn(True)
     models.URLMapManager.cached_get(
         site, path, force_cache_invalidation=True).AndReturn(
             url_map)
     self.mox.ReplayAll()
     response = views.route(request)
     self.assertEqual(response.status_code, 204)
开发者ID:jgmize,项目名称:django-urlographer,代码行数:14,代码来源:tests.py

示例7: test_content_map_class_based_view_newrelic

 def test_content_map_class_based_view_newrelic(self):
     self.mox.StubOutWithMock(views, 'newrelic')
     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)
     views.newrelic.agent = self.mox.CreateMockAnything()
     views.newrelic.agent.set_transaction_name(
         'urlographer.sample_views:SampleClassView.get',
         'Python/urlographer')
     self.mox.ReplayAll()
     response = views.route(self.factory.get('/test'))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.content, 'test value=testing 1 2 3')
开发者ID:jvzammit,项目名称:django-urlographer,代码行数:17,代码来源:tests.py

示例8: test_content_map_view_function_newrelic

 def test_content_map_view_function_newrelic(self):
     self.mox.StubOutWithMock(views, 'newrelic')
     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')
     views.newrelic.agent = self.mox.CreateMockAnything()
     views.newrelic.agent.set_transaction_name(
         'urlographer.sample_views:sample_view.get',
         'Python/urlographer')
     self.mox.ReplayAll()
     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)
开发者ID:jvzammit,项目名称:django-urlographer,代码行数:18,代码来源:tests.py

示例9: test_signal_called_on_urlmap_bound_to_request

    def test_signal_called_on_urlmap_bound_to_request(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,
            force_secure=False)
        request = self.factory.get('/test')

        # Mocks:
        self.mock.StubOutWithMock(
            views.urlmap_bound_to_request, 'send')

        # Expected calls:
        views.urlmap_bound_to_request.send(sender=None, request=request)

        self.mock.ReplayAll()
        response = views.route(request)
        self.mock.VerifyAll()
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'test value=testing 1 2 3')
        self.assertEqual(request.urlmap, urlmap)
开发者ID:ConsumerAffairs,项目名称:django-urlographer,代码行数:23,代码来源:tests.py

示例10: test_handler_as_class

 def test_handler_as_class(self):
     models.URLMap.objects.create(
         site=self.site, path='/page', status_code=402)
     response = views.route(self.factory.get('/page'))
     self.assertContains(response, 'payment required', status_code=402)
开发者ID:jgmize,项目名称:django-urlographer,代码行数:5,代码来源:tests.py

示例11: test_handler_as_func

 def test_handler_as_func(self):
     models.URLMap.objects.create(
         site=self.site, path='/page', status_code=206)
     response = views.route(self.factory.get('/page'))
     self.assertContains(response, 'modified content', status_code=206)
开发者ID:jgmize,项目名称:django-urlographer,代码行数:5,代码来源:tests.py

示例12: test_route_gone

 def test_route_gone(self):
     models.URLMap.objects.create(
         site=self.site, status_code=410, path='/410')
     request = self.factory.get('/410')
     response = views.route(request)
     self.assertEqual(response.status_code, 410)
开发者ID:jgmize,项目名称:django-urlographer,代码行数:6,代码来源:tests.py


注:本文中的urlographer.views.route函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。