File size: 1,779 Bytes
1c77a4c | 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 | import pytest
from app.agents.synthesizer_agent import SynthesizerAgent
from app.schemas import AgentOutput, Finding, RepoScanResult, Severity
def make_finding(index: int, agent: str = "Docs Agent", severity: Severity = Severity.low) -> Finding:
return Finding(
title=f"Finding {index}",
severity=severity,
file_path=f"file_{index}.py",
line_start=1,
line_end=1,
description="Description",
why_it_matters="Why",
suggested_fix="Fix",
agent_source=agent,
)
@pytest.mark.anyio
async def test_synthesizer_preserves_totals_when_display_is_truncated():
output = AgentOutput(
agent_name="Docs Agent",
findings=[make_finding(index) for index in range(20)],
)
repo = RepoScanResult(repo_url="https://github.com/example/project", local_path=".", files=[], skipped_files=0)
report = await SynthesizerAgent().synthesize(repo, [output])
assert report.total_findings_count == 20
assert report.displayed_findings_count == 8
assert report.hidden_findings_count == 12
assert report.agent_finding_counts["Docs Agent"] == 20
assert any("displaying 8 of 20" in warning for warning in report.warnings)
@pytest.mark.anyio
async def test_synthesizer_keeps_high_severity_before_low_findings():
outputs = [
AgentOutput(agent_name="Docs Agent", findings=[make_finding(1, severity=Severity.low)]),
AgentOutput(agent_name="Security Agent", findings=[make_finding(2, "Security Agent", Severity.high)]),
]
repo = RepoScanResult(repo_url="https://github.com/example/project", local_path=".", files=[], skipped_files=0)
report = await SynthesizerAgent().synthesize(repo, outputs)
assert report.findings[0].severity == Severity.high
|