Test read file tool.
()
| 11 | |
| 12 | @pytest.mark.asyncio |
| 13 | async def test_read_tool(): |
| 14 | """Test read file tool.""" |
| 15 | print("\n=== Testing ReadTool ===") |
| 16 | |
| 17 | # Create a temp file |
| 18 | with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".txt") as f: |
| 19 | f.write("Hello, World!") |
| 20 | temp_path = f.name |
| 21 | |
| 22 | try: |
| 23 | tool = ReadTool() |
| 24 | result = await tool.execute(path=temp_path) |
| 25 | |
| 26 | assert result.success, f"Read failed: {result.error}" |
| 27 | # ReadTool now returns content with line numbers in format: "LINE_NUMBER|LINE_CONTENT" |
| 28 | assert "Hello, World!" in result.content, f"Content mismatch: {result.content}" |
| 29 | assert "|Hello, World!" in result.content, f"Expected line number format: {result.content}" |
| 30 | print("✅ ReadTool test passed") |
| 31 | finally: |
| 32 | Path(temp_path).unlink() |
| 33 | |
| 34 | |
| 35 | @pytest.mark.asyncio |