"""
Behavioral tests for followup_research models.

Tests the FollowUpRequest dataclass.
"""


class TestFollowUpRequestInit:
    """Tests for FollowUpRequest initialization."""

    def test_requires_parent_research_id(self):
        """Requires parent_research_id."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123", question="What about X?"
        )
        assert request.parent_research_id == "abc123"

    def test_requires_question(self):
        """Requires question."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123", question="What about X?"
        )
        assert request.question == "What about X?"

    def test_default_strategy_is_source_based(self):
        """Default strategy is source-based."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123", question="Question"
        )
        assert request.strategy == "source-based"

    def test_accepts_custom_strategy(self):
        """Accepts custom strategy."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123",
            question="Question",
            strategy="deep-dive",
        )
        assert request.strategy == "deep-dive"

    def test_default_max_iterations_is_1(self):
        """Default max_iterations is 1."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123", question="Question"
        )
        assert request.max_iterations == 1

    def test_accepts_custom_max_iterations(self):
        """Accepts custom max_iterations."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123",
            question="Question",
            max_iterations=5,
        )
        assert request.max_iterations == 5

    def test_default_questions_per_iteration_is_3(self):
        """Default questions_per_iteration is 3."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123", question="Question"
        )
        assert request.questions_per_iteration == 3

    def test_accepts_custom_questions_per_iteration(self):
        """Accepts custom questions_per_iteration."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123",
            question="Question",
            questions_per_iteration=5,
        )
        assert request.questions_per_iteration == 5


class TestFollowUpRequestToDict:
    """Tests for FollowUpRequest.to_dict method."""

    def test_returns_dict(self):
        """to_dict returns a dictionary."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123", question="Question"
        )
        result = request.to_dict()
        assert isinstance(result, dict)

    def test_includes_parent_research_id(self):
        """Includes parent_research_id in dict."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123", question="Question"
        )
        result = request.to_dict()
        assert result["parent_research_id"] == "abc123"

    def test_includes_question(self):
        """Includes question in dict."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123", question="What about X?"
        )
        result = request.to_dict()
        assert result["question"] == "What about X?"

    def test_includes_strategy(self):
        """Includes strategy in dict."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123",
            question="Question",
            strategy="deep-dive",
        )
        result = request.to_dict()
        assert result["strategy"] == "deep-dive"

    def test_includes_max_iterations(self):
        """Includes max_iterations in dict."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123", question="Question", max_iterations=5
        )
        result = request.to_dict()
        assert result["max_iterations"] == 5

    def test_includes_questions_per_iteration(self):
        """Includes questions_per_iteration in dict."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123",
            question="Question",
            questions_per_iteration=10,
        )
        result = request.to_dict()
        assert result["questions_per_iteration"] == 10

    def test_dict_has_all_fields(self):
        """Dict has all expected fields."""
        from local_deep_research.followup_research.models import FollowUpRequest

        request = FollowUpRequest(
            parent_research_id="abc123", question="Question"
        )
        result = request.to_dict()
        expected_keys = {
            "parent_research_id",
            "question",
            "strategy",
            "max_iterations",
            "questions_per_iteration",
        }
        assert set(result.keys()) == expected_keys


class TestFollowUpModelsDataclass:
    """Tests for dataclass behavior."""

    def test_request_is_dataclass(self):
        """FollowUpRequest is a dataclass."""
        from dataclasses import is_dataclass

        from local_deep_research.followup_research.models import FollowUpRequest

        assert is_dataclass(FollowUpRequest)

    def test_request_equality(self):
        """FollowUpRequest supports equality comparison."""
        from local_deep_research.followup_research.models import FollowUpRequest

        req1 = FollowUpRequest(
            parent_research_id="abc", question="Q", strategy="s"
        )
        req2 = FollowUpRequest(
            parent_research_id="abc", question="Q", strategy="s"
        )
        assert req1 == req2
