From 2b976e1f63e2593e0fc0a334b15a834a4c05b3cc Mon Sep 17 00:00:00 2001 From: Brandon Hancock Date: Thu, 9 Jan 2025 14:05:24 -0500 Subject: [PATCH] revert back to figure out why tests are timing out --- tests/crew_test.py | 1 - tests/tools/test_tool_usage.py | 180 ++++++++++++++++----------------- 2 files changed, 90 insertions(+), 91 deletions(-) diff --git a/tests/crew_test.py b/tests/crew_test.py index 090caf222..a4b210643 100644 --- a/tests/crew_test.py +++ b/tests/crew_test.py @@ -1464,7 +1464,6 @@ def test_dont_set_agents_step_callback_if_already_set(): @pytest.mark.vcr(filter_headers=["authorization"]) def test_crew_function_calling_llm(): - from unittest.mock import patch from crewai import LLM from crewai.tools import tool diff --git a/tests/tools/test_tool_usage.py b/tests/tools/test_tool_usage.py index 952011339..f450aca2e 100644 --- a/tests/tools/test_tool_usage.py +++ b/tests/tools/test_tool_usage.py @@ -123,111 +123,111 @@ def test_tool_usage_render(): ) -def test_validate_tool_input_booleans_and_none(): - # Create a ToolUsage instance with mocks - tool_usage = ToolUsage( - tools_handler=MagicMock(), - tools=[], - original_tools=[], - tools_description="", - tools_names="", - task=MagicMock(), - function_calling_llm=MagicMock(), - agent=MagicMock(), - action=MagicMock(), - ) +# def test_validate_tool_input_booleans_and_none(): +# # Create a ToolUsage instance with mocks +# tool_usage = ToolUsage( +# tools_handler=MagicMock(), +# tools=[], +# original_tools=[], +# tools_description="", +# tools_names="", +# task=MagicMock(), +# function_calling_llm=MagicMock(), +# agent=MagicMock(), +# action=MagicMock(), +# ) - # Input with booleans and None - tool_input = '{"key1": True, "key2": False, "key3": None}' - expected_arguments = {"key1": True, "key2": False, "key3": None} +# # Input with booleans and None +# tool_input = '{"key1": True, "key2": False, "key3": None}' +# expected_arguments = {"key1": True, "key2": False, "key3": None} - arguments = tool_usage._validate_tool_input(tool_input) - assert arguments == expected_arguments +# arguments = tool_usage._validate_tool_input(tool_input) +# assert arguments == expected_arguments -def test_validate_tool_input_mixed_types(): - # Create a ToolUsage instance with mocks - tool_usage = ToolUsage( - tools_handler=MagicMock(), - tools=[], - original_tools=[], - tools_description="", - tools_names="", - task=MagicMock(), - function_calling_llm=MagicMock(), - agent=MagicMock(), - action=MagicMock(), - ) +# def test_validate_tool_input_mixed_types(): +# # Create a ToolUsage instance with mocks +# tool_usage = ToolUsage( +# tools_handler=MagicMock(), +# tools=[], +# original_tools=[], +# tools_description="", +# tools_names="", +# task=MagicMock(), +# function_calling_llm=MagicMock(), +# agent=MagicMock(), +# action=MagicMock(), +# ) - # Input with mixed types - tool_input = '{"number": 123, "text": "Some text", "flag": True}' - expected_arguments = {"number": 123, "text": "Some text", "flag": True} +# # Input with mixed types +# tool_input = '{"number": 123, "text": "Some text", "flag": True}' +# expected_arguments = {"number": 123, "text": "Some text", "flag": True} - arguments = tool_usage._validate_tool_input(tool_input) - assert arguments == expected_arguments +# arguments = tool_usage._validate_tool_input(tool_input) +# assert arguments == expected_arguments -def test_validate_tool_input_single_quotes(): - # Create a ToolUsage instance with mocks - tool_usage = ToolUsage( - tools_handler=MagicMock(), - tools=[], - original_tools=[], - tools_description="", - tools_names="", - task=MagicMock(), - function_calling_llm=MagicMock(), - agent=MagicMock(), - action=MagicMock(), - ) +# def test_validate_tool_input_single_quotes(): +# # Create a ToolUsage instance with mocks +# tool_usage = ToolUsage( +# tools_handler=MagicMock(), +# tools=[], +# original_tools=[], +# tools_description="", +# tools_names="", +# task=MagicMock(), +# function_calling_llm=MagicMock(), +# agent=MagicMock(), +# action=MagicMock(), +# ) - # Input with single quotes instead of double quotes - tool_input = "{'key': 'value', 'flag': True}" - expected_arguments = {"key": "value", "flag": True} +# # Input with single quotes instead of double quotes +# tool_input = "{'key': 'value', 'flag': True}" +# expected_arguments = {"key": "value", "flag": True} - arguments = tool_usage._validate_tool_input(tool_input) - assert arguments == expected_arguments +# arguments = tool_usage._validate_tool_input(tool_input) +# assert arguments == expected_arguments -def test_validate_tool_input_invalid_json_repairable(): - # Create a ToolUsage instance with mocks - tool_usage = ToolUsage( - tools_handler=MagicMock(), - tools=[], - original_tools=[], - tools_description="", - tools_names="", - task=MagicMock(), - function_calling_llm=MagicMock(), - agent=MagicMock(), - action=MagicMock(), - ) +# def test_validate_tool_input_invalid_json_repairable(): +# # Create a ToolUsage instance with mocks +# tool_usage = ToolUsage( +# tools_handler=MagicMock(), +# tools=[], +# original_tools=[], +# tools_description="", +# tools_names="", +# task=MagicMock(), +# function_calling_llm=MagicMock(), +# agent=MagicMock(), +# action=MagicMock(), +# ) - # Invalid JSON input that can be repaired - tool_input = '{"key": "value", "list": [1, 2, 3,]}' - expected_arguments = {"key": "value", "list": [1, 2, 3]} +# # Invalid JSON input that can be repaired +# tool_input = '{"key": "value", "list": [1, 2, 3,]}' +# expected_arguments = {"key": "value", "list": [1, 2, 3]} - arguments = tool_usage._validate_tool_input(tool_input) - assert arguments == expected_arguments +# arguments = tool_usage._validate_tool_input(tool_input) +# assert arguments == expected_arguments -def test_validate_tool_input_with_special_characters(): - # Create a ToolUsage instance with mocks - tool_usage = ToolUsage( - tools_handler=MagicMock(), - tools=[], - original_tools=[], - tools_description="", - tools_names="", - task=MagicMock(), - function_calling_llm=MagicMock(), - agent=MagicMock(), - action=MagicMock(), - ) +# def test_validate_tool_input_with_special_characters(): +# # Create a ToolUsage instance with mocks +# tool_usage = ToolUsage( +# tools_handler=MagicMock(), +# tools=[], +# original_tools=[], +# tools_description="", +# tools_names="", +# task=MagicMock(), +# function_calling_llm=MagicMock(), +# agent=MagicMock(), +# action=MagicMock(), +# ) - # Input with special characters - tool_input = '{"message": "Hello, world! \u263A", "valid": True}' - expected_arguments = {"message": "Hello, world! ☺", "valid": True} +# # Input with special characters +# tool_input = '{"message": "Hello, world! \u263A", "valid": True}' +# expected_arguments = {"message": "Hello, world! ☺", "valid": True} - arguments = tool_usage._validate_tool_input(tool_input) - assert arguments == expected_arguments +# arguments = tool_usage._validate_tool_input(tool_input) +# assert arguments == expected_arguments