"""
Tests for the ParallelSearchEngine class.

Tests cover:
- Global executor management
- Initialization
- API key availability checking
- Engine selection
- Engine instance caching
- Parallel execution
- Full content retrieval
"""

import concurrent.futures
from unittest.mock import Mock, patch


from local_deep_research.utilities.enums import SearchMode


class TestGlobalExecutor:
    """Tests for global executor functions."""

    def test_get_global_executor_creates_pool(self):
        """_get_global_executor creates a thread pool."""
        from local_deep_research.web_search_engines.engines import (
            parallel_search_engine,
        )

        # Reset global executor
        with parallel_search_engine._global_executor_lock:
            old_executor = parallel_search_engine._global_executor
            parallel_search_engine._global_executor = None

        try:
            executor = parallel_search_engine._get_global_executor(
                max_workers=2
            )
            assert executor is not None
            assert isinstance(executor, concurrent.futures.ThreadPoolExecutor)
        finally:
            # Restore
            with parallel_search_engine._global_executor_lock:
                if parallel_search_engine._global_executor:
                    parallel_search_engine._global_executor.shutdown(wait=False)
                parallel_search_engine._global_executor = old_executor

    def test_get_global_executor_returns_cached(self):
        """_get_global_executor returns cached executor on subsequent calls."""
        from local_deep_research.web_search_engines.engines import (
            parallel_search_engine,
        )

        # Reset global executor
        with parallel_search_engine._global_executor_lock:
            old_executor = parallel_search_engine._global_executor
            parallel_search_engine._global_executor = None

        try:
            executor1 = parallel_search_engine._get_global_executor(
                max_workers=2
            )
            executor2 = parallel_search_engine._get_global_executor(
                max_workers=10
            )

            # Should be the same instance (max_workers ignored on second call)
            assert executor1 is executor2
        finally:
            # Restore
            with parallel_search_engine._global_executor_lock:
                if parallel_search_engine._global_executor:
                    parallel_search_engine._global_executor.shutdown(wait=False)
                parallel_search_engine._global_executor = old_executor

    def test_shutdown_global_executor(self):
        """shutdown_global_executor shuts down and clears the pool."""
        from local_deep_research.web_search_engines.engines import (
            parallel_search_engine,
        )

        # Reset global executor
        with parallel_search_engine._global_executor_lock:
            old_executor = parallel_search_engine._global_executor
            parallel_search_engine._global_executor = None

        try:
            # Create an executor
            parallel_search_engine._get_global_executor(max_workers=2)
            assert parallel_search_engine._global_executor is not None

            # Shut it down
            parallel_search_engine.shutdown_global_executor(wait=True)
            assert parallel_search_engine._global_executor is None
        finally:
            # Restore
            with parallel_search_engine._global_executor_lock:
                parallel_search_engine._global_executor = old_executor

    def test_shutdown_global_executor_when_none(self):
        """shutdown_global_executor handles None executor gracefully."""
        from local_deep_research.web_search_engines.engines import (
            parallel_search_engine,
        )

        # Reset global executor
        with parallel_search_engine._global_executor_lock:
            old_executor = parallel_search_engine._global_executor
            parallel_search_engine._global_executor = None

        try:
            # Should not raise
            parallel_search_engine.shutdown_global_executor(wait=True)
        finally:
            # Restore
            with parallel_search_engine._global_executor_lock:
                parallel_search_engine._global_executor = old_executor


