"""Tests for wideholy.api — HTTP client for wideholy.com."""

from __future__ import annotations

from wideholy.api import VALID_RELIGIONS, WideHoly


class TestWideHolyClient:
    """Verify the client initializes and has all expected methods."""

    def test_init_default(self) -> None:
        client = WideHoly()
        assert "wideholy.com" in str(client._client.base_url)
        assert "api/v1" in str(client._client.base_url)
        client.close()

    def test_init_custom_url(self) -> None:
        client = WideHoly(base_url="http://localhost:8000", timeout=5.0)
        assert "localhost" in str(client._client.base_url)
        client.close()

    def test_context_manager(self) -> None:
        with WideHoly() as client:
            assert client is not None

    def test_has_all_methods(self) -> None:
        client = WideHoly()
        methods = [
            "verse_of_the_day",
            "random_verse",
            "compare",
            "search_suggest",
            "topic_verses",
            "cross_religion",
            "calendar",
            "commentary",
        ]
        for method in methods:
            assert hasattr(client, method), f"Missing method: {method}"
            assert callable(getattr(client, method))
        client.close()

    def test_valid_religions(self) -> None:
        assert "bible" in VALID_RELIGIONS
        assert "quran" in VALID_RELIGIONS
        assert "torah" in VALID_RELIGIONS
        assert "gita" in VALID_RELIGIONS
        assert "sutra" in VALID_RELIGIONS
        assert len(VALID_RELIGIONS) == 5
