From fcbb758b2911e77fb37819aa228e999d16ef8b2e Mon Sep 17 00:00:00 2001 From: luciferlinx <129729795+luciferlinx101@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:44:34 +0530 Subject: [PATCH] Added Unit Test (#541) --- tests/unit_tests/jobs/test_agent_executor.py | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/unit_tests/jobs/test_agent_executor.py b/tests/unit_tests/jobs/test_agent_executor.py index 7628ea0a0..41691779c 100644 --- a/tests/unit_tests/jobs/test_agent_executor.py +++ b/tests/unit_tests/jobs/test_agent_executor.py @@ -2,6 +2,8 @@ from unittest.mock import MagicMock from superagi.jobs.agent_executor import AgentExecutor +from superagi.models.tool import Tool +from superagi.tools.file.write_file import WriteFileTool def test_validate_filename(): @@ -9,4 +11,23 @@ def test_validate_filename(): assert AgentExecutor.validate_filename("tool.py") == "tool" # Test when filename doesn't end with ".py" - assert AgentExecutor.validate_filename("tool") == "tool" \ No newline at end of file + assert AgentExecutor.validate_filename("tool") == "tool" + + +def test_create_object(): + # Setup mock objects + tool = Tool() + tool.file_name = "file_toolkit.py" + tool.folder_name = "file" + tool.class_name = "WriteFileTool" + tool.toolkit_id = 1 + + session = MagicMock() + + # Test creating an object + obj = AgentExecutor.create_object(tool, session) + + # Assertions + assert isinstance(obj, WriteFileTool) + assert obj.toolkit_config.session == session + assert obj.toolkit_config.toolkit_id == tool.toolkit_id