Пример #1
0
 def test_tuple_urlconf(self):
     request = rf.get('/')
     urls = __import__('tests.urls').urls
     urls.urlpatterns = tuple(urls.urlpatterns)
     request.urlconf = urls
     middleware = DebugToolbarMiddleware()
     with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
         middleware.process_request(request)
         self.assertFalse(isinstance(request.urlconf, basestring))
    def test_tuple_urlconf(self):
        request = rf.get('/')
        urls = __import__('tests.urls').urls
        urls.urlpatterns = tuple(urls.urlpatterns)
        request.urlconf = urls
        middleware = DebugToolbarMiddleware()

        middleware.process_request(request)

        self.assertFalse(isinstance(request.urlconf, six.string_types))
Пример #3
0
    def test_tuple_urlconf(self):
        request = rf.get('/')
        urls = __import__('tests.urls').urls
        urls.urlpatterns = tuple(urls.urlpatterns)
        request.urlconf = urls
        middleware = DebugToolbarMiddleware()

        middleware.process_request(request)

        self.assertFalse(isinstance(request.urlconf, six.string_types))
    def test_request_urlconf_string(self):
        request = rf.get('/')
        set_urlconf('tests.urls')
        middleware = DebugToolbarMiddleware()

        middleware.process_request(request)

        patterns = get_resolver(get_urlconf()).url_patterns
        self.assertTrue(hasattr(patterns[1], '_callback_str'))
        self.assertEqual(patterns[-1]._callback_str, 'tests.views.execute_sql')
Пример #5
0
    def test_request_urlconf_module(self):
        request = rf.get('/')
        request.urlconf = __import__('tests.urls').urls
        middleware = DebugToolbarMiddleware()

        middleware.process_request(request)

        self.assertFalse(isinstance(request.urlconf, six.string_types))

        patterns = request.urlconf.urlpatterns
        self.assertTrue(hasattr(patterns[1], '_callback_str'))
        self.assertEqual(patterns[-1]._callback_str, 'tests.views.execute_sql')
Пример #6
0
    def test_request_urlconf_string(self):
        request = rf.get('/')
        request.urlconf = 'tests.urls'
        middleware = DebugToolbarMiddleware()

        with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, basestring))

            self.assertTrue(hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
            self.assertEquals(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
Пример #7
0
    def test_request_urlconf_module(self):
        request = rf.get('/')
        request.urlconf = __import__('tests.urls').urls
        middleware = DebugToolbarMiddleware()

        with self.settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, six.string_types))

            self.assertTrue(hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
            self.assertEqual(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
Пример #8
0
    def test_request_urlconf_module(self):
        request = rf.get('/')
        request.urlconf = __import__('tests.urls').urls
        middleware = DebugToolbarMiddleware()

        with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, string_types))

            self.assertTrue(hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
            self.assertEqual(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
    def test_request_urlconf_module(self):
        request = rf.get('/')
        request.urlconf = __import__('tests.urls').urls
        middleware = DebugToolbarMiddleware()

        middleware.process_request(request)

        self.assertFalse(isinstance(request.urlconf, six.string_types))

        patterns = request.urlconf.urlpatterns
        self.assertTrue(hasattr(patterns[1], '_callback_str'))
        self.assertEqual(patterns[-1]._callback_str, 'tests.views.execute_sql')
Пример #10
0
    def test_request_urlconf_string(self):
        request = rf.get('/')
        request.urlconf = 'tests.urls'
        middleware = DebugToolbarMiddleware()

        with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, basestring))

            self.assertTrue(hasattr(request.urlconf.urlpatterns[0], '_callback_str'))
            self.assertEquals(request.urlconf.urlpatterns[0]._callback_str, 'debug_toolbar.views.debug_media')
            self.assertTrue(hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
            self.assertEquals(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
Пример #11
0
    def test_request_urlconf_string(self):
        request = self.request

        request.urlconf = 'debug_toolbar.tests.urls'
        request.META = {'REMOTE_ADDR': '127.0.0.1'}
        middleware = DebugToolbarMiddleware()

        with Settings(DEBUG=True):
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, basestring))

            self.assertTrue(hasattr(request.urlconf.urlpatterns[0], '_callback_str'))
            self.assertEquals(request.urlconf.urlpatterns[0]._callback_str, 'debug_toolbar.views.debug_media')
            self.assertEquals(request.urlconf.urlpatterns[-1].urlconf_name.__name__, 'debug_toolbar.tests.urls')
Пример #12
0
    def test_request_urlconf_string_per_request(self):
        request = rf.get('/')
        request.urlconf = 'debug_toolbar.urls'
        middleware = DebugToolbarMiddleware()

        with self.settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
            middleware.process_request(request)
            request.urlconf = 'tests.urls'
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, six.string_types))

            patterns = request.urlconf.urlpatterns
            self.assertTrue(hasattr(patterns[1], '_callback_str'))
            self.assertEqual(patterns[-1]._callback_str, 'tests.views.execute_sql')
Пример #13
0
    def test_request_urlconf_string(self):
        request = self.request

        request.urlconf = "tests.urls"
        request.META = {"REMOTE_ADDR": "127.0.0.1"}
        middleware = DebugToolbarMiddleware()

        with Settings(INTERNAL_IPS=["127.0.0.1"], DEBUG=True):
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, basestring))

            self.assertTrue(hasattr(request.urlconf.urlpatterns[0], "_callback_str"))
            self.assertEquals(request.urlconf.urlpatterns[0]._callback_str, "debug_toolbar.views.debug_media")
            self.assertEquals(request.urlconf.urlpatterns[-1].urlconf_name.__name__, "tests.urls")
Пример #14
0
 def test_request_urlconf_module(self):
     request = self.request
     
     request.urlconf = __import__('tests.urls').urls
     request.META = {'REMOTE_ADDR': '127.0.0.1'}
     middleware = DebugToolbarMiddleware()
     
     with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
         middleware.process_request(request)
         
         self.assertFalse(isinstance(request.urlconf, basestring))
         
         self.assertTrue(hasattr(request.urlconf.urlpatterns[0], '_callback_str'))
         self.assertEquals(request.urlconf.urlpatterns[0]._callback_str, 'debug_toolbar.views.debug_media')
         self.assertTrue(hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
         self.assertEquals(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
Пример #15
0
    def test_request_urlconf_module(self):
        request = self.request

        request.urlconf = __import__('tests.urls').urls
        request.META = {'REMOTE_ADDR': '127.0.0.1'}
        middleware = DebugToolbarMiddleware()

        with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, basestring))

            self.assertTrue(
                hasattr(request.urlconf.urlpatterns[0], '_callback_str'))
            self.assertEquals(request.urlconf.urlpatterns[0]._callback_str,
                              'debug_toolbar.views.debug_media')
            self.assertTrue(
                hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
            self.assertEquals(request.urlconf.urlpatterns[-1]._callback_str,
                              'tests.views.execute_sql')