rag-chatbot / tests /conftest.py
Abeshith's picture
Fix CI tests: add environment variable defaults and skip integration tests
c4a4657
import pytest
import asyncio
import os
from unittest.mock import patch
from httpx import AsyncClient
os.environ.setdefault("GROQ_API_KEY", "test-key-12345")
os.environ.setdefault("JWT_SECRET_KEY", "test-secret-key-67890")
os.environ.setdefault("MONGODB_URI", "mongodb://localhost:27017/test")
os.environ.setdefault("REDIS_URL", "redis://localhost:6379/0")
os.environ.setdefault("QDRANT_URL", "http://localhost:6333")
os.environ.setdefault("QDRANT_API_KEY", "test-qdrant-key")
from app.main import app
from app.db.redis_client import redis_client
from app.db.mongodb import mongodb
from app.core.cache import semantic_cache
@pytest.fixture(scope="session")
def event_loop():
loop = asyncio.get_event_loop_policy().new_event_loop()
yield loop
loop.close()
@pytest.fixture
async def client():
async with AsyncClient(app=app, base_url="http://test") as ac:
yield ac
@pytest.fixture
async def clear_cache():
await semantic_cache.clear()
yield
await semantic_cache.clear()
@pytest.fixture
def sample_query():
return "What is the attention mechanism?"
@pytest.fixture
def sample_document_text():
return """
The attention mechanism is a key component of modern neural networks.
It allows the model to focus on different parts of the input when processing.
This is particularly useful in sequence-to-sequence tasks.
"""