Пример #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])
Пример #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])
Пример #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])
Пример #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])