class TestParallelSearchEngineInit:
    """Tests for ParallelSearchEngine initialization."""

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_init_default_values(self, mock_get_executor):
        """ParallelSearchEngine initializes with default values."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)

            assert engine.use_api_key_services is True
            assert engine.max_engines_to_select == 100
            assert engine.allow_local_engines is False
            assert engine.include_generic_engines is True
            assert engine.search_mode == SearchMode.ALL

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_init_custom_values(self, mock_get_executor):
        """ParallelSearchEngine initializes with custom values."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(
                llm=mock_llm,
                use_api_key_services=False,
                max_engines_to_select=5,
                allow_local_engines=True,
                include_generic_engines=False,
                search_mode=SearchMode.SCIENTIFIC,
            )

            assert engine.use_api_key_services is False
            assert engine.max_engines_to_select == 5
            assert engine.allow_local_engines is True
            assert engine.include_generic_engines is False
            assert engine.search_mode == SearchMode.SCIENTIFIC

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_init_sets_max_filtered_results(self, mock_get_executor):
        """ParallelSearchEngine sets max_filtered_results to 50 by default."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)

            assert engine.max_filtered_results == 50

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_init_disables_llm_relevance_filter_by_default(
        self, mock_get_executor
    ):
        """ParallelSearchEngine disables LLM relevance filter by default."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)

            assert engine.enable_llm_relevance_filter is False


class TestParallelSearchEngineApiKeyCheck:
    """Tests for API key availability checking."""

    def test_api_key_validation_in_shared_function(self):
        """API key filtering is now handled by the shared get_available_engines function.
        See tests/web_search_engines/engines/test_parallel_search_engine.py::TestResolveApiKey."""
        from local_deep_research.web_search_engines.search_engines_config import (
            _resolve_api_key,
        )

        # Valid key
        assert (
            _resolve_api_key("brave", {"api_key": "real-key"}, {}) == "real-key"
        )
        # Missing key
        assert _resolve_api_key("brave", {}, {}) is None
        # Placeholder key
        assert _resolve_api_key("brave", {"api_key": "PLACEHOLDER"}, {}) is None


class TestParallelSearchEngineSelectEngines:
    """Tests for engine selection with LLM."""

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_select_engines_no_llm(self, mock_get_executor):
        """select_engines returns all available when no LLM."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()

        with patch.object(
            ParallelSearchEngine,
            "_get_available_engines",
            return_value=["duckduckgo", "brave", "arxiv"],
        ):
            engine = ParallelSearchEngine(llm=None)
            engine.max_engines_to_select = 2

            result = engine.select_engines("test query")

            assert len(result) == 2
            assert result == ["duckduckgo", "brave"]

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_select_engines_no_available(self, mock_get_executor):
        """select_engines returns empty list when no engines available."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)

            result = engine.select_engines("test query")

            assert result == []

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_select_engines_with_llm(self, mock_get_executor):
        """select_engines uses LLM to select engines."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()
        mock_llm.invoke.return_value = Mock(content="[0, 2]")

        with patch.object(
            ParallelSearchEngine,
            "_get_available_engines",
            return_value=["arxiv", "pubmed", "semantic_scholar"],
        ):
            with patch.object(
                ParallelSearchEngine,
                "_get_available_generic_engines",
                return_value=[],
            ):
                engine = ParallelSearchEngine(
                    llm=mock_llm, include_generic_engines=False
                )

                result = engine.select_engines("machine learning research")

                mock_llm.invoke.assert_called_once()
                assert "arxiv" in result
                assert "semantic_scholar" in result

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_select_engines_adds_generic_engines(self, mock_get_executor):
        """select_engines adds generic engines to selection."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()
        mock_llm.invoke.return_value = Mock(content="[0]")

        with patch.object(
            ParallelSearchEngine,
            "_get_available_engines",
            return_value=["duckduckgo", "arxiv", "pubmed"],
        ):
            with patch.object(
                ParallelSearchEngine,
                "_get_available_generic_engines",
                return_value=["duckduckgo"],
            ):
                engine = ParallelSearchEngine(
                    llm=mock_llm, include_generic_engines=True
                )

                result = engine.select_engines("test query")

                # Should have arxiv (selected) plus duckduckgo (generic)
                assert "duckduckgo" in result

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_select_engines_llm_invalid_response(self, mock_get_executor):
        """select_engines handles invalid LLM response."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()
        mock_llm.invoke.return_value = Mock(content="invalid response")

        with patch.object(
            ParallelSearchEngine,
            "_get_available_engines",
            return_value=["duckduckgo", "brave"],
        ):
            with patch.object(
                ParallelSearchEngine,
                "_get_available_generic_engines",
                return_value=["duckduckgo"],
            ):
                engine = ParallelSearchEngine(llm=mock_llm)

                result = engine.select_engines("test query")

                # Should fallback to available engines
                assert len(result) > 0


class TestParallelSearchEngineEngineInstance:
    """Tests for engine instance management."""

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine.create_search_engine"
    )
    def test_get_engine_instance_creates_new(
        self, mock_create, mock_get_executor
    ):
        """_get_engine_instance creates new engine instance."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()
        mock_engine = Mock()
        mock_create.return_value = mock_engine

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)

            result = engine._get_engine_instance("duckduckgo")

            mock_create.assert_called_once()
            assert result is mock_engine

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine.create_search_engine"
    )
    def test_get_engine_instance_returns_cached(
        self, mock_create, mock_get_executor
    ):
        """_get_engine_instance returns cached instance."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()
        mock_engine = Mock()
        mock_create.return_value = mock_engine

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)

            result1 = engine._get_engine_instance("duckduckgo")
            result2 = engine._get_engine_instance("duckduckgo")

            # Should only create once
            assert mock_create.call_count == 1
            assert result1 is result2

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine.create_search_engine"
    )
    def test_get_engine_instance_handles_creation_error(
        self, mock_create, mock_get_executor
    ):
        """_get_engine_instance handles creation errors."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()
        mock_create.side_effect = Exception("Creation failed")

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)

            result = engine._get_engine_instance("broken_engine")

            assert result is None


