import pytest import pytest_asyncio from unittest.mock import AsyncMock, MagicMock, patch from app.core.llm_client import LLMClient, LLMResponse from app.core.model_registry import ModelRegistry, Capability @pytest.fixture def mock_llm_response(): def _create_response(content="{}", model="gpt-oss-20b", reasoning=None): return LLMResponse(content=content, model=model, reasoning=reasoning) return _create_response @pytest_asyncio.fixture async def llm_client(): client = LLMClient() # Mock primary and fallback to prevent actual API calls client.primary = AsyncMock() client.fallback = AsyncMock() client.initialized = True client.provider_name = "groq" return client @pytest.fixture(autouse=True) def mock_settings(): with patch("app.config.settings") as mock_s: mock_s.GROQ_API_KEY = "mock_key" mock_s.LLM_TEMPERATURE = 0.7 mock_s.LLM_MAX_TOKENS = 1000 mock_s.GROQ_FAST_MODEL = None mock_s.GROQ_SMART_MODEL = None mock_s.GROQ_STRUCTURED_MODEL = None mock_s.GROQ_SAFETY_MODEL = None yield mock_s @pytest.fixture def mock_groq_client(): with patch("app.core.llm_client.GroqClient") as mock: instance = mock.return_value instance.initialize = AsyncMock() instance.generate = AsyncMock() instance.generate_structured = AsyncMock() yield instance