示例#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])