refactor: engineering improvements -- API versioning, structured logging, Alembic, error standardization, test coverage
- API versioning: all REST endpoints prefixed with /api/v1/ - Structured logging: replaced stdlib logging with structlog (console/JSON modes) - Alembic migrations: versioned DB schema with initial migration - Error standardization: global exception handlers for consistent envelope format - Interrupt cleanup: asyncio background task for expired interrupt removal - Integration tests: +30 tests (analytics, replay, openapi, error, session APIs) - Frontend tests: +57 tests (all components, pages, useWebSocket hook) - Backend: 557 tests, 89.75% coverage | Frontend: 80 tests, 16 test files
This commit is contained in:
@@ -44,7 +44,7 @@ def _make_analytics_result() -> object:
|
||||
)
|
||||
|
||||
|
||||
def _get_analytics(app: FastAPI, path: str = "/api/analytics", **patch_kwargs: object) -> object:
|
||||
def _get_analytics(app: FastAPI, path: str = "/api/v1/analytics", **patch_kwargs: object) -> object:
|
||||
"""Helper: patch get_analytics, make request, return (response, mock)."""
|
||||
analytics_result = _make_analytics_result()
|
||||
with (
|
||||
@@ -84,7 +84,7 @@ class TestAnalyticsEndpoint:
|
||||
def test_custom_range_7d(self) -> None:
|
||||
app = _build_app()
|
||||
app.state.pool = _make_mock_pool()
|
||||
resp, mock_ga = _get_analytics(app, "/api/analytics?range=7d")
|
||||
resp, mock_ga = _get_analytics(app, "/api/v1/analytics?range=7d")
|
||||
|
||||
assert resp.status_code == 200
|
||||
mock_ga.assert_called_once()
|
||||
@@ -94,7 +94,7 @@ class TestAnalyticsEndpoint:
|
||||
def test_custom_range_30d(self) -> None:
|
||||
app = _build_app()
|
||||
app.state.pool = _make_mock_pool()
|
||||
resp, mock_ga = _get_analytics(app, "/api/analytics?range=30d")
|
||||
resp, mock_ga = _get_analytics(app, "/api/v1/analytics?range=30d")
|
||||
|
||||
assert resp.status_code == 200
|
||||
call_kwargs = mock_ga.call_args
|
||||
@@ -107,7 +107,7 @@ class TestAnalyticsEndpoint:
|
||||
app.state.pool = _make_mock_pool()
|
||||
|
||||
with TestClient(app) as client:
|
||||
resp = client.get("/api/analytics?range=invalid")
|
||||
resp = client.get("/api/v1/analytics?range=invalid")
|
||||
|
||||
assert resp.status_code == 400
|
||||
|
||||
@@ -116,7 +116,7 @@ class TestAnalyticsEndpoint:
|
||||
app.state.pool = _make_mock_pool()
|
||||
|
||||
with TestClient(app) as client:
|
||||
resp = client.get("/api/analytics?range=7")
|
||||
resp = client.get("/api/v1/analytics?range=7")
|
||||
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
Reference in New Issue
Block a user