55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
import tempfile
|
|
from pathlib import Path
|
|
|
|
|
|
def _make_job_dir(base: Path, job_id: int, has_ply: bool = True, has_poses: bool = True) -> Path:
|
|
job_dir = base / f"job_{job_id}"
|
|
job_dir.mkdir(parents=True)
|
|
if has_ply:
|
|
(job_dir / "reconstruction.ply").write_bytes(b"\x00" * 100)
|
|
if has_poses:
|
|
(job_dir / "lingbot_poses.npz").touch()
|
|
return job_dir
|
|
|
|
|
|
def test_complete_job_is_ok():
|
|
from scripts.check_jobs import check_job
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
_make_job_dir(Path(tmp), 1)
|
|
result = check_job(1, tmp)
|
|
assert result["status"] == "ok"
|
|
assert result["job_id"] == 1
|
|
assert result["missing"] == []
|
|
|
|
|
|
def test_missing_ply_flagged():
|
|
from scripts.check_jobs import check_job
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
_make_job_dir(Path(tmp), 2, has_ply=False)
|
|
result = check_job(2, tmp)
|
|
assert result["status"] == "incomplete"
|
|
assert "reconstruction.ply" in result["missing"]
|
|
|
|
|
|
def test_missing_poses_flagged():
|
|
from scripts.check_jobs import check_job
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
_make_job_dir(Path(tmp), 3, has_poses=False)
|
|
result = check_job(3, tmp)
|
|
assert result["status"] == "incomplete"
|
|
assert "lingbot_poses.npz" in result["missing"]
|
|
|
|
|
|
def test_missing_job_dir_returns_missing():
|
|
from scripts.check_jobs import check_job
|
|
result = check_job(999, "/nonexistent/base")
|
|
assert result["status"] == "missing"
|
|
|
|
|
|
def test_decimated_flag_false_without_file():
|
|
from scripts.check_jobs import check_job
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
_make_job_dir(Path(tmp), 4)
|
|
result = check_job(4, tmp)
|
|
assert result["details"]["decimated"] is False
|