mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-06-24 04:20:41 -04:00
26 lines
781 B
Python
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"
|