| 21 | |
| 22 | |
| 23 | class TestChunkedResponses: |
| 24 | def test_cache_chunked_response(self, url, sess): |
| 25 | """ |
| 26 | Verify that an otherwise cacheable response is cached when the |
| 27 | response is chunked. |
| 28 | """ |
| 29 | url = url + "stream" |
| 30 | r = sess.get(url) |
| 31 | from pprint import pprint |
| 32 | |
| 33 | pprint(dict(r.headers)) |
| 34 | pprint(dict(r.request.headers)) |
| 35 | print(r.content) |
| 36 | assert r.headers.get("transfer-encoding") == "chunked" |
| 37 | |
| 38 | r = sess.get(url, headers={"Cache-Control": "max-age=3600"}) |
| 39 | assert r.from_cache is True |
| 40 | |
| 41 | def test_stream_is_cached(self, url, sess): |
| 42 | resp_1 = sess.get(url + "stream") |
| 43 | content_1 = resp_1.content |
| 44 | |
| 45 | resp_2 = sess.get(url + "stream") |
| 46 | content_2 = resp_1.content |
| 47 | |
| 48 | assert not resp_1.from_cache |
| 49 | assert resp_2.from_cache |
| 50 | assert content_1 == content_2 |
| 51 | |
| 52 | def test_stream_is_not_cached_when_content_is_not_read(self, url, sess): |
| 53 | sess.get(url + "stream", stream=True) |
| 54 | resp = sess.get(url + "stream", stream=True) |
| 55 | |
| 56 | assert not resp.from_cache |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…