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])
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')
def test_no_dict(self): resp = HttpResponse() self.assertEqual(get_header_dict(resp, 'Cache-Control'), {})