"""
Unit tests for Hone SDK providers module.

Exact replica of TypeScript providers tests - tests AIProvider enum and helper functions.
"""

from hone.providers import (
    AIProvider,
    AI_PROVIDER_VALUES,
    is_valid_provider,
    get_provider_display_name,
)


class TestAIProvider:
    """Tests for AIProvider enum."""

    def test_should_have_all_expected_providers(self):
        """Should have all expected provider values."""
        expected_providers = [
            "openai",
            "anthropic",
            "google",
        ]

        for provider in expected_providers:
            assert provider in AI_PROVIDER_VALUES, f"Missing provider: {provider}"

    def test_should_have_correct_string_values(self):
        """Should have correct string values for each provider."""
        assert AIProvider.OPENAI.value == "openai"
        assert AIProvider.ANTHROPIC.value == "anthropic"
        assert AIProvider.GOOGLE.value == "google"

    def test_should_be_usable_as_string(self):
        """Provider enum values should be usable as strings."""
        provider = AIProvider.OPENAI
        # Direct comparison works due to str inheritance
        assert provider == "openai"
        # .value gives the string value
        assert provider.value == "openai"

    def test_ai_provider_values_should_match_enum(self):
        """AI_PROVIDER_VALUES should match all enum values."""
        enum_values = [p.value for p in AIProvider]
        assert set(AI_PROVIDER_VALUES) == set(enum_values)
        assert len(AI_PROVIDER_VALUES) == len(AIProvider)


class TestIsValidProvider:
    """Tests for is_valid_provider function."""

    def test_should_return_true_for_valid_providers(self):
        """Should return True for valid provider strings."""
        assert is_valid_provider("openai") is True
        assert is_valid_provider("anthropic") is True
        assert is_valid_provider("google") is True

    def test_should_return_false_for_invalid_providers(self):
        """Should return False for invalid provider strings."""
        assert is_valid_provider("invalid") is False
        assert is_valid_provider("OpenAI") is False  # Case sensitive
        assert is_valid_provider("") is False
        assert is_valid_provider("gpt-4") is False  # Model, not provider

    def test_should_work_with_all_enum_values(self):
        """Should return True for all AIProvider enum values."""
        for provider in AIProvider:
            assert is_valid_provider(provider.value) is True


class TestGetProviderDisplayName:
    """Tests for get_provider_display_name function."""

    def test_should_return_correct_display_names(self):
        """Should return correct display names for known providers."""
        assert get_provider_display_name("openai") == "OpenAI"
        assert get_provider_display_name("anthropic") == "Anthropic"
        assert get_provider_display_name("google") == "Google AI"

    def test_should_return_input_for_unknown_providers(self):
        """Should return the input string for unknown providers."""
        assert get_provider_display_name("unknown") == "unknown"
        assert get_provider_display_name("my-custom-provider") == "my-custom-provider"

    def test_should_work_with_enum_values(self):
        """Should work when passed AIProvider enum values."""
        assert get_provider_display_name(AIProvider.OPENAI.value) == "OpenAI"
        assert get_provider_display_name(AIProvider.ANTHROPIC.value) == "Anthropic"


class TestProviderImports:
    """Tests for provider module imports."""

    def test_should_be_importable_from_hone_package(self):
        """Should be importable from the main hone package."""
        from hone import (
            AIProvider,
            AI_PROVIDER_VALUES,
            is_valid_provider,
            get_provider_display_name,
        )

        assert AIProvider is not None
        assert AI_PROVIDER_VALUES is not None
        assert is_valid_provider is not None
        assert get_provider_display_name is not None

    def test_should_be_in_all_exports(self):
        """Should be included in __all__."""
        import hone

        assert "AIProvider" in hone.__all__
        assert "AI_PROVIDER_VALUES" in hone.__all__
        assert "is_valid_provider" in hone.__all__
        assert "get_provider_display_name" in hone.__all__
