feat: add FastAPI admin dashboard with sync orchestration and test suite
Replace Flask admin with FastAPI app (api/app/) featuring: - Dashboard with stat cards, sync control, and history - Mappings CRUD for ARTICOLE_TERTI with CSV import/export - Article autocomplete from NOM_ARTICOLE - SKU pre-validation before import - Sync orchestration: read JSONs -> validate -> import -> log to SQLite - APScheduler for periodic sync from UI - File logging to logs/sync_comenzi_YYYYMMDD_HHMMSS.log - Oracle pool None guard (503 vs 500 on unavailable) Test suite: - test_app_basic.py: 30 tests (imports + routes) without Oracle - test_integration.py: 9 integration tests with Oracle Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
30
api/app/routers/health.py
Normal file
30
api/app/routers/health.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from fastapi import APIRouter
|
||||
from .. import database
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/health")
|
||||
async def health_check():
|
||||
result = {"oracle": "error", "sqlite": "error"}
|
||||
|
||||
# Check Oracle
|
||||
try:
|
||||
if database.pool:
|
||||
with database.pool.acquire() as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT SYSDATE FROM DUAL")
|
||||
cur.fetchone()
|
||||
result["oracle"] = "ok"
|
||||
except Exception as e:
|
||||
result["oracle"] = str(e)
|
||||
|
||||
# Check SQLite
|
||||
try:
|
||||
db = await database.get_sqlite()
|
||||
await db.execute("SELECT 1")
|
||||
await db.close()
|
||||
result["sqlite"] = "ok"
|
||||
except Exception as e:
|
||||
result["sqlite"] = str(e)
|
||||
|
||||
return result
|
||||
Reference in New Issue
Block a user