cambios profundos
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Tests de los routers /policies y /violations."""
|
||||
"""Tests de los routers /api/policies y /api/violations."""
|
||||
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
@@ -37,24 +37,24 @@ def client() -> TestClient:
|
||||
|
||||
|
||||
def test_list_policies_incluye_default(client: TestClient) -> None:
|
||||
r = client.get("/policies")
|
||||
r = client.get("/api/policies")
|
||||
assert r.status_code == 200
|
||||
assert any(p["name"] == "default" for p in r.json())
|
||||
|
||||
|
||||
def test_list_policy_versions(client: TestClient) -> None:
|
||||
r = client.get("/policies/default/versions")
|
||||
r = client.get("/api/policies/default/versions")
|
||||
assert r.status_code == 200
|
||||
assert r.json()[0]["id"] == "v1"
|
||||
|
||||
|
||||
def test_list_policy_versions_inexistente_404(client: TestClient) -> None:
|
||||
r = client.get("/policies/inexistente/versions")
|
||||
r = client.get("/api/policies/inexistente/versions")
|
||||
assert r.status_code == 404
|
||||
|
||||
|
||||
def test_violations_vacio_si_no_hay(client: TestClient) -> None:
|
||||
r = client.get("/violations")
|
||||
r = client.get("/api/violations")
|
||||
assert r.status_code == 200
|
||||
assert r.json() == []
|
||||
|
||||
@@ -75,11 +75,11 @@ def test_violations_lista_y_filtra(client: TestClient, tmp_path: Path) -> None:
|
||||
tid = uuid4()
|
||||
append_violation(tmp_path, _violation(tid, "DetectPII", "block", blocked=True))
|
||||
append_violation(tmp_path, _violation(uuid4(), "Schema", "warning", blocked=False))
|
||||
assert len(client.get("/violations").json()) == 2
|
||||
assert len(client.get("/violations", params={"severity": "block"}).json()) == 1
|
||||
assert len(client.get("/violations", params={"trace_id": str(tid)}).json()) == 1
|
||||
assert len(client.get("/api/violations").json()) == 2
|
||||
assert len(client.get("/api/violations", params={"severity": "block"}).json()) == 1
|
||||
assert len(client.get("/api/violations", params={"trace_id": str(tid)}).json()) == 1
|
||||
|
||||
|
||||
def test_violations_severity_invalida_422(client: TestClient) -> None:
|
||||
r = client.get("/violations", params={"severity": "nope"})
|
||||
r = client.get("/api/violations", params={"severity": "nope"})
|
||||
assert r.status_code == 422
|
||||
|
||||
Reference in New Issue
Block a user