重构漏损识别请求,添加用户验证和输入准备

This commit is contained in:
2026-03-04 17:23:01 +08:00
parent 340808e85e
commit b8aee14c00
4 changed files with 49 additions and 14 deletions
+5
View File
@@ -1,5 +1,6 @@
from fastapi import FastAPI
from fastapi.testclient import TestClient
from types import SimpleNamespace
from app.api.v1.endpoints import leakage as leakage_endpoint
@@ -7,12 +8,16 @@ from app.api.v1.endpoints import leakage as leakage_endpoint
def _build_client() -> TestClient:
app = FastAPI()
app.include_router(leakage_endpoint.router, prefix="/api/v1/leakage")
app.dependency_overrides[leakage_endpoint.get_current_user] = lambda: SimpleNamespace(
username="tester"
)
return TestClient(app)
def test_identify_leakage_success(monkeypatch):
def fake_run_leakage_identification(**kwargs):
assert kwargs["network"] == "demo"
assert kwargs["username"] == "tester"
return {"rows": [], "area_count": 0}
monkeypatch.setattr(