Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
| import pathlib, ast | |
| ROOT=pathlib.Path(__file__).resolve().parents[1] | |
| def test_version_381(): | |
| assert (ROOT/"VERSION").read_text(encoding="utf-8").strip()=="4.3.0" | |
| def test_recent_conversation_switches_to_chat(): | |
| js=(ROOT/"static"/"js"/"app.js").read_text(encoding="utf-8") | |
| start=js.index("function openSession(id)") | |
| block=js[start:start+300] | |
| assert 'if(CURRENT_VIEW!=="chat")setView("chat")' in block | |
| def _load_export_detector(): | |
| text=(ROOT/"ui_server.py").read_text(encoding="utf-8") | |
| tree=ast.parse(text) | |
| node=next(n for n in tree.body if isinstance(n,ast.FunctionDef) and n.name=="_is_ocean_export_request") | |
| mod=ast.Module(body=[node],type_ignores=[]) | |
| ns={"re":__import__("re"), "_needs_ocean_mcp":lambda q: True} | |
| exec(compile(mod,"<test>","exec"),ns) | |
| return ns["_is_ocean_export_request"] | |
| def test_export_format_question_is_not_execution(): | |
| fn=_load_export_detector() | |
| assert fn("查询现在支持哪些 Ocean 数据源和变量,并说明时间范围、空间分辨率和可导出格式") is False | |
| assert fn("现在支持哪些导出格式?") is False | |
| def test_explicit_export_still_executes(): | |
| fn=_load_export_detector() | |
| assert fn("请帮我导出这份 Ocean 数据为 CSV") is True | |
| assert fn("下载上述数据文件") is True | |