def test_process_request_no_op(self):

        from urlmiddleware import URLMiddleware

        class MyProcessRequestMiddleware(object):

            def process_request(self, request, *args, **kwargs):
                pass

        def mock_match(self, path, middleware_method=None):
            return [MyProcessRequestMiddleware(), ]

        request = self.factory.get('/foo/bar/')

        with patch.object(URLMiddleware, 'get_matched_middleware', mock_match):

            m = URLMiddleware()

            self.assertEquals(m.process_request(request), None)
Beispiel #2
0
    def test_process_request_no_op(self):

        from urlmiddleware import URLMiddleware

        class MyProcessRequestMiddleware(object):
            def process_request(self, request, *args, **kwargs):
                pass

        def mock_match(self, path, middleware_method=None):
            return [
                MyProcessRequestMiddleware(),
            ]

        request = self.factory.get('/foo/bar/')

        with patch.object(URLMiddleware, 'get_matched_middleware', mock_match):

            m = URLMiddleware()

            self.assertEquals(m.process_request(request), None)
    def test_process_request(self):

        from urlmiddleware import URLMiddleware

        class MyProcessRequestMiddleware(object):

            def process_request(self, request, *args, **kwargs):
                from django.http import HttpResponse
                return HttpResponse("New Process Request Response")

        def mock_match(self, path, middleware_method=None):
            return [MyProcessRequestMiddleware(), ]

        request = self.factory.get('/foo/bar/')

        with patch.object(URLMiddleware, 'get_matched_middleware', mock_match):

            m = URLMiddleware()

            expected_content = "New Process Request Response"
            self.assertEquals(m.process_request(request).content, expected_content)
Beispiel #4
0
    def test_process_request(self):

        from urlmiddleware import URLMiddleware

        class MyProcessRequestMiddleware(object):
            def process_request(self, request, *args, **kwargs):
                from django.http import HttpResponse
                return HttpResponse("New Process Request Response")

        def mock_match(self, path, middleware_method=None):
            return [
                MyProcessRequestMiddleware(),
            ]

        request = self.factory.get('/foo/bar/')

        with patch.object(URLMiddleware, 'get_matched_middleware', mock_match):

            m = URLMiddleware()

            expected_content = "New Process Request Response"
            self.assertEquals(
                m.process_request(request).content, expected_content)