コード例 #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])
コード例 #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])
コード例 #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')
コード例 #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')
コード例 #5
0
 def test_no_dict(self):
     resp = HttpResponse()
     self.assertEqual(get_header_dict(resp, 'Cache-Control'), {})
コード例 #6
0
 def test_no_dict(self):
     resp = HttpResponse()
     self.assertEqual(get_header_dict(resp, 'Cache-Control'), {})