Files
2026-05-28 20:23:01 -07:00

26 lines
781 B
Python

from pathlib import Path
from django.test import RequestFactory
from archivebox.misc.serve_static import serve_static_with_byterange_support
def test_archive_file_response_uses_async_iterator_under_asgi(tmp_path: Path):
output = tmp_path / "screenshot" / "output.png"
output.parent.mkdir()
output.write_bytes(b"0123456789")
request = RequestFactory().get("/screenshot/output.png", HTTP_RANGE="bytes=2-5")
request.scope = {"type": "http"}
response = serve_static_with_byterange_support(
request,
"screenshot/output.png",
document_root=tmp_path,
)
assert response.is_async is True
assert response.status_code == 206
assert response["Content-Range"] == "bytes 2-5/10"
assert response["Content-Length"] == "4"