Add admin panel, WebSocket support, and API versioning
CI / Lint & Format (push) Failing after 28s
CI / Tests (push) Has been skipped
CI / Security Scan (push) Failing after 8s
CI / Docker Build (push) Has been skipped

Introduce an admin portal (React + Nginx), WebSocket routing, and
API versioning middleware with `/api/v1/` prefix deprecation.
Add master API key authentication, new Prometheus metrics for AI
token consumption and active WebSockets, and extend S3 config
with a public endpoint URL. Update test paths and fixtures to
align with the new routing structure.
This commit is contained in:
2026-06-22 11:25:22 -04:00
parent d68deb9c74
commit 2f2a5e9b4a
158 changed files with 64811 additions and 503 deletions
+11 -4
View File
@@ -8,11 +8,17 @@ def test_detect_language():
assert _detect_language("") == "unknown"
assert _detect_language("123456789") == "unknown"
@pytest.mark.asyncio
@patch("app.services.ocr_service.pytesseract")
@patch("app.services.ocr_service.PILImage")
@patch("app.services.ocr_service.Path.exists", return_value=True)
@patch("app.services.ocr_service.settings")
def test_extract_text_success(mock_settings, mock_path_exists, mock_pil, mock_tesseract):
@patch("app.services.ocr_service.get_storage_backend")
async def test_extract_text_success(mock_get_storage_backend, mock_settings, mock_path_exists, mock_pil, mock_tesseract):
from unittest.mock import AsyncMock
mock_backend = MagicMock()
mock_backend.get_bytes = AsyncMock(return_value=b"fake")
mock_get_storage_backend.return_value = mock_backend
mock_settings.OCR_ENABLED = True
mock_settings.OCR_LANGUAGES = "fra+eng"
mock_settings.TESSERACT_CMD = None
@@ -26,16 +32,17 @@ def test_extract_text_success(mock_settings, mock_path_exists, mock_pil, mock_te
# Mock image_to_string
mock_tesseract.image_to_string.return_value = "This is a test OCR output."
result = extract_text("fake/path.jpg")
result = await extract_text("fake/path.jpg")
assert result["has_text"] is True
assert result["text"] == "This is a test OCR output."
assert result["confidence"] == 0.8 # (90+80+70)/3 / 100 = 0.8
assert result["language"] == "en"
@pytest.mark.asyncio
@patch("app.services.ocr_service.settings")
def test_extract_text_disabled(mock_settings):
async def test_extract_text_disabled(mock_settings):
mock_settings.OCR_ENABLED = False
result = extract_text("any/path.jpg")
result = await extract_text("any/path.jpg")
assert result["has_text"] is False
assert result["text"] is None