Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
| import pathlib | |
| from services.ocean_batch import parse_ocean_batch_request | |
| ROOT=pathlib.Path(__file__).resolve().parents[1] | |
| def test_version_410(): | |
| assert (ROOT/"VERSION").read_text(encoding="utf-8").strip()=="4.3.0" | |
| def test_month_three_variable_batch_plan(): | |
| p=parse_ocean_batch_request("查询并导出 2002 年 8 月西北太平洋 120°E–140°E、20°N–40°N 的 SST、SSH、CHL 数据,并打包下载") | |
| assert p is not None | |
| assert p["days"]==31 | |
| assert p["subtask_count"]==93 | |
| assert p["start_date"]=="2002-08-01" | |
| assert p["end_date"]=="2002-08-31" | |
| assert set(p["variables"])=={"sst","ssh","chl"} | |
| def test_single_day_does_not_batch(): | |
| assert parse_ocean_batch_request("导出 2002-08-01 120°E-140°E 20°N-40°N SST") is None | |
| def test_routes_and_chat_fast_path(): | |
| route=(ROOT/"routes"/"ocean_batch.py").read_text(encoding="utf-8") | |
| rt=(ROOT/"services"/"chat_runtime.py").read_text(encoding="utf-8") | |
| assert "/api/ocean/batch/{job_id}/retry" in route | |
| assert 'yield out("batch_job",job)' in rt | |
| assert "后台并行执行中" in rt | |
| def test_frontend_batch_card(): | |
| js=(ROOT/"static"/"js"/"app.js").read_text(encoding="utf-8") | |
| assert "function attachOceanBatchCard" in js | |
| assert 'E.e==="batch_job"' in js | |
| assert "仅重试失败项" in js | |
| def test_service_parallelism_and_persistence(): | |
| svc=(ROOT/"services"/"ocean_batch.py").read_text(encoding="utf-8") | |
| assert "asyncio.Semaphore" in svc | |
| assert "asyncio.gather" in svc | |
| assert 'job["status"]="paused"' in svc | |