# import pytest
# from unittest.mock import AsyncMock, patch, MagicMock

# from app.core.providers.base import LLMProvider
# from app.core.providers.llm.deepseek import DeepSeekProvider
# from app.core.providers.llm.gemini import GeminiProvider
# from openai import OpenAI
# import httpx

# # --- Fixtures ---

# @pytest.fixture
# def mock_deepseek_client():
#     """Provides a mock OpenAI client with a mocked chat.completions.create method."""
#     mock_client = MagicMock(spec=OpenAI)
    
#     mock_response = MagicMock()
#     mock_response.choices = [MagicMock()]
#     mock_response.choices[0].message.content = "This is a mocked DeepSeek response."
    
#     mock_client.chat.completions.create = AsyncMock(return_value=mock_response)
    
#     return mock_client

# # --- DeepSeek Provider Tests ---

# @pytest.mark.asyncio
# async def test_deepseek_provider_generates_response(mock_deepseek_client):
#     """Tests that DeepSeekProvider returns the expected response."""
#     provider = DeepSeekProvider(model_name="deepseek-chat", client=mock_deepseek_client)
    
#     assert isinstance(provider, LLMProvider)
    
#     response = await provider.generate_response("Test prompt")
    
#     mock_deepseek_client.chat.completions.create.assert_awaited_with(
#         model="deepseek-chat", 
#         messages=[
#             {"role": "system", "content": "You are a helpful assistant."},
#             {"role": "user", "content": "Test prompt"}
#         ]
#     )
#     assert response == "This is a mocked DeepSeek response."

# # --- Gemini Provider Tests ---
# @pytest.mark.asyncio
# async def test_gemini_provider_generates_response(mocker):
#     """Tests that GeminiProvider returns the expected response."""
#     # Mock the response object from the post call
#     mock_response = MagicMock()
#     mock_response.raise_for_status.return_value = None
#     mock_response.json = MagicMock(return_value={
#         'candidates': [{'content': {'parts': [{'text': 'This is a mocked Gemini response.'}]}}]
#     })

#     # Create a mock for the AsyncClient instance
#     mock_client_instance = MagicMock(spec=httpx.AsyncClient)
#     mock_client_instance.post = AsyncMock(return_value=mock_response)
    
#     # Create a mock for the AsyncClient class itself
#     mock_async_client_class = MagicMock(spec=httpx.AsyncClient)
    
#     # Mock the behavior of `async with`
#     mock_async_client_class.return_value.__aenter__ = AsyncMock(return_value=mock_client_instance)
#     mock_async_client_class.return_value.__aexit__ = AsyncMock(return_value=None)
    
#     # Patch the AsyncClient class
#     mocker.patch('httpx.AsyncClient', new=mock_async_client_class)
    
#     provider = GeminiProvider(api_url="http://mock-gemini.com")
#     assert isinstance(provider, LLMProvider)
    
#     response = await provider.generate_response("Test prompt")
    
#     mock_client_instance.post.assert_awaited_with(
#         "http://mock-gemini.com",
#         json={"contents": [{"parts": [{"text": "Test prompt"}]}]},
#         headers={"Content-Type": "application/json"}
#     )
    
#     assert response == "This is a mocked Gemini response."
