Add live acceptance smoke validation

This commit is contained in:
2026-06-30 13:02:13 +08:00
parent 7a43303f15
commit bf9b5c33e0
7 changed files with 299 additions and 9 deletions

View File

@@ -0,0 +1,34 @@
from pathlib import Path
from fastapi.testclient import TestClient
from app.main import app
def test_project_var_artifact_path_is_served(tmp_path, monkeypatch):
from app import main
project_root = tmp_path / "project"
source_root = tmp_path / "source"
artifact = project_root / "var" / "uploads" / "datasets" / "case" / "labels" / "label.txt"
artifact.parent.mkdir(parents=True)
artifact.write_text("ok", encoding="utf-8")
source_root.mkdir()
original = main.settings
patched = type(original)(
project_root=project_root,
source_root=source_root,
db_path=original.db_path,
log_dir=original.log_dir,
weights_root=original.weights_root,
task_conda_env=original.task_conda_env,
backend_conda_env=original.backend_conda_env,
weight_mode=original.weight_mode,
enable_shell_tasks=original.enable_shell_tasks,
)
monkeypatch.setattr(main, "settings", patched)
response = TestClient(app).get("/api/artifacts/var/uploads/datasets/case/labels/label.txt")
assert response.status_code == 200
assert response.text == "ok"