File size: 1,174 Bytes
a3ecd30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pytest

from app.agents.security_agent import SecurityAgent
from app.agents.synthesizer_agent import SynthesizerAgent
from app.config import Settings
from app.schemas import CodeChunk, RepoScanResult, Severity
from app.services.llm_client import LLMClient


@pytest.mark.anyio
async def test_security_agent_and_synthesizer_return_structured_report():
    chunk = CodeChunk(
        file_path="app.py",
        language="Python",
        line_start=10,
        line_end=10,
        content="API_KEY = '1234567890abcdef'",
    )
    output = await SecurityAgent(LLMClient(Settings())).analyze([chunk])
    repo = RepoScanResult(repo_url="https://github.com/example/project", local_path=".", files=[], skipped_files=0)

    report = await SynthesizerAgent().synthesize(repo, [output])

    assert len(report.findings) == 1
    assert report.findings[0].severity == Severity.high
    assert report.findings[0].file_path == "app.py"
    assert report.findings[0].line_start == 10
    assert report.severity_summary[Severity.high] == 1
    assert report.total_findings_count == 1
    assert report.displayed_findings_count == 1
    assert report.hidden_findings_count == 0