()
| 630 | |
| 631 | |
| 632 | def test_range_request_with_file(): |
| 633 | env = create_environ() |
| 634 | resources = os.path.join(os.path.dirname(__file__), "res") |
| 635 | fname = os.path.join(resources, "test.txt") |
| 636 | with open(fname, "rb") as f: |
| 637 | fcontent = f.read() |
| 638 | with open(fname, "rb") as f: |
| 639 | response = wrappers.Response(wrap_file(env, f)) |
| 640 | env["HTTP_RANGE"] = "bytes=0-0" |
| 641 | response.make_conditional( |
| 642 | env, accept_ranges=True, complete_length=len(fcontent) |
| 643 | ) |
| 644 | assert response.status_code == 206 |
| 645 | assert response.headers["Accept-Ranges"] == "bytes" |
| 646 | assert response.headers["Content-Range"] == f"bytes 0-0/{len(fcontent)}" |
| 647 | assert response.headers["Content-Length"] == "1" |
| 648 | assert response.data == fcontent[:1] |
| 649 | |
| 650 | |
| 651 | def test_range_request_with_complete_file(): |
nothing calls this directly
no test coverage detected