"""
Pure-logic tests for SmartDecompositionStrategy._is_browsecomp_style.

Tests indicator-phrase counting with the >= 3 threshold,
requiring no LLM or search calls.
"""

from unittest.mock import Mock

from local_deep_research.advanced_search_system.strategies.smart_decomposition_strategy import (
    SmartDecompositionStrategy,
)


class TestIsBrowsecompStyle:
    """Verify BrowseComp-style detection based on indicator phrase counting."""

    def _call(self, query):
        return SmartDecompositionStrategy._is_browsecomp_style(Mock(), query)

    def test_zero_indicators(self):
        """Query with no indicator phrases -> False."""
        assert self._call("What is the capital of France?") is False

    def test_one_indicator(self):
        """Query with one indicator -> False."""
        assert self._call("What is the name of the president?") is False

    def test_two_indicators(self):
        """Query with two indicators -> False (need >= 3)."""
        assert (
            self._call("What is the name of something between two cities?")
            is False
        )

    def test_three_indicators(self):
        """Query with exactly three indicators -> True."""
        query = "What is the name of the specific scenic location where search and rescue operates?"
        assert self._call(query) is True

    def test_many_indicators(self):
        """Query with many indicators -> True."""
        query = (
            "What is the name of the specific scenic location with a viewpoint "
            "where someone fell from during search and rescue SAR incidents "
            "involving a body part since the last ice age?"
        )
        assert self._call(query) is True

    def test_case_insensitive(self):
        """Indicator matching should be case-insensitive."""
        query = "WHAT IS THE NAME of a SPECIFIC SCENIC LOCATION with SEARCH AND RESCUE"
        assert self._call(query) is True
