Surface YOLO preflight in Detection Lab
This commit is contained in:
@@ -5,7 +5,10 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.core.config import Settings
|
||||
from app.main import app
|
||||
from app.services.yolo_preflight_service import YoloPreflightService
|
||||
|
||||
|
||||
@@ -213,3 +216,21 @@ def test_yolo_preflight_script_rejects_assumed_dependencies_for_model_load(tmp_p
|
||||
|
||||
assert result.returncode != 0
|
||||
assert "--check-model-load cannot be combined with --assume-dependencies" in result.stderr
|
||||
|
||||
|
||||
def test_yolo_preflight_api_returns_canonical_envelope(monkeypatch, tmp_path: Path) -> None:
|
||||
monkeypatch.setenv("YOLO_ENABLED", "false")
|
||||
monkeypatch.setenv("YOLO_MODEL_PATH", str(tmp_path / "missing.pt"))
|
||||
monkeypatch.setenv("YOLO_CONFIG_DIR", str(tmp_path / "ultralytics"))
|
||||
|
||||
response = TestClient(app).get("/api/v1/detection/yolo/preflight")
|
||||
|
||||
assert response.status_code == 200
|
||||
payload = response.json()
|
||||
assert set(payload) == {"data"}
|
||||
assert payload["data"]["status"] == "not_configured"
|
||||
assert payload["data"]["checks"]["enabled"] is False
|
||||
assert payload["data"]["runtime"]["model_directory"] == str(tmp_path)
|
||||
assert payload["data"]["runtime"]["yolo_config_dir"] == str(tmp_path / "ultralytics")
|
||||
assert payload["data"]["will_download_models"] is False
|
||||
assert payload["data"]["will_run_inference"] is False
|
||||
|
||||
Reference in New Issue
Block a user