32 lines
1.5 KiB
Python
32 lines
1.5 KiB
Python
"""集成验证:真实树注入后 _get_ground_truth_for_trace 收到非空 ground_truth;core 不依赖 app。
|
||
|
||
这两个测试守护"诊断 tree_data 断链"修复:
|
||
- 真实树 → load_tree_nodes → _get_ground_truth_for_trace,证明 bug 之前恒空的环已接通。
|
||
- core/evolution/diagnose.py 不 import app,守护依赖方向(core 不依赖 app)与算法保真。
|
||
"""
|
||
|
||
from pathlib import Path
|
||
|
||
from app.harness.tree_nodes import load_tree_nodes
|
||
from core.evolution.diagnose import _get_ground_truth_for_trace
|
||
|
||
# store 根锚定到仓库根,避免测试运行目录漂移导致相对路径失效(与 Task 1 测试一致)。
|
||
_STORE_DIR = Path(__file__).resolve().parents[2] / "store"
|
||
|
||
|
||
def test_ground_truth_nonempty_with_real_tree():
|
||
"""对真实 T2 样本 604-2(video 0RxMZBLeqRI)的 view_node 调用,ground_truth 非空。"""
|
||
tree_data = load_tree_nodes(_STORE_DIR, "0RxMZBLeqRI")
|
||
node_id = "0RxMZBLeqRI_L1_000" # 该视频真实存在的节点
|
||
ground_truth = _get_ground_truth_for_trace(tree_data, "view_node", {"node_id": node_id})
|
||
assert ground_truth and ground_truth != "{}" # 拿到该节点 card 的 JSON,非空
|
||
|
||
|
||
def test_core_diagnose_does_not_import_app():
|
||
"""算法保真 + 依赖方向:core/evolution/diagnose.py 不 import app。"""
|
||
src = (Path(__file__).resolve().parents[2] / "core" / "evolution" / "diagnose.py").read_text(
|
||
encoding="utf-8"
|
||
)
|
||
assert "import app." not in src
|
||
assert "from app." not in src
|