from unittest.mock import AsyncMock, MagicMock

class MockClaudeMessage:
    def __init__(self, content):
        self.content = content

class MockClaudeResponse:
    def __init__(self, content="Mock Claude Response"):
        self.content = [MockClaudeMessage(content)]

class MockGeminiResponse:
    """Mock response from Gemini API."""
    def __init__(self, text):
        self.text = text

class MockGeminiModel:
    """Mock Gemini model."""
    def __init__(self, model_name):
        self.model_name = model_name

    def generate_content(self, prompt, generation_config=None):
        """Mock generate_content method."""
        if "error" in prompt.lower():
            raise ValueError("Mock error for testing")
        return MockGeminiResponse("This is a mock response from " + self.model_name)

class MockGeminiClient:
    """Mock Gemini client."""
    def __init__(self):
        self.api_key = "mock_api_key"

    def configure(self, api_key):
        """Mock configure method."""
        self.api_key = api_key

    def GenerativeModel(self, model_name):
        """Mock GenerativeModel method."""
        return MockGeminiModel(model_name)

class MockClaudeClient:
    def __init__(self):
        self.messages = AsyncMock()
        self.messages.create = AsyncMock(return_value=MockClaudeResponse())

def mock_claude_provider():
    """Create a mock Claude provider."""
    return MockClaudeClient()

def mock_gemini_provider():
    """Create a mock Gemini provider."""
    return MockGeminiClient()

def patch_providers(monkeypatch):
    """Patch both Claude and Gemini providers."""
    # Mock Anthropic
    monkeypatch.setattr('anthropic.Anthropic', mock_claude_provider)
    
    # Mock Gemini
    mock_genai = MagicMock()
    mock_genai.GenerativeModel = mock_gemini_provider
    monkeypatch.setattr('google.generativeai', mock_genai) 