3d_model / tests /test_bundle_annotations.py
Azan
Clean deployment build (Squashed)
7a87926
import json
from pathlib import Path
from ylff.utils.capture_bundle import CaptureBundle
def test_load_detailed_annotation_returns_model(tmp_path: Path):
(tmp_path / "devices" / "iphone_a").mkdir(parents=True)
(tmp_path / "annotations").mkdir(parents=True)
(tmp_path / "devices" / "iphone_a" / "video.mov").write_bytes(b"x")
(tmp_path / "devices" / "iphone_a" / "intrinsics.json").write_text(
json.dumps({"fx": 100.0, "fy": 100.0, "cx": 4.0, "cy": 4.0})
)
(tmp_path / "devices" / "iphone_a" / "timestamps.json").write_text(json.dumps({"t": []}))
ann = {
"schema_version": "1.0",
"capture_id": "cap_001",
"segments": [],
"scene_metadata": {"primary_type": "RESIDENTIAL_KITCHEN"},
"quality_assessment": {"rating": "good"},
}
(tmp_path / "annotations" / "detailed_annotation.json").write_text(json.dumps(ann))
manifest = {
"schema_version": "1.0",
"capture_id": "cap_001",
"devices": [
{
"device_id": "iphone_a",
"device_type": "iphone",
"video_path": "devices/iphone_a/video.mov",
"intrinsics_path": "devices/iphone_a/intrinsics.json",
"timestamps_path": "devices/iphone_a/timestamps.json",
}
],
"annotations": {"detailed_annotation_path": "annotations/detailed_annotation.json"},
}
(tmp_path / "manifest.json").write_text(json.dumps(manifest))
bundle = CaptureBundle.load(tmp_path)
loaded = bundle.load_detailed_annotation()
assert loaded is not None
assert loaded.capture_id == "cap_001"