Protect private API routes and scope agent data

This commit is contained in:
Hamza Ayed
2026-10-03 00:34:49 +03:00
parent 1c1f662850
commit b0cd825838
17 changed files with 313 additions and 95 deletions
@@ -8,7 +8,6 @@ from unittest.mock import AsyncMock, MagicMock, patch
from PIL import Image, ImageDraw
from pypdf import PdfReader, PdfWriter
from fastapi.testclient import TestClient
from app.local_ocr import LocalOCRError
from app.pdf_documents import extract_pdf_pages_text
@@ -18,6 +17,7 @@ if "SOVEREIGNAI_DATA_DIR" not in os.environ:
os.environ["SOVEREIGNAI_DATA_DIR"] = _TEST_DATA_DIR.name
from app.main import app
from tests.api_client import authenticated_client
def make_pdf(text: str | None) -> bytes:
@@ -79,7 +79,7 @@ def make_mixed_pdf() -> bytes:
class PdfAnalysisTests(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.client = TestClient(app)
cls.client = authenticated_client(app)
def test_extracts_pdf_text_and_sends_page_number_to_model(self) -> None:
completion = {"choices": [{"message": {"content": "يتحدث الملف عن لقاء مجتمعي في عمّان."}}]}