From 141ae590eb8a6fcef53fde2eb0ef16c0a66f6845 Mon Sep 17 00:00:00 2001 From: "Peter A. Jonsson" Date: Wed, 23 Sep 2026 13:18:01 +0200 Subject: [PATCH] test_job: improve range download mock Adjust the assertion for the range to use an inclusive test, and respond with 206 and the right headers for range requests. --- tests/rest/test_job.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/rest/test_job.py b/tests/rest/test_job.py index ed0784334..6e04df082 100644 --- a/tests/rest/test_job.py +++ b/tests/rest/test_job.py @@ -719,7 +719,6 @@ def setup(*, job_id="jj1", assets: dict, media_type: str = "image/tiff; applicat return setup - @pytest.fixture def job_with_1_asset(job_with_results_mocker) -> BatchJob: return job_with_results_mocker(job_id="jj1", assets={"1.tiff": "/dl/jjr1.tiff"}) @@ -734,8 +733,13 @@ def handle_content(request, context): assert search from_bytes = int(search.group(1)) to_bytes = int(search.group(2)) - assert from_bytes < to_bytes - return TIFF_CONTENT[from_bytes : to_bytes + 1] + assert from_bytes <= to_bytes + sliced_content = TIFF_CONTENT[from_bytes : to_bytes + 1] + context.status_code = 206 + context.headers["Accept-Ranges"] = "bytes" + context.headers["Content-Range"] = f"bytes {from_bytes}-{to_bytes}/{len(TIFF_CONTENT)}" + context.headers["Content-Length"] = str(len(sliced_content)) + return sliced_content requests_mock.get( API_URL + "/jobs/jj1/results",