File size: 1,866 Bytes
0257d2f 5cac97d 0257d2f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
from unittest.mock import MagicMock
import pytest
from src.utils.models import AssessmentDetails, Citation, Evidence, JudgeAssessment, SearchResult
@pytest.fixture
def mock_search_handler():
"""Return a mock search handler that returns fake evidence."""
mock = MagicMock()
async def mock_execute(query, max_results=10):
return SearchResult(
query=query,
evidence=[
Evidence(
content=f"Evidence content for {query}",
citation=Citation(
source="pubmed",
title=f"Study on {query}",
url="https://pubmed.example.com/123",
date="2025-01-01",
authors=["Doe J"],
),
)
],
sources_searched=["pubmed"],
total_found=1,
errors=[],
)
mock.execute = mock_execute
return mock
@pytest.fixture
def mock_judge_handler():
"""Return a mock judge that always says 'synthesize'."""
mock = MagicMock()
async def mock_assess(question, evidence, iteration=1, max_iterations=10):
return JudgeAssessment(
sufficient=True,
confidence=0.9,
recommendation="synthesize",
details=AssessmentDetails(
mechanism_score=8,
mechanism_reasoning="Strong mechanism found in mock data",
clinical_evidence_score=7,
clinical_reasoning="Good clinical evidence in mock data",
drug_candidates=["MockDrug A"],
key_findings=["Finding 1", "Finding 2"],
),
reasoning="Evidence is sufficient for synthesis.",
next_search_queries=[],
)
mock.assess = mock_assess
return mock
|