重构漏损识别请求,添加用户验证和输入准备
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user