Refactor configuration handling and improve error management across services; normalize placeholder values for SMTP and Stripe configurations; enhance local storage fallback logic in StorageService; add tests for new behaviors and edge cases.

This commit is contained in:
Your Name
2026-03-26 14:15:10 +02:00
parent 688d411537
commit bc8a5dc290
19 changed files with 423 additions and 95 deletions

View File

@@ -0,0 +1,24 @@
"""Service-level tests for PDF AI helpers."""
import pytest
from app.services.pdf_ai_service import PdfAiError, _extract_text_from_pdf
def test_extract_text_from_pdf_rejects_password_protected_documents(monkeypatch):
"""Password-protected PDFs should surface a specific actionable error."""
class FakeReader:
def __init__(self, input_path):
self.is_encrypted = True
self.pages = []
def decrypt(self, password):
return 0
monkeypatch.setattr("PyPDF2.PdfReader", FakeReader)
with pytest.raises(PdfAiError) as exc:
_extract_text_from_pdf("/tmp/protected.pdf")
assert exc.value.error_code == "PDF_ENCRYPTED"
assert "unlock" in exc.value.user_message.lower()