Exemplo n.º 1
0
 def test_get_dict(self):
     resp = HttpResponse()
     resp['Cache-Control'] = 'x=1, y'
     expected = dict(x='1', y=True)
     actual = get_header_dict(resp, 'Cache-Control')
     for k in expected:
         self.assertEqual(expected[k], actual[k])
Exemplo n.º 2
0
 def test_get_dict(self):
     resp = HttpResponse()
     resp['Cache-Control'] = 'x=1, y'
     expected = dict(x='1', y=True)
     actual = get_header_dict(resp, 'Cache-Control')
     for k in expected:
         self.assertEqual(expected[k], actual[k])
Exemplo n.º 3
0
 def test_patch_headers(self, settings):
     resp = HttpResponse()
     resp['Vary'] = 'cookie, accept-encoding'
     self.set_settings(settings)
     cm = CachingMixin()
     cm.patch_headers(resp)
     self.assertEqual(resp['Vary'], 'accept-encoding')
     self.assertEqual(resp['Edge-Control'], 'cache-maxage=1d')
     ccdict = get_header_dict(resp, 'Cache-Control')
     self.assertEqual(ccdict['pre-check'], '60')
     self.assertEqual(ccdict['post-check'], '6')
     self.assertEqual(ccdict['max-age'], '60')
Exemplo n.º 4
0
 def test_patch_headers(self, settings):
     resp = HttpResponse()
     resp['Vary'] = 'cookie, accept-encoding'
     self.set_settings(settings)
     cm = CachingMixin()
     cm.patch_headers(resp)
     self.assertEqual(resp['Vary'], 'accept-encoding')
     self.assertEqual(resp['Edge-Control'], 'cache-maxage=1d')
     ccdict = get_header_dict(resp, 'Cache-Control')
     self.assertEqual(ccdict['pre-check'], '60')
     self.assertEqual(ccdict['post-check'], '6')
     self.assertEqual(ccdict['max-age'], '60')
Exemplo n.º 5
0
 def test_no_dict(self):
     resp = HttpResponse()
     self.assertEqual(get_header_dict(resp, 'Cache-Control'), {})
Exemplo n.º 6
0
 def test_no_dict(self):
     resp = HttpResponse()
     self.assertEqual(get_header_dict(resp, 'Cache-Control'), {})