class TestParallelSearchEngineExecution:
    """Tests for search execution."""

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_execute_single_engine_success(self, mock_get_executor):
        """_execute_single_engine returns results on success."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()
        mock_engine = Mock()
        mock_engine.run.return_value = [
            {"title": "Result 1", "link": "https://example.com"},
        ]

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)
            engine.engine_cache["test_engine"] = mock_engine

            result = engine._execute_single_engine("test_engine", "test query")

            assert result["success"] is True
            assert result["engine"] == "test_engine"
            assert len(result["results"]) == 1

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_execute_single_engine_no_results(self, mock_get_executor):
        """_execute_single_engine handles no results."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()
        mock_engine = Mock()
        mock_engine.run.return_value = []

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)
            engine.engine_cache["test_engine"] = mock_engine

            result = engine._execute_single_engine("test_engine", "test query")

            assert result["success"] is False
            assert result["error"] == "No results"

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_execute_single_engine_error(self, mock_get_executor):
        """_execute_single_engine handles engine errors."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()
        mock_engine = Mock()
        mock_engine.run.side_effect = Exception("Search failed")

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)
            engine.engine_cache["test_engine"] = mock_engine

            result = engine._execute_single_engine("test_engine", "test query")

            assert result["success"] is False
            assert "failed" in result["error"].lower()

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_execute_single_engine_missing_engine(self, mock_get_executor):
        """_execute_single_engine handles missing engine instance."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            with patch.object(
                ParallelSearchEngine,
                "_get_engine_instance",
                return_value=None,
            ):
                engine = ParallelSearchEngine(llm=mock_llm)

                result = engine._execute_single_engine(
                    "missing_engine", "test query"
                )

                assert result["success"] is False
                assert "initialize" in result["error"].lower()


class TestParallelSearchEnginePreviews:
    """Tests for preview retrieval."""

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine.SocketIOService"
    )
    def test_get_previews_no_engines_selected(
        self, mock_socket, mock_get_executor
    ):
        """_get_previews returns empty list when no engines selected."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            with patch.object(
                ParallelSearchEngine,
                "select_engines",
                return_value=[],
            ):
                engine = ParallelSearchEngine(llm=mock_llm)

                result = engine._get_previews("test query")

                assert result == []

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine.SocketIOService"
    )
    def test_get_previews_no_executor(self, mock_socket, mock_get_executor):
        """_get_previews handles missing executor."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        # Return None for executor
        mock_get_executor.return_value = None
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine,
            "_get_available_engines",
            return_value=["engine1"],
        ):
            with patch.object(
                ParallelSearchEngine,
                "select_engines",
                return_value=["engine1"],
            ):
                engine = ParallelSearchEngine(llm=mock_llm)

                result = engine._get_previews("test query")

                assert result == []


