Spaces:
Sleeping
Sleeping
Download backend/tests/test_demo_runtime.py from dauphinking/pump: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/dauphinking/pump/resolve/main/backend/tests/test_demo_runtime.py
- Command line
-
hf download hf://spaces/dauphinking/pump/backend/tests/test_demo_runtime.py
-
curl -L -o test_demo_runtime.py https://huggingface.co/spaces/dauphinking/pump/resolve/main/backend/tests/test_demo_runtime.py
1.12 kB
| from app.demo_runtime import build_snapshot | |
| def test_build_snapshot_preserves_missing_pressure_and_unknown_frequency(): | |
| pumps = [ | |
| {"id": 1, "status": 1, "freq": 35.0, "power": 20.0}, | |
| {"id": 2, "status": 1, "freq": None, "power": 30.0}, | |
| {"id": 3, "status": 0, "freq": 0.0, "power": 0.0}, | |
| ] | |
| snapshot = build_snapshot( | |
| { | |
| "totalFlow": 1000.0, | |
| "totalPower": 50.0, | |
| "level": 6.2, | |
| "pressure": None, | |
| "replayTimestamp": "2026-01-01T00:00:00+08:00", | |
| "replayIndex": 0, | |
| "replayCount": 10, | |
| }, | |
| pumps, | |
| ) | |
| assert snapshot["source"] == "historical_opc_replay" | |
| assert snapshot["pressure"] is None | |
| assert snapshot["pressureQuality"] == "missing" | |
| assert snapshot["pumps"][0]["head"] is None | |
| assert snapshot["pumps"][0]["headSource"] == "missing_pressure" | |
| assert snapshot["pumps"][1]["freq"] is None | |
| assert snapshot["pumps"][0]["flow"] == 400.0 | |
| assert snapshot["pumps"][1]["flow"] == 600.0 | |
| assert snapshot["pumps"][1]["flowSource"] == "estimated_power_share" | |