fix(lab): keep full route result indexable
This commit is contained in:
@@ -4,6 +4,7 @@ import hashlib
|
||||
import io
|
||||
import json
|
||||
import shutil
|
||||
import struct
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
@@ -271,9 +272,17 @@ def test_vegetation_shadow_lab_seals_autonomous_visual_evidence(
|
||||
assert mask.headers["cache-control"].endswith("immutable")
|
||||
|
||||
full_archive_payloads = (b"\x89PNG\r\n\x1a\ncity", b"\x89PNG\r\n\x1a\nvegetation")
|
||||
full_timeline_payload = struct.pack("<2Q", 1_000_000_000, 1_100_000_000)
|
||||
full_identity = dict(manifest["identity"])
|
||||
full_route = {
|
||||
"frame_count": 2,
|
||||
"timeline": {
|
||||
"path": "video/frame-source-times-ns.bin",
|
||||
"sha256": hashlib.sha256(full_timeline_payload).hexdigest(),
|
||||
"byte_length": len(full_timeline_payload),
|
||||
"encoding": "uint64-le-nanoseconds",
|
||||
"frame_count": 2,
|
||||
},
|
||||
"layers": {
|
||||
layer: {"mask_archive": {"path": "video/full-route-masks.zip"}}
|
||||
for layer in ("city", "vegetation")
|
||||
@@ -296,6 +305,8 @@ def test_vegetation_shadow_lab_seals_autonomous_visual_evidence(
|
||||
with zipfile.ZipFile(full_archive, "x", compression=zipfile.ZIP_STORED) as frozen:
|
||||
for sequence, payload in enumerate(full_archive_payloads, start=1):
|
||||
frozen.writestr(f"masks/frame-{sequence:06d}.png", payload)
|
||||
full_timeline = full_root / "video" / "frame-source-times-ns.bin"
|
||||
full_timeline.write_bytes(full_timeline_payload)
|
||||
full_manifest = dict(manifest)
|
||||
full_manifest["result_id"] = full_result_id
|
||||
full_manifest["identity"] = full_identity
|
||||
@@ -310,6 +321,13 @@ def test_vegetation_shadow_lab_seals_autonomous_visual_evidence(
|
||||
"sha256": _sha256(full_archive),
|
||||
"media_type": "application/zip",
|
||||
},
|
||||
{
|
||||
"role": "full-route-frame-timeline",
|
||||
"path": "video/frame-source-times-ns.bin",
|
||||
"byte_length": full_timeline.stat().st_size,
|
||||
"sha256": _sha256(full_timeline),
|
||||
"media_type": "application/octet-stream",
|
||||
},
|
||||
]
|
||||
(full_root / "result.json").write_text(
|
||||
json.dumps(full_manifest, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
|
||||
@@ -330,6 +348,12 @@ def test_vegetation_shadow_lab_seals_autonomous_visual_evidence(
|
||||
assert client.get(
|
||||
f"/api/v1/laboratory/vegetation-shadow/{full_result_id}/route-masks/city/2"
|
||||
).status_code == 404
|
||||
timeline = client.get(
|
||||
f"/api/v1/laboratory/vegetation-shadow/{full_result_id}/route-timeline"
|
||||
)
|
||||
assert timeline.status_code == 200
|
||||
assert timeline.content == full_timeline_payload
|
||||
assert timeline.headers["cache-control"].endswith("immutable")
|
||||
|
||||
(result_root / asset_path).write_bytes(b"tampered")
|
||||
assert (
|
||||
|
||||
Reference in New Issue
Block a user