"""
Tests for advanced_search_system/evidence/evaluator.py

Covers the two unique tests retained after deduplication against
test_evaluator_high_value.py / test_evaluator_pure_logic.py /
test_evaluator_integration.py:
- EvidenceEvaluator stores its model on init
- extract_evidence handles invalid confidence values gracefully
"""

from unittest.mock import Mock


class TestEvidenceEvaluatorInit:
    """Tests for EvidenceEvaluator initialization."""

    def test_init_stores_model(self):
        """Test that model is stored."""
        from local_deep_research.advanced_search_system.evidence.evaluator import (
            EvidenceEvaluator,
        )

        mock_model = Mock()
        evaluator = EvidenceEvaluator(mock_model)

        assert evaluator.model is mock_model


class TestExtractEvidence:
    """Tests for extract_evidence method."""

    def test_extract_evidence_handles_invalid_confidence(self):
        """Test that invalid confidence is handled."""
        from local_deep_research.advanced_search_system.evidence.evaluator import (
            EvidenceEvaluator,
        )
        from local_deep_research.advanced_search_system.constraints.base_constraint import (
            Constraint,
            ConstraintType,
        )

        mock_model = Mock()
        mock_model.invoke.return_value = Mock(
            content="""CLAIM: Test claim
TYPE: inference
SOURCE: Analysis
CONFIDENCE: not_a_number"""
        )

        evaluator = EvidenceEvaluator(mock_model)
        constraint = Constraint(
            id="test",
            type=ConstraintType.PROPERTY,
            value="test",
            description="Test",
        )

        result = evaluator.extract_evidence(
            "search results", "candidate", constraint
        )

        # Should default to 0.5 when parsing fails
        assert result.confidence > 0
