squid-main-space / tests /test_unified_query_v390.py
Zin299's picture
Deploy v4.3.0 persistent task center
e5e9d87
Raw
History Blame
1.49 kB
import pathlib
from services.unified_query import plan_unified_query
ROOT=pathlib.Path(__file__).resolve().parents[1]
def test_version_390():
assert (ROOT/"VERSION").read_text(encoding="utf-8").strip()=="4.3.0"
def test_joint_squid_environment_plan():
p=plan_unified_query("查询 2002 年 8 月西北太平洋柔鱼记录,并匹配 SST、SSH、CHL")
assert p["intent"]=="joint_ocean_fisheries"
assert "ocean" in p["domains"]
assert "squid" in p["domains"]
assert set(("sst","ssh","chl")).issubset(set(p["variables"]))
assert p["date_range"]["start"].startswith("2002-08")
def test_tuna_only_plan():
p=plan_unified_query("查询 WCPFC 金枪鱼 CPUE")
assert "tuna" in p["domains"]
assert "squid" not in p["domains"]
def test_ocean_only_eddy_plan():
p=plan_unified_query("研究太平洋中尺度涡旋和 SSH")
assert p["intent"]=="ocean_query"
assert p["domains"]==["ocean"]
def test_endpoint_registered_in_source():
route=(ROOT/"routes"/"unified_query.py").read_text(encoding="utf-8")
ui=(ROOT/"ui_server.py").read_text(encoding="utf-8")
assert '"/api/query/preview"' in route
assert "register_unified_query_routes(app, globals())" in ui
def test_frontend_has_unified_query():
js=(ROOT/"static"/"js"/"app.js").read_text(encoding="utf-8")
assert "统一智能查询" in js
assert "统一智能查询 · P1" not in js
assert "runUnifiedQueryPreview" in js
assert "/api/query/preview" in js