Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more tests for CLI commands. #70

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ Adding tools is easy once you understand the project structure. A few things nee
4. Manually test your tool integration by running `agentstack tools add <your_tool>` and ensure it behaves as expected.

## Tests
Gitstar-OC marked this conversation as resolved.
Show resolved Hide resolved
HAHAHAHAHAHAHA good one
Tests are written in `tests` folder with the cli tests being in `tests/test_cli_loads.py`.

Currently some of the tests will not work but you can run the tests by

```
cd tests
python -m unittest discover
Gitstar-OC marked this conversation as resolved.
Show resolved Hide resolved
```
44 changes: 44 additions & 0 deletions tests/test_cli_loads.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,50 @@ def test_init_command(self):

# Clean up
shutil.rmtree(test_dir)
def test_generate_agent_command(self):
Gitstar-OC marked this conversation as resolved.
Show resolved Hide resolved
"""Test the 'generate agent' command."""
agent_name = "test_agent"
result = self.run_cli("generate", "agent", agent_name)
self.assertEqual(result.returncode, 0)
# Verify that the agent is added to agents.yaml
agents_config = Path("src/config/agents.yaml")
self.assertTrue(agents_config.exists())
with open(agents_config, 'r') as f:
content = f.read()
self.assertIn(agent_name, content)

def test_generate_task_command(self):
"""Test the 'generate task' command."""
task_name = "test_task"
result = self.run_cli("generate", "task", task_name)
self.assertEqual(result.returncode, 0)
# Verify that the task is added to tasks.yaml
tasks_config = Path("src/config/tasks.yaml")
self.assertTrue(tasks_config.exists())
with open(tasks_config, 'r') as f:
content = f.read()
self.assertIn(task_name, content)

def test_tools_list_command(self):
"""Test the 'tools list' command."""
result = self.run_cli("tools", "list")
self.assertEqual(result.returncode, 0)
self.assertIn("Available AgentStack Tools:", result.stdout)

def test_tools_add_command(self):
"""Test the 'tools add' command."""
tool_name = "example_tool"
result = self.run_cli("tools", "add", tool_name)
self.assertEqual(result.returncode, 0)
self.assertIn(f"Tool {tool_name} added", result.stdout)
# Clean up: remove the tool
self.run_cli("tools", "remove", tool_name)

def test_run_command(self):
"""Test the 'run' command."""
result = self.run_cli("run")
self.assertEqual(result.returncode, 0)
self.assertIn("Running your agent", result.stdout)


if __name__ == "__main__":
Expand Down