"""
Tests for the default search engine configurations.

Tests cover:
- Default Elasticsearch configuration
- Default search engine configs
"""


class TestGetDefaultElasticsearchConfig:
    """Tests for get_default_elasticsearch_config function."""

    def test_returns_dict(self):
        """Function returns a dictionary."""
        from local_deep_research.web_search_engines.default_search_engines import (
            get_default_elasticsearch_config,
        )

        result = get_default_elasticsearch_config()

        assert isinstance(result, dict)

    def test_has_required_keys(self):
        """Config has required keys."""
        from local_deep_research.web_search_engines.default_search_engines import (
            get_default_elasticsearch_config,
        )

        result = get_default_elasticsearch_config()

        assert "module_path" in result
        assert "class_name" in result
        assert "requires_llm" in result
        assert "default_params" in result
        assert "description" in result

    def test_correct_class_name(self):
        """Config has correct class name."""
        from local_deep_research.web_search_engines.default_search_engines import (
            get_default_elasticsearch_config,
        )

        result = get_default_elasticsearch_config()

        assert result["class_name"] == "ElasticsearchSearchEngine"

    def test_has_hosts_param(self):
        """Config has hosts in default params."""
        from local_deep_research.web_search_engines.default_search_engines import (
            get_default_elasticsearch_config,
        )

        result = get_default_elasticsearch_config()

        assert "hosts" in result["default_params"]
        assert isinstance(result["default_params"]["hosts"], list)

    def test_has_index_name(self):
        """Config has index name in default params."""
        from local_deep_research.web_search_engines.default_search_engines import (
            get_default_elasticsearch_config,
        )

        result = get_default_elasticsearch_config()

        assert "index_name" in result["default_params"]

    def test_has_search_fields(self):
        """Config has search fields in default params."""
        from local_deep_research.web_search_engines.default_search_engines import (
            get_default_elasticsearch_config,
        )

        result = get_default_elasticsearch_config()

        assert "search_fields" in result["default_params"]
        assert isinstance(result["default_params"]["search_fields"], list)


class TestGetDefaultSearchEngineConfigs:
    """Tests for get_default_search_engine_configs function."""

    def test_returns_dict(self):
        """Function returns a dictionary."""
        from local_deep_research.web_search_engines.default_search_engines import (
            get_default_search_engine_configs,
        )

        result = get_default_search_engine_configs()

        assert isinstance(result, dict)

    def test_has_elasticsearch(self):
        """Config includes elasticsearch."""
        from local_deep_research.web_search_engines.default_search_engines import (
            get_default_search_engine_configs,
        )

        result = get_default_search_engine_configs()

        assert "elasticsearch" in result

    def test_elasticsearch_config_matches(self):
        """Elasticsearch config matches dedicated function."""
        from local_deep_research.web_search_engines.default_search_engines import (
            get_default_elasticsearch_config,
            get_default_search_engine_configs,
        )

        configs = get_default_search_engine_configs()
        es_config = get_default_elasticsearch_config()

        assert configs["elasticsearch"] == es_config
