2023-04-15 17:04:15 +00:00
|
|
|
import autogpt.agent.agent_manager as agent_manager
|
2023-04-15 21:42:53 +00:00
|
|
|
from autogpt.app import start_agent, list_agents, execute_command
|
2023-04-15 04:34:28 +00:00
|
|
|
import unittest
|
2023-04-15 05:44:42 +00:00
|
|
|
from unittest.mock import patch, MagicMock
|
|
|
|
|
2023-04-15 04:34:28 +00:00
|
|
|
|
|
|
|
class TestCommands(unittest.TestCase):
|
|
|
|
def test_make_agent(self):
|
|
|
|
with patch("openai.ChatCompletion.create") as mock:
|
|
|
|
obj = MagicMock()
|
|
|
|
obj.response.choices[0].messages[0].content = "Test message"
|
|
|
|
mock.return_value = obj
|
2023-04-15 17:04:15 +00:00
|
|
|
start_agent("Test Agent", "chat", "Hello, how are you?", "gpt2")
|
|
|
|
agents = list_agents()
|
2023-04-15 04:42:54 +00:00
|
|
|
self.assertEqual("List of agents:\n0: chat", agents)
|
2023-04-15 17:04:15 +00:00
|
|
|
start_agent("Test Agent 2", "write", "Hello, how are you?", "gpt2")
|
|
|
|
agents = list_agents()
|
2023-04-15 04:42:54 +00:00
|
|
|
self.assertEqual("List of agents:\n0: chat\n1: write", agents)
|