forked from agentstack-ai/AgentStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cli_tools.py
More file actions
46 lines (39 loc) · 1.53 KB
/
test_cli_tools.py
File metadata and controls
46 lines (39 loc) · 1.53 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import subprocess
import os, sys
import unittest
from parameterized import parameterized
from pathlib import Path
import shutil
from agentstack.tools import get_all_tool_names
BASE_PATH = Path(__file__).parent
CLI_ENTRY = [
sys.executable,
"-m",
"agentstack.main",
]
# TODO parameterized framework
class CLIToolsTest(unittest.TestCase):
def setUp(self):
self.project_dir = Path(BASE_PATH / 'tmp/cli_tools')
os.makedirs(self.project_dir)
os.chdir(self.project_dir)
def tearDown(self):
shutil.rmtree(self.project_dir)
def _run_cli(self, *args):
"""Helper method to run the CLI with arguments."""
return subprocess.run([*CLI_ENTRY, *args], capture_output=True, text=True)
@parameterized.expand([(x,) for x in get_all_tool_names()])
@unittest.skip("Dependency resolution issue")
def test_add_tool(self, tool_name):
"""Test the adding every tool to a project."""
result = self._run_cli('init', f"{tool_name}_project")
self.assertEqual(result.returncode, 0)
os.chdir(self.project_dir / f"{tool_name}_project")
result = self._run_cli('generate', 'agent', 'test_agent', '--llm', 'opeenai/gpt-4o')
self.assertEqual(result.returncode, 0)
result = self._run_cli('generate', 'task', 'test_task')
self.assertEqual(result.returncode, 0)
result = self._run_cli('tools', 'add', tool_name)
print(result.stdout)
self.assertEqual(result.returncode, 0)
self.assertTrue(self.project_dir.exists())