feat(api): standardize REST contracts and auth

This commit is contained in:
2026-07-30 20:38:51 +08:00
parent ae1a657554
commit ba947b616b
86 changed files with 54193 additions and 990 deletions
+15 -15
View File
@@ -118,7 +118,7 @@ def test_run_project_endpoint_returns_plain_text(monkeypatch):
monkeypatch.setattr(module, "run_project", lambda network: f"report::{network}")
client = TestClient(build_test_app(module.router, "/api/v1"))
response = client.get("/api/v1/runproject/", params={"network": "demo"})
response = client.post("/api/v1/project-runs", params={"network": "demo"})
assert response.status_code == 200
assert response.text == "report::demo"
@@ -143,7 +143,7 @@ def test_scheduling_analysis_maps_request_body(monkeypatch):
client = TestClient(build_test_app(module.router, "/api/v1"))
response = client.post(
"/api/v1/scheduling_analysis/",
"/api/v1/scheduling-analyses",
json={
"network": "demo",
"start_time": "2025-01-01T08:00:00+08:00",
@@ -177,7 +177,7 @@ def test_project_management_maps_named_arguments(monkeypatch):
client = TestClient(build_test_app(module.router, "/api/v1"))
response = client.post(
"/api/v1/project_management/",
"/api/v1/project-managements",
json={
"network": "demo",
"start_time": "2025-01-01T08:00:00+08:00",
@@ -260,7 +260,7 @@ def test_runsimulationmanuallybydate_endpoint_accepts_timezone_aware_start_time(
client = TestClient(build_test_app(module.router, "/api/v1"))
response = client.post(
"/api/v1/runsimulationmanuallybydate/",
"/api/v1/simulation-runs",
json={
"name": "demo",
"start_time": "2025-01-02T03:04:05+08:00",
@@ -280,7 +280,7 @@ def test_runsimulationmanuallybydate_endpoint_rejects_naive_start_time(monkeypat
client = TestClient(build_test_app(module.router, "/api/v1"))
response = client.post(
"/api/v1/runsimulationmanuallybydate/",
"/api/v1/simulation-runs",
json={
"name": "demo",
"start_time": "2025-01-02T03:04:05",
@@ -302,8 +302,8 @@ def test_valve_close_endpoint_passes_scheme_name(monkeypatch):
monkeypatch.setattr(module, "valve_close_analysis", fake_valve_close_analysis)
client = TestClient(build_test_app(module.router, "/api/v1"))
response = client.get(
"/api/v1/valve_close_analysis/",
response = client.post(
"/api/v1/valve-closure-analyses",
params={
"network": "demo",
"start_time": "2025-01-02T03:04:05+08:00",
@@ -334,8 +334,8 @@ def test_burst_endpoint_passes_current_username(monkeypatch):
monkeypatch.setattr(module, "burst_analysis", fake_burst_analysis)
client = _build_authenticated_client(module)
response = client.get(
"/api/v1/burst_analysis/",
response = client.post(
"/api/v1/burst-analyses",
params={
"network": "demo",
"modify_pattern_start_time": "2025-01-02T03:04:05+08:00",
@@ -362,8 +362,8 @@ def test_flushing_endpoint_passes_required_scheme_name(monkeypatch):
monkeypatch.setattr(module, "flushing_analysis", fake_flushing_analysis)
client = _build_authenticated_client(module)
response = client.get(
"/api/v1/flushing_analysis/",
response = client.post(
"/api/v1/flushing-analyses",
params={
"network": "demo",
"start_time": "2025-01-02T03:04:05+08:00",
@@ -401,8 +401,8 @@ def test_contaminant_endpoint_passes_current_username(monkeypatch):
monkeypatch.setattr(module, "contaminant_simulation", fake_contaminant_simulation)
client = _build_authenticated_client(module)
response = client.get(
"/api/v1/contaminant_simulation/",
response = client.post(
"/api/v1/contaminant-simulations",
params={
"network": "demo",
"start_time": "2025-01-02T03:04:05+08:00",
@@ -422,8 +422,8 @@ def test_contaminant_endpoint_requires_scheme_name(monkeypatch):
module = _load_simulation_module(monkeypatch)
client = _build_authenticated_client(module)
response = client.get(
"/api/v1/contaminant_simulation/",
response = client.post(
"/api/v1/contaminant-simulations",
params={
"network": "demo",
"start_time": "2025-01-02T03:04:05+08:00",