mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
add more tests back in
This commit is contained in:
@@ -123,111 +123,111 @@ def test_tool_usage_render():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# def test_validate_tool_input_booleans_and_none():
|
def test_validate_tool_input_booleans_and_none():
|
||||||
# # Create a ToolUsage instance with mocks
|
# Create a ToolUsage instance with mocks
|
||||||
# tool_usage = ToolUsage(
|
tool_usage = ToolUsage(
|
||||||
# tools_handler=MagicMock(),
|
tools_handler=MagicMock(),
|
||||||
# tools=[],
|
tools=[],
|
||||||
# original_tools=[],
|
original_tools=[],
|
||||||
# tools_description="",
|
tools_description="",
|
||||||
# tools_names="",
|
tools_names="",
|
||||||
# task=MagicMock(),
|
task=MagicMock(),
|
||||||
# function_calling_llm=MagicMock(),
|
function_calling_llm=MagicMock(),
|
||||||
# agent=MagicMock(),
|
agent=MagicMock(),
|
||||||
# action=MagicMock(),
|
action=MagicMock(),
|
||||||
# )
|
)
|
||||||
|
|
||||||
# # Input with booleans and None
|
# Input with booleans and None
|
||||||
# tool_input = '{"key1": True, "key2": False, "key3": None}'
|
tool_input = '{"key1": True, "key2": False, "key3": None}'
|
||||||
# expected_arguments = {"key1": True, "key2": False, "key3": None}
|
expected_arguments = {"key1": True, "key2": False, "key3": None}
|
||||||
|
|
||||||
# arguments = tool_usage._validate_tool_input(tool_input)
|
arguments = tool_usage._validate_tool_input(tool_input)
|
||||||
# assert arguments == expected_arguments
|
assert arguments == expected_arguments
|
||||||
|
|
||||||
|
|
||||||
# def test_validate_tool_input_mixed_types():
|
def test_validate_tool_input_mixed_types():
|
||||||
# # Create a ToolUsage instance with mocks
|
# Create a ToolUsage instance with mocks
|
||||||
# tool_usage = ToolUsage(
|
tool_usage = ToolUsage(
|
||||||
# tools_handler=MagicMock(),
|
tools_handler=MagicMock(),
|
||||||
# tools=[],
|
tools=[],
|
||||||
# original_tools=[],
|
original_tools=[],
|
||||||
# tools_description="",
|
tools_description="",
|
||||||
# tools_names="",
|
tools_names="",
|
||||||
# task=MagicMock(),
|
task=MagicMock(),
|
||||||
# function_calling_llm=MagicMock(),
|
function_calling_llm=MagicMock(),
|
||||||
# agent=MagicMock(),
|
agent=MagicMock(),
|
||||||
# action=MagicMock(),
|
action=MagicMock(),
|
||||||
# )
|
)
|
||||||
|
|
||||||
# # Input with mixed types
|
# Input with mixed types
|
||||||
# tool_input = '{"number": 123, "text": "Some text", "flag": True}'
|
tool_input = '{"number": 123, "text": "Some text", "flag": True}'
|
||||||
# expected_arguments = {"number": 123, "text": "Some text", "flag": True}
|
expected_arguments = {"number": 123, "text": "Some text", "flag": True}
|
||||||
|
|
||||||
# arguments = tool_usage._validate_tool_input(tool_input)
|
arguments = tool_usage._validate_tool_input(tool_input)
|
||||||
# assert arguments == expected_arguments
|
assert arguments == expected_arguments
|
||||||
|
|
||||||
|
|
||||||
# def test_validate_tool_input_single_quotes():
|
def test_validate_tool_input_single_quotes():
|
||||||
# # Create a ToolUsage instance with mocks
|
# Create a ToolUsage instance with mocks
|
||||||
# tool_usage = ToolUsage(
|
tool_usage = ToolUsage(
|
||||||
# tools_handler=MagicMock(),
|
tools_handler=MagicMock(),
|
||||||
# tools=[],
|
tools=[],
|
||||||
# original_tools=[],
|
original_tools=[],
|
||||||
# tools_description="",
|
tools_description="",
|
||||||
# tools_names="",
|
tools_names="",
|
||||||
# task=MagicMock(),
|
task=MagicMock(),
|
||||||
# function_calling_llm=MagicMock(),
|
function_calling_llm=MagicMock(),
|
||||||
# agent=MagicMock(),
|
agent=MagicMock(),
|
||||||
# action=MagicMock(),
|
action=MagicMock(),
|
||||||
# )
|
)
|
||||||
|
|
||||||
# # Input with single quotes instead of double quotes
|
# Input with single quotes instead of double quotes
|
||||||
# tool_input = "{'key': 'value', 'flag': True}"
|
tool_input = "{'key': 'value', 'flag': True}"
|
||||||
# expected_arguments = {"key": "value", "flag": True}
|
expected_arguments = {"key": "value", "flag": True}
|
||||||
|
|
||||||
# arguments = tool_usage._validate_tool_input(tool_input)
|
arguments = tool_usage._validate_tool_input(tool_input)
|
||||||
# assert arguments == expected_arguments
|
assert arguments == expected_arguments
|
||||||
|
|
||||||
|
|
||||||
# def test_validate_tool_input_invalid_json_repairable():
|
def test_validate_tool_input_invalid_json_repairable():
|
||||||
# # Create a ToolUsage instance with mocks
|
# Create a ToolUsage instance with mocks
|
||||||
# tool_usage = ToolUsage(
|
tool_usage = ToolUsage(
|
||||||
# tools_handler=MagicMock(),
|
tools_handler=MagicMock(),
|
||||||
# tools=[],
|
tools=[],
|
||||||
# original_tools=[],
|
original_tools=[],
|
||||||
# tools_description="",
|
tools_description="",
|
||||||
# tools_names="",
|
tools_names="",
|
||||||
# task=MagicMock(),
|
task=MagicMock(),
|
||||||
# function_calling_llm=MagicMock(),
|
function_calling_llm=MagicMock(),
|
||||||
# agent=MagicMock(),
|
agent=MagicMock(),
|
||||||
# action=MagicMock(),
|
action=MagicMock(),
|
||||||
# )
|
)
|
||||||
|
|
||||||
# # Invalid JSON input that can be repaired
|
# Invalid JSON input that can be repaired
|
||||||
# tool_input = '{"key": "value", "list": [1, 2, 3,]}'
|
tool_input = '{"key": "value", "list": [1, 2, 3,]}'
|
||||||
# expected_arguments = {"key": "value", "list": [1, 2, 3]}
|
expected_arguments = {"key": "value", "list": [1, 2, 3]}
|
||||||
|
|
||||||
# arguments = tool_usage._validate_tool_input(tool_input)
|
arguments = tool_usage._validate_tool_input(tool_input)
|
||||||
# assert arguments == expected_arguments
|
assert arguments == expected_arguments
|
||||||
|
|
||||||
|
|
||||||
# def test_validate_tool_input_with_special_characters():
|
def test_validate_tool_input_with_special_characters():
|
||||||
# # Create a ToolUsage instance with mocks
|
# Create a ToolUsage instance with mocks
|
||||||
# tool_usage = ToolUsage(
|
tool_usage = ToolUsage(
|
||||||
# tools_handler=MagicMock(),
|
tools_handler=MagicMock(),
|
||||||
# tools=[],
|
tools=[],
|
||||||
# original_tools=[],
|
original_tools=[],
|
||||||
# tools_description="",
|
tools_description="",
|
||||||
# tools_names="",
|
tools_names="",
|
||||||
# task=MagicMock(),
|
task=MagicMock(),
|
||||||
# function_calling_llm=MagicMock(),
|
function_calling_llm=MagicMock(),
|
||||||
# agent=MagicMock(),
|
agent=MagicMock(),
|
||||||
# action=MagicMock(),
|
action=MagicMock(),
|
||||||
# )
|
)
|
||||||
|
|
||||||
# # Input with special characters
|
# Input with special characters
|
||||||
# tool_input = '{"message": "Hello, world! \u263A", "valid": True}'
|
tool_input = '{"message": "Hello, world! \u263A", "valid": True}'
|
||||||
# expected_arguments = {"message": "Hello, world! ☺", "valid": True}
|
expected_arguments = {"message": "Hello, world! ☺", "valid": True}
|
||||||
|
|
||||||
# arguments = tool_usage._validate_tool_input(tool_input)
|
arguments = tool_usage._validate_tool_input(tool_input)
|
||||||
# assert arguments == expected_arguments
|
assert arguments == expected_arguments
|
||||||
|
|||||||
Reference in New Issue
Block a user