diff --git a/tests/conftest.py b/tests/conftest.py index 27685330..ffa61e4a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -91,7 +91,7 @@ def permalink(self, env, start_response): return [b"The permanent resource"] def multiple_choices(self, env, start_response): - headers = [("Link", "/permalink")] + headers = [("Link", "/permalink"), ("Cache-Control", "max-age=5000")] start_response("300 Multiple Choices", headers) return [b"See: /permalink"] diff --git a/tests/test_redirects.py b/tests/test_redirects.py index 9d6932b2..40f3e3b4 100644 --- a/tests/test_redirects.py +++ b/tests/test_redirects.py @@ -37,19 +37,28 @@ def setup_method(self): self.sess = CacheControl(requests.Session()) def test_multiple_choices_is_cacheable(self, url): - self.sess.get(url + "multiple_choices_redirect", allow_redirects=False) + first = self.sess.get(url + "multiple_choices", allow_redirects=False) + assert first.status_code == 300 + assert not first.from_cache - resp = self.sess.get(url + "multiple_choices_redirect", allow_redirects=False) + resp = self.sess.get(url + "multiple_choices", allow_redirects=False) + assert resp.status_code == 300 assert resp.from_cache + assert resp.content == first.content def test_bust_cache_on_redirect(self, url): - self.sess.get(url + "multiple_choices_redirect", allow_redirects=False) + self.sess.get(url + "multiple_choices", allow_redirects=False) + + cached = self.sess.get(url + "multiple_choices", allow_redirects=False) + assert cached.status_code == 300 + assert cached.from_cache resp = self.sess.get( - url + "multiple_choices_redirect", + url + "multiple_choices", headers={"cache-control": "no-cache"}, allow_redirects=False, ) + assert resp.status_code == 300 assert not resp.from_cache