(self)
| 2824 | |
| 2825 | @retry() |
| 2826 | def test_cache_page_timeout(self): |
| 2827 | # Page timeout takes precedence over the "max-age" section of the |
| 2828 | # "Cache-Control". |
| 2829 | tests = [ |
| 2830 | (1, 3), # max_age < page_timeout. |
| 2831 | (3, 1), # max_age > page_timeout. |
| 2832 | ] |
| 2833 | for max_age, page_timeout in tests: |
| 2834 | with self.subTest(max_age=max_age, page_timeout=page_timeout): |
| 2835 | view = cache_page(timeout=page_timeout)( |
| 2836 | cache_control(max_age=max_age)(hello_world_view) |
| 2837 | ) |
| 2838 | request = self.factory.get("/view/") |
| 2839 | response = view(request, "1") |
| 2840 | self.assertEqual(response.content, b"Hello World 1") |
| 2841 | time.sleep(1) |
| 2842 | response = view(request, "2") |
| 2843 | self.assertEqual( |
| 2844 | response.content, |
| 2845 | b"Hello World 1" if page_timeout > max_age else b"Hello World 2", |
| 2846 | ) |
| 2847 | cache.clear() |
| 2848 | |
| 2849 | def test_cache_control_not_cached(self): |
| 2850 | """ |
nothing calls this directly
no test coverage detected