"""
Test evidence-related classes in the advanced search system.
"""

import pytest
from loguru import logger


class TestEvidenceImports:
    """Test that evidence-related classes can be imported."""

    def test_base_evidence_import(self):
        """Test base evidence classes import."""
        try:
            from local_deep_research.advanced_search_system.evidence.base_evidence import (
                Evidence,
                EvidenceType,
            )

            assert Evidence is not None
            assert EvidenceType is not None
            logger.info("Base evidence classes imported successfully")
        except ImportError as e:
            pytest.skip(f"Base evidence classes not available: {e}")

    def test_evidence_evaluator_import(self):
        """Test EvidenceEvaluator import."""
        try:
            from local_deep_research.advanced_search_system.evidence.evaluator import (
                EvidenceEvaluator,
            )

            assert EvidenceEvaluator is not None
        except ImportError as e:
            pytest.skip(f"EvidenceEvaluator not available: {e}")

    def test_requirement_checker_import(self):
        """Test RequirementChecker import."""
        try:
            from local_deep_research.advanced_search_system.evidence.requirements import (
                RequirementChecker,
            )

            assert RequirementChecker is not None
        except ImportError as e:
            pytest.skip(f"RequirementChecker not available: {e}")


class TestCandidateImports:
    """Test candidate-related classes."""

    def test_base_candidate_import(self):
        """Test Candidate class import."""
        try:
            from local_deep_research.advanced_search_system.candidates.base_candidate import (
                Candidate,
            )

            assert Candidate is not None
            logger.info("Candidate class imported successfully")
        except ImportError as e:
            pytest.skip(f"Candidate class not available: {e}")


class TestCandidateExplorationImports:
    """Test candidate exploration module imports."""

    def test_base_explorer_import(self):
        """Test base explorer import."""
        try:
            from local_deep_research.advanced_search_system.candidate_exploration.base_explorer import (
                BaseExplorer,
            )

            assert BaseExplorer is not None
        except ImportError as e:
            pytest.skip(f"BaseExplorer not available: {e}")

    def test_adaptive_explorer_import(self):
        """Test AdaptiveExplorer import."""
        try:
            from local_deep_research.advanced_search_system.candidate_exploration.adaptive_explorer import (
                AdaptiveExplorer,
            )

            assert AdaptiveExplorer is not None
        except ImportError as e:
            pytest.skip(f"AdaptiveExplorer not available: {e}")

    def test_constraint_guided_explorer_import(self):
        """Test ConstraintGuidedExplorer import."""
        try:
            from local_deep_research.advanced_search_system.candidate_exploration.constraint_guided_explorer import (
                ConstraintGuidedExplorer,
            )

            assert ConstraintGuidedExplorer is not None
        except ImportError as e:
            pytest.skip(f"ConstraintGuidedExplorer not available: {e}")

    def test_diversity_explorer_import(self):
        """Test DiversityExplorer import."""
        try:
            from local_deep_research.advanced_search_system.candidate_exploration.diversity_explorer import (
                DiversityExplorer,
            )

            assert DiversityExplorer is not None
        except ImportError as e:
            pytest.skip(f"DiversityExplorer not available: {e}")

    def test_parallel_explorer_import(self):
        """Test ParallelExplorer import."""
        try:
            from local_deep_research.advanced_search_system.candidate_exploration.parallel_explorer import (
                ParallelExplorer,
            )

            assert ParallelExplorer is not None
        except ImportError as e:
            pytest.skip(f"ParallelExplorer not available: {e}")

    def test_progressive_explorer_import(self):
        """Test ProgressiveExplorer import."""
        try:
            from local_deep_research.advanced_search_system.candidate_exploration.progressive_explorer import (
                ProgressiveExplorer,
            )

            assert ProgressiveExplorer is not None
        except ImportError as e:
            pytest.skip(f"ProgressiveExplorer not available: {e}")


class TestFindingsImports:
    """Test findings-related classes."""

    def test_findings_repository_instantiation(self, mock_llm):
        """Test FindingsRepository can be instantiated."""
        from local_deep_research.advanced_search_system.findings.repository import (
            FindingsRepository,
        )

        repo = FindingsRepository(mock_llm)
        assert repo is not None
        logger.info("FindingsRepository instantiated successfully")


class TestFiltersImports:
    """Test filter-related classes."""

    def test_cross_engine_filter_instantiation(self, mock_llm):
        """Test CrossEngineFilter can be instantiated."""
        from local_deep_research.advanced_search_system.filters.cross_engine_filter import (
            CrossEngineFilter,
        )

        filter_instance = CrossEngineFilter(model=mock_llm)
        assert filter_instance is not None
        logger.info("CrossEngineFilter instantiated successfully")


class TestEvidenceEvaluator:
    """Test EvidenceEvaluator functionality."""

    def test_instantiation(self, mock_llm):
        """Test that evaluator can be instantiated."""
        try:
            from local_deep_research.advanced_search_system.evidence.evaluator import (
                EvidenceEvaluator,
            )

            evaluator = EvidenceEvaluator(mock_llm)
            assert evaluator is not None
            logger.info("EvidenceEvaluator instantiated successfully")

        except ImportError as e:
            pytest.skip(f"EvidenceEvaluator not available: {e}")
        except Exception as e:
            pytest.skip(f"EvidenceEvaluator instantiation failed: {e}")
