Skip to content

Commit

Permalink
Added Unit Test (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
luciferlinx101 authored Jun 28, 2023
1 parent 19158a8 commit fcbb758
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/unit_tests/jobs/test_agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,32 @@
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():
# Test when filename ends with ".py"
assert AgentExecutor.validate_filename("tool.py") == "tool"

# Test when filename doesn't end with ".py"
assert AgentExecutor.validate_filename("tool") == "tool"
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

0 comments on commit fcbb758

Please sign in to comment.