class TestParallelSearchEngineFullContent:
    """Tests for full content retrieval."""

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    @patch("local_deep_research.config.search_config.get_setting_from_snapshot")
    def test_get_full_content_snippets_only(
        self, mock_get_setting, mock_get_executor
    ):
        """_get_full_content returns items as-is in snippets-only mode."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_get_setting.return_value = True  # snippets_only = True
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)

            items = [{"title": "Test", "search_engine": "duckduckgo"}]
            result = engine._get_full_content(items)

            assert result == items

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_get_full_content_groups_by_engine(self, mock_get_executor):
        """_get_full_content groups items by source engine."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()

        mock_engine = Mock()
        mock_engine._get_full_content.return_value = [
            {"title": "Full content", "content": "Full text"},
        ]

        # Provide settings_snapshot with snippets_only = False (simplified format)
        settings_snapshot = {"search.snippets_only": False}

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(
                llm=mock_llm, settings_snapshot=settings_snapshot
            )
            engine.engine_cache["test_engine"] = mock_engine

            items = [
                {"title": "Result 1", "search_engine": "test_engine"},
            ]
            result = engine._get_full_content(items)

            mock_engine._get_full_content.assert_called_once()
            assert len(result) == 1

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    @patch("local_deep_research.config.search_config.get_setting_from_snapshot")
    def test_get_full_content_handles_missing_engine(
        self, mock_get_setting, mock_get_executor
    ):
        """_get_full_content handles missing engine instance."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_get_setting.return_value = False
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            with patch.object(
                ParallelSearchEngine,
                "_get_engine_instance",
                return_value=None,
            ):
                engine = ParallelSearchEngine(llm=mock_llm)

                items = [
                    {"title": "Result 1", "search_engine": "missing_engine"},
                ]
                result = engine._get_full_content(items)

                # Should return items as-is when engine not available
                assert result == items


class TestParallelSearchEngineInvoke:
    """Tests for invoke method."""

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_invoke_calls_run(self, mock_get_executor):
        """invoke() calls run() for compatibility."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm)

            with patch.object(
                engine, "run", return_value=[{"title": "Test"}]
            ) as mock_run:
                result = engine.invoke("test query")

                mock_run.assert_called_once_with("test query")
                assert result == [{"title": "Test"}]


class TestParallelSearchEngineSearchConfig:
    """Tests for search config retrieval."""

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_get_search_config_delegates_to_shared(self, mock_get_executor):
        """_get_search_config delegates to get_available_engines."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()

        expected = {"brave": {"api_key": "test_key"}, "duckduckgo": {}}

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(
                llm=mock_llm,
                settings_snapshot={"search.max_results": 10},
            )

            with patch(
                "local_deep_research.web_search_engines.engines.parallel_search_engine.get_available_engines",
                return_value=expected,
            ):
                config = engine._get_search_config()

            assert "duckduckgo" in config
            assert "brave" in config

    @patch(
        "local_deep_research.web_search_engines.engines.parallel_search_engine._get_global_executor"
    )
    def test_get_search_config_no_snapshot(self, mock_get_executor):
        """_get_search_config returns empty dict without settings."""
        from local_deep_research.web_search_engines.engines.parallel_search_engine import (
            ParallelSearchEngine,
        )

        mock_get_executor.return_value = Mock()
        mock_llm = Mock()

        with patch.object(
            ParallelSearchEngine, "_get_available_engines", return_value=[]
        ):
            engine = ParallelSearchEngine(llm=mock_llm, settings_snapshot=None)

            config = engine._get_search_config()

            assert config == {}
