Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

Better test coverage of Agents app (#84)

Dmitrii Khizbullin1d90c702e105
diff --git a/apps/agents/test/test_agents.py b/apps/agents/test/test_agents.py
index a7c413315..5248d5948 100644
--- a/apps/agents/test/test_agents.py
+++ b/apps/agents/test/test_agents.py
@@ -2,7 +2,16 @@ import unittest
import gradio as gr
-from apps.agents.agents import construct_blocks
+from apps.agents.agents import (
+ State,
+ cleanup_on_launch,
+ construct_blocks,
+ parse_arguments,
+ role_playing_chat_cont,
+ role_playing_chat_init,
+ role_playing_start,
+ stop_session,
+)
class TestAgents(unittest.TestCase):
@@ -10,6 +19,40 @@ class TestAgents(unittest.TestCase):
blocks = construct_blocks(None)
self.assertIsInstance(blocks, gr.Blocks)
+ def test_utils(self):
+ args = parse_arguments()
+ self.assertIsNotNone(args)
+
+ def test_session(self):
+ state = State.empty()
+
+ state, _, _ = cleanup_on_launch(state)
+
+ assistant = "professor"
+ user = "PhD student"
+ original_task = "Recommend AI conferences to publish a paper"
+ max_messages = 10
+ with_task_specifier = False
+ word_limit = 50
+ state, specified_task_prompt, planned_task_upd, chat, progress_upd = \
+ role_playing_start(state, assistant, user, original_task,
+ max_messages, with_task_specifier, word_limit)
+
+ self.assertIsNotNone(state.session)
+
+ state, chat, progress_update = \
+ role_playing_chat_init(state)
+
+ self.assertIsNotNone(state.session)
+
+ for _ in range(5):
+ state, chat, progress_update, start_bn_update =\
+ role_playing_chat_cont(state)
+
+ state, _, _ = stop_session(state)
+
+ self.assertIsNone(state.session)
+
if __name__ == '__main__':
unittest.main()
diff --git a/apps/data_explorer/test/test_data_explorer.py b/apps/data_explorer/test/test_data_explorer.py
index c29cf5b60..32cf49ade 100644
--- a/apps/data_explorer/test/test_data_explorer.py
+++ b/apps/data_explorer/test/test_data_explorer.py
@@ -4,7 +4,7 @@ import urllib.request
import gradio as gr
-from apps.data_explorer.data_explorer import construct_blocks
+from apps.data_explorer.data_explorer import construct_blocks, parse_arguments
from apps.data_explorer.loader import REPO_ROOT
@@ -22,6 +22,10 @@ class TestDataExplorer(unittest.TestCase):
self.assertIsInstance(blocks, gr.Blocks)
+ def test_utils(self):
+ args = parse_arguments()
+ self.assertIsNotNone(args)
+
if __name__ == '__main__':
unittest.main()