diff --git a/test_tools.py b/test_tools.py new file mode 100644 index 0000000..9a58897 --- /dev/null +++ b/test_tools.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 +""" +Test script to verify PicoGent tools functionality without requiring API key +""" + +import asyncio +import sys +import os +sys.path.insert(0, '.') + +from picogent.tools.registry import ToolRegistry +from picogent.tools.read import ReadTool +from picogent.tools.write import WriteTool +from picogent.tools.edit import EditTool +from picogent.tools.bash import BashTool + + +async def test_tools(): + """Test all tools individually""" + print("๐Ÿ”ง Testing PicoGent Tools\n") + + # Initialize tools + registry = ToolRegistry() + registry.register(ReadTool()) + registry.register(WriteTool()) + registry.register(EditTool()) + registry.register(BashTool()) + + print(f"โœ“ Registered {len(registry.get_all_tools())} tools") + + # Test 1: Write a file + print("\n๐Ÿ“ Test 1: Writing a file...") + result = await registry.execute_tool("write", { + "file_path": "test_hello.py", + "content": "print('Hello from PicoGent!')\nprint('This is a test file.')\n" + }) + print(result) + + # Test 2: Read the file + print("\n๐Ÿ“– Test 2: Reading the file...") + result = await registry.execute_tool("read", { + "file_path": "test_hello.py" + }) + print(result) + + # Test 3: Edit the file + print("\nโœ๏ธ Test 3: Editing the file...") + result = await registry.execute_tool("edit", { + "file_path": "test_hello.py", + "old_string": "This is a test file.", + "new_string": "This file was edited by PicoGent!" + }) + print(result) + + # Test 4: Read the edited file + print("\n๐Ÿ“– Test 4: Reading the edited file...") + result = await registry.execute_tool("read", { + "file_path": "test_hello.py" + }) + print(result) + + # Test 5: Run the Python file + print("\n๐Ÿš€ Test 5: Executing the Python file...") + result = await registry.execute_tool("bash", { + "command": "python3 test_hello.py", + "timeout": 5 + }) + print(result) + + # Test 6: Clean up + print("\n๐Ÿงน Test 6: Cleaning up...") + result = await registry.execute_tool("bash", { + "command": "rm -f test_hello.py", + "timeout": 5 + }) + print(result) + + print("\nโœ… All tests completed!") + + +if __name__ == "__main__": + asyncio.run(test_tools()) \ No newline at end of file