(self)
| 2920 | self.assertIsNot(thread_caches[0], thread_caches[1]) |
| 2921 | |
| 2922 | def test_cache_control_max_age(self): |
| 2923 | view = cache_page(2)(hello_world_view) |
| 2924 | request = self.factory.get("/view/") |
| 2925 | |
| 2926 | # First request. Freshly created response gets returned with no Age |
| 2927 | # header. |
| 2928 | with mock.patch.object( |
| 2929 | time, "time", return_value=1468749600 |
| 2930 | ): # Sun, 17 Jul 2016 10:00:00 GMT |
| 2931 | response = view(request, 1) |
| 2932 | response.close() |
| 2933 | self.assertIn("Expires", response) |
| 2934 | self.assertEqual(response["Expires"], "Sun, 17 Jul 2016 10:00:02 GMT") |
| 2935 | self.assertIn("Cache-Control", response) |
| 2936 | self.assertEqual(response["Cache-Control"], "max-age=2") |
| 2937 | self.assertNotIn("Age", response) |
| 2938 | |
| 2939 | # Second request one second later. Response from the cache gets |
| 2940 | # returned with an Age header set to 1 (second). |
| 2941 | with mock.patch.object( |
| 2942 | time, "time", return_value=1468749601 |
| 2943 | ): # Sun, 17 Jul 2016 10:00:01 GMT |
| 2944 | response = view(request, 1) |
| 2945 | response.close() |
| 2946 | self.assertIn("Expires", response) |
| 2947 | self.assertEqual(response["Expires"], "Sun, 17 Jul 2016 10:00:02 GMT") |
| 2948 | self.assertIn("Cache-Control", response) |
| 2949 | self.assertEqual(response["Cache-Control"], "max-age=2") |
| 2950 | self.assertIn("Age", response) |
| 2951 | self.assertEqual(response["Age"], "1") |
| 2952 | |
| 2953 | |
| 2954 | @override_settings( |
nothing calls this directly
no test coverage detected