Files

46 lines
1.7 KiB
Python

"""Verify: check if alert-stats endpoint somehow exists"""
import pytest, sys
sys.path.insert(0, '/root/cma-management/backend')
from fastapi.testclient import TestClient
from app.main import app
from app.database import get_db
from tests.conftest import TEST_ENGINE, TEST_SESSION_LOCAL, Base
Base.metadata.create_all(bind=TEST_ENGINE)
session = TEST_SESSION_LOCAL()
app.dependency_overrides[get_db] = lambda: session
from tests.conftest import create_test_user, get_token_for_user, auth_header
create_test_user(session)
client = TestClient(app)
token = get_token_for_user(client)
# Check alert-stats
resp = client.get("/api/cma/dashboard/alert-stats", headers=auth_header(token))
print(f"alert-stats: status={resp.status_code}, body={resp.text[:200]}")
# Check trend-analysis POST
resp2 = client.post("/api/cma/dashboard/trend-analysis", headers=auth_header(token), json={})
print(f"trend-analysis POST: status={resp2.status_code}, body={resp2.text[:200]}")
# Check trend-analysis GET
resp3 = client.get("/api/cma/dashboard/trend-analysis", headers=auth_header(token))
print(f"trend-analysis GET: status={resp3.status_code}, body={resp3.text[:200]}")
# Check kpis/enhanced
resp4 = client.get("/api/cma/dashboard/kpis/enhanced", headers=auth_header(token))
print(f"kpis/enhanced: status={resp4.status_code}, body={resp4.text[:200]}")
# Check kpi-trend
resp5 = client.get("/api/cma/dashboard/kpi-trend?kpi_ids=1", headers=auth_header(token))
print(f"kpi-trend: status={resp5.status_code}, body={resp5.text[:200]}")
# Check app routes
for route in app.routes:
if hasattr(route, 'path') and 'alert' in route.path.lower():
print(f" Found route: {route.methods} {route.path}")
app.dependency_overrides.clear()
Base.metadata.drop_all(bind=TEST_ENGINE)