refactor(api): unify scheme query endpoints

This commit is contained in:
2026-07-30 11:01:45 +08:00
parent 03bb2d75c2
commit 31e2728db1
14 changed files with 457 additions and 261 deletions
-33
View File
@@ -1,7 +1,5 @@
from fastapi import FastAPI
from fastapi.testclient import TestClient
from types import SimpleNamespace
from app.api.v1.endpoints import leakage as leakage_endpoint
@@ -35,34 +33,3 @@ def test_identify_leakage_success(monkeypatch):
)
assert response.status_code == 200
assert response.json()["area_count"] == 0
def test_query_leakage_schemes_success(monkeypatch):
monkeypatch.setattr(
leakage_endpoint,
"list_leakage_identify_schemes",
lambda network, query_date=None: [
{"scheme_name": "dma_001", "scheme_type": "dma_leak_identification"}
],
)
client = _build_client()
response = client.get("/api/v1/leakage/schemes/", params={"network": "demo"})
assert response.status_code == 200
assert response.json()[0]["scheme_name"] == "dma_001"
def test_query_leakage_scheme_detail_success(monkeypatch):
monkeypatch.setattr(
leakage_endpoint,
"get_leakage_identify_scheme_detail",
lambda network, scheme_name: {
"scheme_name": scheme_name,
"rows": [{"Area": "1", "LeakageFlow_m3_per_s": 0.1}],
},
)
client = _build_client()
response = client.get(
"/api/v1/leakage/schemes/dma_001", params={"network": "demo"}
)
assert response.status_code == 200
assert response.json()["scheme_name"] == "dma_001"