Spaces:
Sleeping
Sleeping
Download backend/tests/test_suggestion_api.py from dauphinking/pump: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/dauphinking/pump/resolve/main/backend/tests/test_suggestion_api.py
- Command line
-
hf download hf://spaces/dauphinking/pump/backend/tests/test_suggestion_api.py
-
curl -L -o test_suggestion_api.py https://huggingface.co/spaces/dauphinking/pump/resolve/main/backend/tests/test_suggestion_api.py
1.23 kB
| from fastapi.testclient import TestClient | |
| from app.main import app | |
| client = TestClient(app) | |
| def test_factory_curves_and_hydraulic_codes_are_exposed(): | |
| cfg = client.get("/api/config").json() | |
| pumps = {p["id"]: p for p in cfg["pumps"]} | |
| assert pumps[1]["hydraulic_code"] == "NP 3202.180 LT 610" | |
| assert pumps[2]["hydraulic_code"] == "F10K-SS1 + FN050X4" | |
| assert all(pumps[i]["curve_source"].startswith("manufacturer") for i in range(1, 6)) | |
| curve = client.get("/api/pump/2/curve", params={"freq": 50, "n": 10}).json() | |
| assert curve["success"] | |
| assert abs(curve["bep_flow"] - 774.72) < 20 | |
| assert curve["meta"]["curve_revision"] == "C-2175 Rev.2" | |
| def test_unknown_frequency_is_omitted_and_negative_saving_is_blocked(): | |
| response = client.post("/api/optimization/suggestion", json={ | |
| "Q_target": 800.0, | |
| "current_active": [1, 2], | |
| "current_freqs": {"1": 48.0}, | |
| "current_total_power": 10.0, | |
| "level": 5.5, | |
| }) | |
| result = response.json() | |
| assert result["success"] | |
| assert result["baseline"]["kind"] == "current_measured" | |
| assert result["sec_saving_pct"] <= 0 | |
| assert result["status"] == "no_improvement" | |
| assert result["executable"] is False | |