All checks were successful
Deploy to Production / deploy (push) Successful in 2m23s
Includes frontend redesign (Navigation, billingApi), backend updates (auth routes, admin routes, LLM service refactor), MSAL removal, and dependency updates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
"""
|
|
conftest.py — sys.modules stubs so tests run without the full Docker venv.
|
|
All heavy external packages are replaced with MagicMocks before any app.*
|
|
module is imported. Individual tests patch specific methods as needed.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from unittest.mock import MagicMock, AsyncMock
|
|
|
|
# ── Fake env vars required at llm_service.py module level ─────────────────────
|
|
os.environ.setdefault('GEMINI_API_KEY', 'test-key-gemini')
|
|
os.environ.setdefault('OPENAI_API_KEY', 'test-key-openai')
|
|
|
|
|
|
def _stub(*names):
|
|
"""Register MagicMocks under each name in sys.modules."""
|
|
for name in names:
|
|
if name not in sys.modules:
|
|
sys.modules[name] = MagicMock()
|
|
|
|
|
|
# ── External packages not present in system Python ────────────────────────────
|
|
_stub(
|
|
'google', 'google.genai', 'google.genai.types',
|
|
'openai', 'openai.types', 'openai.types.responses',
|
|
'motor', 'motor.motor_asyncio',
|
|
'pymongo', 'pymongo.errors',
|
|
'quart', 'quart_cors', 'hypercorn', 'werkzeug', 'werkzeug.exceptions',
|
|
'socketio',
|
|
'bcrypt', 'jwt',
|
|
'bson', 'bson.objectid',
|
|
'pydantic',
|
|
'PIL', 'PIL.Image',
|
|
'httpx', 'requests',
|
|
'dotenv',
|
|
'llama_cloud_services',
|
|
)
|
|
|
|
# ── app.db ─────────────────────────────────────────────────────────────────────
|
|
# Any `from app.db import get_db` will capture this AsyncMock.
|
|
# Tests that need to control DB responses should patch
|
|
# `app.models.<module>.get_db` (i.e. the local binding in the module under test).
|
|
|
|
_mock_db = MagicMock()
|
|
_mock_get_db = AsyncMock(return_value=_mock_db)
|
|
|
|
_app_db_mod = MagicMock()
|
|
_app_db_mod.get_db = _mock_get_db
|
|
sys.modules['app.db'] = _app_db_mod
|
|
|
|
# Expose for tests
|
|
mock_db = _mock_db
|