示例#1
0
    def test_vary(self):
        request = test.RequestFactory().get('/')
        response = http.HttpResponse()
        r = middleware.XMobileMiddleware().process_response(request, response)
        assert r is response
        self.assertEqual(response['Vary'], 'X-Mobile')

        response['Vary'] = 'User-Agent'
        middleware.XMobileMiddleware().process_response(request, response)
        self.assertEqual(response['Vary'], 'User-Agent, X-Mobile')
示例#2
0
    def test_vary_xmobile(self):
        request = test.RequestFactory().get('/')
        request.NO_MOBILE = True
        response = http.HttpResponse()

        r = middleware.XMobileMiddleware().process_response(request, response)
        self.assertEqual(response.get('Vary', None), None)
示例#3
0
 def check(self, xmobile, mobile):
     request = test.RequestFactory().get('/')
     if xmobile:
         request.META['HTTP_X_MOBILE'] = xmobile
     middleware.XMobileMiddleware().process_request(request)
     self.assertEqual(request.MOBILE, mobile)