Add unit test for testing adding a gent

This commit is contained in:
Gershon Bialer
2023-04-14 21:34:28 -07:00
parent bac898f993
commit 0b4f0f5622

View File

@@ -0,0 +1,13 @@
from autogpt import commands
import unittest
from unittest.mock import patch,MagicMock
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
commands.start_agent("Test Agent", "chat", "Hello, how are you?", "gpt2")
agents = commands.list_agents()
self.assertEqual(agents[0], (0,'chat'))