fix: load real tree_data for offline diagnosis (video_split_cli)

This commit is contained in:
2026-07-15 22:38:23 -04:00
parent f1b6865861
commit 83056688cf
3 changed files with 71 additions and 11 deletions
+7 -1
View File
@@ -268,6 +268,8 @@ def test_build_diagnosis_deps_model_mismatch_fails_loud(monkeypatch, tmp_path):
with pytest.raises(SystemExit) as exc:
cli.build_diagnosis_deps(
harness_db=tmp_path / "h.db",
store_dir=tmp_path,
video_ids=[],
concurrency=2,
expected_model="deepseek-v4-pro", # 与 env 不一致
)
@@ -288,7 +290,11 @@ def test_build_diagnosis_deps_missing_credentials_fails_loud(monkeypatch, tmp_pa
monkeypatch.setattr(cli, "_DiagLLMSettings", lambda: _EmptySettings())
with pytest.raises(SystemExit):
cli.build_diagnosis_deps(
harness_db=tmp_path / "h.db", concurrency=2, expected_model="deepseek-v4-pro"
harness_db=tmp_path / "h.db",
store_dir=tmp_path,
video_ids=[],
concurrency=2,
expected_model="deepseek-v4-pro",
)
@@ -0,0 +1,33 @@
"""离线诊断注入:build_diagnosis_deps 按 video_ids 填充非空 tree_data。"""
from pathlib import Path
from unittest.mock import patch
from app.harness.video_split_cli import build_diagnosis_deps
def test_build_diagnosis_deps_loads_tree_for_videos():
with (
patch("app.harness.video_split_cli._DiagLLMSettings") as settings_cls,
patch("adapters.llm.GovernedLLMClient"),
patch("adapters.telemetry.SQLiteTelemetryRecorder"),
patch("app.harness.video_split_cli._build_redis_cache", return_value=None),
):
s = settings_cls.return_value
s.search_llm_model = "deepseek-v4-pro"
s.search_llm_base_url = "http://x"
s.search_llm_api_key = "k"
s.llm_circuit_breaker_threshold = 32
s.llm_circuit_breaker_cooldown = 60
s.llm_timeout = s.llm_ttft_timeout = s.llm_inter_token_timeout = 60
s.llm_max_retries = 1
s.llm_retry_base_delay = s.llm_retry_max_delay = 1
deps = build_diagnosis_deps(
harness_db=Path("workspaces/default/harness.db"),
store_dir=Path("store"),
video_ids=["0RxMZBLeqRI"],
concurrency=1,
expected_model="deepseek-v4-pro",
)
assert "0RxMZBLeqRI" in deps.tree_data
assert deps.tree_data["0RxMZBLeqRI"]["nodes"]