"""Smoke test for Phase 1 foundation fixtures in tests/conftest.py.

This test exists purely to verify the three shared fixtures
(module_registry_cache, mock_bolls_life, mcp_client) are wired
correctly and work end-to-end.  It can be removed once real tests
consume the fixtures.
"""

from __future__ import annotations

import pytest


def test_module_registry_cache_loads(module_registry_cache):
    """Session-scoped cache returns a dict with at least 10 modules."""
    assert isinstance(module_registry_cache, dict)
    assert len(module_registry_cache) >= 10, (
        f"Expected >=10 modules, got {len(module_registry_cache)}"
    )


def test_mock_bolls_life_returns_canned_verse(mock_bolls_life):
    """Set a response and fetch it through the real bible_api path."""
    from accordance_parser.bible_api import fetch_bolls_verse

    mock_bolls_life(
        "/get-verse/KJV/1/1/1/",
        {"text": "In the beginning God created the heaven and the earth."},
    )

    result = fetch_bolls_verse("kjv", 1, 1, 1)
    assert result is not None
    assert "beginning" in result.text
    assert result.translation == "KJV"


def test_mock_bolls_life_unknown_returns_empty(mock_bolls_life):
    """Unmatched URLs get the default empty response, not a crash."""
    from accordance_parser.bible_api import fetch_bolls_verse

    # No mock set — should get default {"text": ""}
    result = fetch_bolls_verse("kjv", 66, 22, 21)
    assert result is None  # empty text → None in fetch_bolls_verse


@pytest.mark.anyio
async def test_mcp_client_connects(mcp_client):
    """In-memory client completes the initialize handshake."""
    # listing tools is the simplest non-destructive probe
    tools = await mcp_client.list_tools()
    assert isinstance(tools, list)
    # The Accordance server has many tools; just check non-empty
    assert len(tools) >= 1, f"Expected >=1 tool, got {len(tools)}"
