|
2 | 2 | import asyncio |
3 | 3 | import sys |
4 | 4 | import os |
| 5 | +import pytest |
5 | 6 |
|
6 | 7 | # Add project root to sys.path |
7 | 8 | sys.path.append(os.getcwd()) |
8 | 9 |
|
9 | 10 | from plexir.tools.definitions import WebSearchTool, BrowseURLTool |
10 | 11 |
|
11 | | -async def test_tools(): |
12 | | - print("--- Testing WebSearchTool (Fallback) ---") |
| 12 | +@pytest.mark.asyncio |
| 13 | +async def test_web_search_fallback(): |
| 14 | + """Test WebSearchTool fallback (DuckDuckGo).""" |
13 | 15 | search_tool = WebSearchTool() |
14 | 16 | results = await search_tool.run("Python programming") |
15 | | - print(f"Results preview:\n{results[:200]}...") |
16 | | - |
17 | | - print("\n--- Testing BrowseURLTool (Extraction) ---") |
| 17 | + assert "Python" in results |
| 18 | + assert "URL:" in results |
| 19 | + |
| 20 | +@pytest.mark.asyncio |
| 21 | +async def test_browse_url_extraction(): |
| 22 | + """Test BrowseURLTool content extraction.""" |
18 | 23 | browse_tool = BrowseURLTool() |
19 | 24 | # Test with a known static page |
20 | 25 | content = await browse_tool.run("https://www.python.org/about/") |
21 | | - print(f"Extracted content length: {len(content)}") |
22 | | - print(f"Content preview:\n{content[:200]}...") |
| 26 | + assert len(content) > 500 |
| 27 | + assert "Python" in content |
23 | 28 |
|
24 | 29 | if __name__ == "__main__": |
25 | | - asyncio.run(test_tools()) |
| 30 | + # Allow running manually |
| 31 | + async def run_manual(): |
| 32 | + await test_web_search_fallback() |
| 33 | + await test_browse_url_extraction() |
| 34 | + print("Manual tests passed!") |
| 35 | + |
| 36 | + asyncio.run(run_manual()) |
0 commit comments