Spaces:
Runtime error
Runtime error
| # 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 |