Performance: - SSE dashboard streaming endpoint (GET /v1/admin/status/stream) - Web Worker for markdown rendering (offload from main thread) - IndexedDB chat persistence (replace localStorage, 500msg support) Security: - CSRF protection middleware (Origin/Referer validation) - Content Security Policy + security headers middleware - API key rotation endpoint (POST /v1/admin/keys/rotate) Observability: - OpenTelemetry tracing with graceful NoOp fallback - Structured error codes (FAGI-xxxx taxonomy with ErrorResponse schema) - Audit log export (CSV + JSON at /v1/admin/audit/export/*) Features: - Multi-session management hook (parallel conversations) - Conversation export (markdown/JSON/text download + clipboard) - Head customization UI (enable/disable + weight sliders for 12 heads) Infrastructure: - Kubernetes Helm chart (Deployment, Service, HPA, Ingress) - Database migration versioning (generate, verify commands) - Blue-green deployment manifests (color-based traffic switching) Tests: 598 Python + 56 frontend = 654 total, 0 ruff errors Co-Authored-By: Nakamoto, S <defi@defi-oracle.io>
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""Tests for structured error codes."""
|
|
|
|
from fusionagi.api.error_codes import (
|
|
ErrorCode,
|
|
error_json_response,
|
|
error_response,
|
|
)
|
|
|
|
|
|
def test_error_codes_unique():
|
|
"""All error codes should have unique values."""
|
|
values = [e.value for e in ErrorCode]
|
|
assert len(values) == len(set(values))
|
|
|
|
|
|
def test_error_response_basic():
|
|
"""error_response should return structured dict."""
|
|
resp = error_response(ErrorCode.AUTH_MISSING)
|
|
assert resp["error"]["code"] == "FAGI-1001"
|
|
assert "Authentication" in resp["error"]["message"]
|
|
|
|
|
|
def test_error_response_custom_detail():
|
|
"""Custom detail should override default message."""
|
|
resp = error_response(ErrorCode.INTERNAL_ERROR, detail="Custom error")
|
|
assert resp["error"]["message"] == "Custom error"
|
|
|
|
|
|
def test_error_response_extra():
|
|
"""Extra data should appear in details."""
|
|
resp = error_response(ErrorCode.INPUT_INVALID, extra={"field": "prompt"})
|
|
assert resp["error"]["details"]["field"] == "prompt"
|
|
|
|
|
|
def test_error_json_response():
|
|
"""error_json_response should return a JSONResponse."""
|
|
r = error_json_response(ErrorCode.SESSION_NOT_FOUND, status_code=404)
|
|
assert r.status_code == 404
|