File size: 1,298 Bytes
c6d7a24
4a30717
c6d7a24
 
 
 
 
 
 
 
 
 
 
 
 
4a30717
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# tests/test_formatter.py
import pytest
from modules.formatter import OutputFormatter

def test_format_response_basic():
    formatter = OutputFormatter()
    analysis = "This is a test analysis."
    search_results = [
        {"title": "Test Source 1", "url": "https://example.com/1"},
        {"title": "Test Source 2", "url": "https://example.com/2"},
    ]
    result = formatter.format_response(analysis, search_results)
    assert "## Research Analysis" in result
    assert "## Sources" in result
    assert "Test Source 1" in result
    assert "https://example.com/1" in result

def test_format_response_with_citations():
    formatter = OutputFormatter()
    analysis = "This is a test analysis."
    citations = {
        "[1]": {"title": "Test Source 1", "url": "https://example.com/1", "source": "Test Journal"},
        "[2]": {"title": "Test Source 2", "url": "https://example.com/2", "source": "Test Journal"},
    }
    search_results = [
        {"title": "Test Source 1", "url": "https://example.com/1"},
        {"title": "Test Source 2", "url": "https://example.com/2"},
    ]
    result = formatter.format_response((analysis, citations), search_results)
    assert "## Research Analysis" in result
    assert "## Sources" in result
    assert "## Detailed Citations" in result