"""
Fixtures for search engine tests.
"""

import pytest
from unittest.mock import Mock


@pytest.fixture
def mock_settings_snapshot():
    """Create a mock settings snapshot for testing."""
    return {
        "rate_limiting.enabled": {"value": True, "ui_element": "checkbox"},
        "rate_limiting.profile": {
            "value": "balanced",
            "ui_element": "dropdown",
        },
        "rate_limiting.memory_window": {"value": 100, "ui_element": "number"},
        "rate_limiting.exploration_rate": {
            "value": 0.1,
            "ui_element": "number",
        },
        "rate_limiting.learning_rate": {"value": 0.3, "ui_element": "number"},
        "rate_limiting.decay_per_day": {"value": 0.95, "ui_element": "number"},
    }


@pytest.fixture
def mock_llm():
    """Create a mock LLM for testing."""
    llm = Mock()
    llm.invoke.return_value = Mock(content="Test response")
    return llm


@pytest.fixture
def mock_search_results():
    """Create mock search results."""
    return [
        {
            "title": "Test Result 1",
            "link": "https://example.com/result1",
            "snippet": "This is the first test result snippet.",
            "source": "test_engine",
        },
        {
            "title": "Test Result 2",
            "link": "https://example.com/result2",
            "snippet": "This is the second test result snippet.",
            "source": "test_engine",
        },
    ]


@pytest.fixture
def mock_wikipedia_response():
    """Create mock Wikipedia response."""
    return {
        "title": "Test Article",
        "summary": "This is a test article summary from Wikipedia.",
        "url": "https://en.wikipedia.org/wiki/Test_Article",
    }


@pytest.fixture
def mock_arxiv_paper():
    """Create mock arXiv paper response."""
    return {
        "id": "2301.12345",
        "title": "A Test Paper on Machine Learning",
        "authors": ["John Doe", "Jane Smith"],
        "summary": "This paper presents a novel approach to machine learning.",
        "pdf_url": "https://arxiv.org/pdf/2301.12345.pdf",
        "published": "2023-01-15",
    }


@pytest.fixture
def mock_pubmed_article():
    """Create mock PubMed article response."""
    return {
        "pmid": "12345678",
        "title": "A Clinical Study on Treatment Efficacy",
        "authors": ["Dr. Smith", "Dr. Jones"],
        "abstract": "This study examines the efficacy of a novel treatment.",
        "journal": "Journal of Medical Research",
        "pub_date": "2023-06-01",
    }


@pytest.fixture
def mock_http_session():
    """Create a mock HTTP session for testing."""
    session = Mock()
    response = Mock()
    response.status_code = 200
    response.json.return_value = {"results": []}
    response.text = '{"results": []}'
    session.get.return_value = response
    session.post.return_value = response
    return session
