def test_process_view_no_op(self):

        from urlmiddleware import URLMiddleware

        class MyProcessViewMiddleware(object):

            def process_view(self, request, view, view_args, view_kwargs):
                pass

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

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

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

            m = URLMiddleware()

            self.assertEquals(m.process_view(request, lambda x: None, [], {}), None)
Beispiel #2
0
    def test_process_view_no_op(self):

        from urlmiddleware import URLMiddleware

        class MyProcessViewMiddleware(object):
            def process_view(self, request, view, view_args, view_kwargs):
                pass

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

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

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

            m = URLMiddleware()

            self.assertEquals(m.process_view(request, lambda x: None, [], {}),
                              None)
    def test_process_view(self):

        from urlmiddleware import URLMiddleware

        class MyProcessViewMiddleware(object):

            def process_view(self, request, view, view_args, view_kwargs):
                from django.http import HttpResponse
                return HttpResponse("New Process View Response")

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

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

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

            m = URLMiddleware()

            expected_content = "New Process View Response"
            self.assertEquals(m.process_view(request, lambda x: None, [], {}).content, expected_content)
Beispiel #4
0
    def test_process_view(self):

        from urlmiddleware import URLMiddleware

        class MyProcessViewMiddleware(object):
            def process_view(self, request, view, view_args, view_kwargs):
                from django.http import HttpResponse
                return HttpResponse("New Process View Response")

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

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

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

            m = URLMiddleware()

            expected_content = "New Process View Response"
            self.assertEquals(
                m.process_view(request, lambda x: None, [], {}).content,
                expected_content)