You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
swarms/tests/structs/test_team.py

53 lines
1.3 KiB

5 months ago
import json
import unittest
4 months ago
from swarm_models import OpenAIChat
5 months ago
from swarms.structs import Agent, Task
from swarms.structs.team import Team
class TestTeam(unittest.TestCase):
def setUp(self):
self.agent = Agent(
llm=OpenAIChat(openai_api_key=""),
max_loops=1,
dashboard=False,
)
self.task = Task(
description="What's the weather in miami",
agent=self.agent,
)
self.team = Team(
tasks=[self.task],
agents=[self.agent],
architecture="sequential",
verbose=False,
)
def test_check_config(self):
with self.assertRaises(ValueError):
self.team.check_config({"config": None})
with self.assertRaises(ValueError):
self.team.check_config(
{"config": json.dumps({"agents": [], "tasks": []})}
)
def test_run(self):
4 months ago
self.assertEqual(self.team.run(), self.task.run())
5 months ago
def test_sequential_loop(self):
self.assertEqual(
4 months ago
self.team._Team__sequential_loop(), self.task.run()
5 months ago
)
def test_log(self):
self.assertIsNone(self.team._Team__log("Test message"))
self.team.verbose = True
self.assertIsNone(self.team._Team__log("Test message"))
if __name__ == "__main__":
unittest.main()