Ejemplo n.º 1
0
    def test_process_response_only(self):
        request = HttpRequest()
        response = HttpResponse()
        target = TimingMiddleware()

        target.process_response(request, response)
        self.assertRaises(KeyError, lambda: response[TimingMiddleware.RESPONSE_HEADER])
Ejemplo n.º 2
0
    def test_process_response_only(self):
        request = HttpRequest()
        response = HttpResponse()
        target = TimingMiddleware()

        target.process_response(request, response)
        self.assertRaises(KeyError,
                          lambda: response[TimingMiddleware.RESPONSE_HEADER])
Ejemplo n.º 3
0
    def test_full_lifecycle(self):
        request = HttpRequest()
        response = HttpResponse()
        target = TimingMiddleware()

        target.process_request(request)
        assert (hasattr(request, TimingMiddleware.REQUEST_ATTR))

        target.process_response(request, response)
        self.assertIsNotNone(response[TimingMiddleware.RESPONSE_HEADER])
Ejemplo n.º 4
0
    def test_full_lifecycle(self):
        request = HttpRequest()
        response = HttpResponse()
        target = TimingMiddleware()

        target.process_request(request)
        assert(hasattr(request, TimingMiddleware.REQUEST_ATTR))

        target.process_response(request, response)
        self.assertIsNotNone(response[TimingMiddleware.RESPONSE_HEADER])