File size: 2,115 Bytes
0257d2f
 
e82d9c9
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
62
63
64
65
66
import pytest

from src.orchestrators import Orchestrator
from src.utils.models import OrchestratorConfig


@pytest.mark.asyncio
@pytest.mark.e2e
async def test_simple_mode_completes(mock_search_handler, mock_judge_handler):
    """Verify Simple mode runs without crashing using mocks."""

    config = OrchestratorConfig(max_iterations=2)

    orchestrator = Orchestrator(
        search_handler=mock_search_handler,
        judge_handler=mock_judge_handler,
        config=config,
        enable_analysis=False,
        enable_embeddings=False,
    )

    events = []
    async for event in orchestrator.run("test query"):
        events.append(event)

    # Must complete
    assert any(e.type == "complete" for e in events), "Did not receive complete event"
    # Must not error
    assert not any(e.type == "error" for e in events), "Received error event"

    # Check structure of complete event
    complete_event = next(e for e in events if e.type == "complete")
    # The mock judge returns "MockDrug A" and "Finding 1", ensuring synthesis happens
    assert "MockDrug A" in complete_event.message
    assert "Finding 1" in complete_event.message


@pytest.mark.asyncio
@pytest.mark.e2e
async def test_simple_mode_structure_validation(mock_search_handler, mock_judge_handler):
    """Verify output contains expected structure (citations, headings)."""
    config = OrchestratorConfig(max_iterations=2)
    orchestrator = Orchestrator(
        search_handler=mock_search_handler,
        judge_handler=mock_judge_handler,
        config=config,
        enable_analysis=False,
        enable_embeddings=False,
    )

    events = []
    async for event in orchestrator.run("test query"):
        events.append(event)

    complete_event = next(e for e in events if e.type == "complete")
    report = complete_event.message

    # Check markdown structure
    assert "## Drug Repurposing Analysis" in report
    assert "### Citations" in report
    assert "### Key Findings" in report

    # Check for citations
    assert "Study on test query" in report
    assert "https://pubmed.example.com/123" in report