CareerNexus 职联:岗位能力图谱构建与动态演化分析平台(挑战杯 XH-202621)
- 全链路:多源JD接入/清洗交叉验证/结构化抽取(星火+离线双通道)/时序知识图谱/新岗位发现/演化分析/人岗匹配/学习路径 - WebUI 五视图:驾驶舱/图谱工作台/岗位演化/匹配(单人+批量)/学习路径 - 设置中心(config.json)/Token鉴权/SQLite状态库/语义向量通道(BGE-M3本地或联网API) - 71 个 pytest 用例;数据目录仅保留结构(.gitkeep),数据由 scripts/generate_dataset.py 复现
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
"""pytest 共享夹具:确保数据与图谱存在(数据已随工程提交,缺失时现场生成)。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
PY = sys.executable
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def ensure_data() -> None:
|
||||
if not (ROOT / "data" / "jd_raw").exists():
|
||||
subprocess.run([PY, str(ROOT / "scripts" / "generate_dataset.py")], check=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def graph_path() -> Path:
|
||||
path = ROOT / "data" / "graph.json"
|
||||
if not path.exists():
|
||||
subprocess.run([PY, str(ROOT / "scripts" / "run_demo.py")], check=True)
|
||||
return path
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def isolated_state_db(tmp_path_factory):
|
||||
"""整个测试会话把 SQLite 状态库重定向到临时目录,避免污染真实 data/careernexus.db。
|
||||
|
||||
audit_path/pending_path 仅作为旧文件迁移种子,指向不存在的临时路径即跳过迁移。
|
||||
"""
|
||||
from app.api import routes
|
||||
tmp = tmp_path_factory.mktemp("state_db")
|
||||
keys = ("state_db_path", "audit_path", "pending_path")
|
||||
originals = {k: routes._cfg.get(k) for k in keys}
|
||||
routes._cfg["state_db_path"] = str(tmp / "state.db")
|
||||
routes._cfg["audit_path"] = str(tmp / "audit.jsonl")
|
||||
routes._cfg["pending_path"] = str(tmp / "pending.json")
|
||||
yield
|
||||
for k, v in originals.items():
|
||||
if v is None:
|
||||
routes._cfg.pop(k, None)
|
||||
else:
|
||||
routes._cfg[k] = v
|
||||
Reference in New Issue
Block a user