1313
1414
1515BASE_PATH = Path (__file__ ).parent
16+ TEMPLATE_NAME = "empty"
1617
1718class CLIToolsTest (unittest .TestCase ):
1819 def setUp (self ):
@@ -28,7 +29,7 @@ def tearDown(self):
2829 @unittest .skip ("Dependency resolution issue" )
2930 def test_add_tool (self , tool_name ):
3031 """Test the adding every tool to a project."""
31- result = run_cli ('init' , f"{ tool_name } _project" )
32+ result = run_cli ('init' , f"{ tool_name } _project" , "--template" , TEMPLATE_NAME )
3233 self .assertEqual (result .returncode , 0 )
3334 os .chdir (self .project_dir / f"{ tool_name } _project" )
3435 result = run_cli ('generate' , 'agent' , 'test_agent' , '--llm' , 'opeenai/gpt-4o' )
@@ -67,7 +68,7 @@ def test_get_validated_input(self):
6768 def test_create_tool_basic (self ):
6869 """Test creating a new custom tool via CLI"""
6970 # Initialize a project first
70- result = run_cli ('init' , "test_project" )
71+ result = run_cli ('init' , "test_project" , "--template" , TEMPLATE_NAME )
7172 self .assertEqual (result .returncode , 0 )
7273 os .chdir (self .project_dir / "test_project" )
7374
@@ -76,61 +77,56 @@ def test_create_tool_basic(self):
7677 self .assertEqual (result .returncode , 0 )
7778
7879 # Create a new tool
79- result = run_cli ('tools' , 'create ' , 'test_tool' )
80+ result = run_cli ('tools' , 'new ' , 'test_tool' )
8081 self .assertEqual (result .returncode , 0 )
8182
8283 # Verify tool directory and files were created
83- tool_path = Path ( 'src/tools/test_tool' )
84+ tool_path = self . project_dir / "test_project" / 'src/tools/test_tool'
8485 self .assertTrue (tool_path .exists ())
8586 self .assertTrue ((tool_path / '__init__.py' ).exists ())
8687 self .assertTrue ((tool_path / 'config.json' ).exists ())
8788
8889 def test_create_tool_with_agents (self ):
8990 """Test creating a new custom tool with specific agents via CLI"""
9091 # Initialize project and create multiple agents
91- result = run_cli ('init' , "test_project" )
92+ result = run_cli ('init' , "test_project" , "--template" , TEMPLATE_NAME )
9293 self .assertEqual (result .returncode , 0 )
9394 os .chdir (self .project_dir / "test_project" )
9495
9596 run_cli ('generate' , 'agent' , 'agent1' , '--llm' , 'openai/gpt-4' )
9697 run_cli ('generate' , 'agent' , 'agent2' , '--llm' , 'openai/gpt-4' )
9798
9899 # Create tool with specific agent
99- result = run_cli ('tools' , 'create ' , 'test_tool' , '--agents' , 'agent1' )
100+ result = run_cli ('tools' , 'new ' , 'test_tool' , '--agents' , 'agent1' )
100101 self .assertEqual (result .returncode , 0 )
101102
102103 # Verify tool was created
103- tool_path = Path ( 'src/tools/test_tool' )
104+ tool_path = self . project_dir / "test_project" / 'src/tools/test_tool'
104105 self .assertTrue (tool_path .exists ())
105106
106- # Verify tool was added to correct agent
107- with open ('agentstack.json' ) as f :
108- config = f .read ()
109- self .assertIn ('test_tool' , config )
110-
111107 def test_create_tool_existing (self ):
112108 """Test creating a tool that already exists"""
113109 # Initialize project
114- result = run_cli ('init' , "test_project" )
110+ result = run_cli ('init' , "test_project" , "--template" , TEMPLATE_NAME )
115111 self .assertEqual (result .returncode , 0 )
116112 os .chdir (self .project_dir / "test_project" )
117113
118114 # Create agent
119115 run_cli ('generate' , 'agent' , 'test_agent' , '--llm' , 'openai/gpt-4' )
120116
121117 # Create tool first time
122- result = run_cli ('tools' , 'create ' , 'test_tool' )
118+ result = run_cli ('tools' , 'new ' , 'test_tool' )
123119 self .assertEqual (result .returncode , 0 )
124120
125121 # Try to create same tool again
126- result = run_cli ('tools' , 'create ' , 'test_tool' )
122+ result = run_cli ('tools' , 'new ' , 'test_tool' )
127123 self .assertNotEqual (result .returncode , 0 ) # Should fail
128124 self .assertIn ("already exists" , result .stderr )
129125
130126 def test_create_tool_invalid_name (self ):
131127 """Test creating a tool with invalid name formats"""
132128 # Initialize project
133- result = run_cli ('init' , "test_project" )
129+ result = run_cli ('init' , "test_project" , "--template" , TEMPLATE_NAME )
134130 self .assertEqual (result .returncode , 0 )
135131 os .chdir (self .project_dir / "test_project" )
136132
@@ -148,5 +144,4 @@ def test_create_tool_no_project(self):
148144 """Test creating a tool outside a project directory"""
149145 # Try to create tool without initializing project
150146 result = run_cli ('tools' , 'new' , 'test_tool' )
151- self .assertNotEqual (result .returncode , 0 )
152- self .assertIn ("Could not find agentstack.json" , result .stderr )
147+ self .assertNotEqual (result .returncode , 0 )
0 commit comments