Refine runtime data flow and UI layering
This commit is contained in:
@@ -17,6 +17,7 @@ def test_runtime_service_routes_are_exposed():
|
||||
assert "/api/status" in paths
|
||||
assert "/api/runtime/start" in paths
|
||||
assert "/api/runtime/stop" in paths
|
||||
assert "/api/runtime/cleanup" in paths
|
||||
assert "/api/runtime/current" in paths
|
||||
assert "/api/runtime/gateway/port" in paths
|
||||
|
||||
@@ -192,3 +193,45 @@ def test_runtime_service_update_runtime_config_persists_bootstrap(monkeypatch, t
|
||||
assert payload["bootstrap"]["schedule_mode"] == "intraday"
|
||||
assert payload["resolved"]["interval_minutes"] == 15
|
||||
assert "interval_minutes: 15" in (run_dir / "BOOTSTRAP.md").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_prune_old_timestamped_runs_keeps_named_runs(monkeypatch, tmp_path):
|
||||
runs_dir = tmp_path / "runs"
|
||||
runs_dir.mkdir()
|
||||
|
||||
keep_dirs = ["20260324_110000", "20260324_120000"]
|
||||
prune_dir = "20260324_100000"
|
||||
named_dir = "smoke_fullstack"
|
||||
|
||||
for name in [*keep_dirs, prune_dir, named_dir]:
|
||||
(runs_dir / name).mkdir(parents=True)
|
||||
|
||||
monkeypatch.setattr(runtime_module, "PROJECT_ROOT", tmp_path)
|
||||
|
||||
pruned = runtime_module._prune_old_timestamped_runs(keep=1, exclude_run_ids={"20260324_120000"})
|
||||
|
||||
assert prune_dir in pruned
|
||||
assert (runs_dir / named_dir).exists()
|
||||
assert (runs_dir / "20260324_120000").exists()
|
||||
assert (runs_dir / "20260324_110000").exists()
|
||||
|
||||
|
||||
def test_runtime_cleanup_endpoint_prunes_old_runs(monkeypatch, tmp_path):
|
||||
runs_dir = tmp_path / "runs"
|
||||
runs_dir.mkdir()
|
||||
|
||||
for name in ["20260324_090000", "20260324_100000", "20260324_110000", "smoke_fullstack"]:
|
||||
(runs_dir / name).mkdir(parents=True)
|
||||
|
||||
monkeypatch.setattr(runtime_module, "PROJECT_ROOT", tmp_path)
|
||||
monkeypatch.setattr(runtime_module, "_is_gateway_running", lambda: False)
|
||||
|
||||
with TestClient(create_app()) as client:
|
||||
response = client.post("/api/runtime/cleanup?keep=1")
|
||||
|
||||
assert response.status_code == 200
|
||||
payload = response.json()
|
||||
assert payload["status"] == "ok"
|
||||
assert sorted(payload["pruned_run_ids"]) == ["20260324_090000", "20260324_100000"]
|
||||
assert (runs_dir / "20260324_110000").exists()
|
||||
assert (runs_dir / "smoke_fullstack").exists()
|
||||
|
||||
Reference in New Issue
Block a user