Initial commit: breakpilot-lehrer - Lehrer KI Platform
Services: Admin-Lehrer, Backend-Lehrer, Studio v2, Website, Klausur-Service, School-Service, Voice-Service, Geo-Service, BreakPilot Drive, Agent-Core Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
57
agent-core/tests/conftest.py
Normal file
57
agent-core/tests/conftest.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""
|
||||
Pytest configuration and fixtures for agent-core tests
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import asyncio
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add agent-core to path
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def event_loop():
|
||||
"""Create an instance of the default event loop for each test case."""
|
||||
loop = asyncio.get_event_loop_policy().new_event_loop()
|
||||
yield loop
|
||||
loop.close()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_redis():
|
||||
"""Mock Redis client for testing"""
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
|
||||
redis = AsyncMock()
|
||||
redis.get = AsyncMock(return_value=None)
|
||||
redis.set = AsyncMock(return_value=True)
|
||||
redis.setex = AsyncMock(return_value=True)
|
||||
redis.delete = AsyncMock(return_value=True)
|
||||
redis.keys = AsyncMock(return_value=[])
|
||||
redis.publish = AsyncMock(return_value=1)
|
||||
redis.pubsub = MagicMock()
|
||||
|
||||
return redis
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_db_pool():
|
||||
"""Mock PostgreSQL pool for testing"""
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
pool = AsyncMock()
|
||||
|
||||
@asynccontextmanager
|
||||
async def acquire():
|
||||
conn = AsyncMock()
|
||||
conn.fetch = AsyncMock(return_value=[])
|
||||
conn.fetchrow = AsyncMock(return_value=None)
|
||||
conn.execute = AsyncMock(return_value="UPDATE 0")
|
||||
yield conn
|
||||
|
||||
pool.acquire = acquire
|
||||
|
||||
return pool
|
||||
Reference in New Issue
Block a user