mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 23:58:34 +00:00
Add test scripts for manual verification
Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
57
simple_test_verbose.py
Normal file
57
simple_test_verbose.py
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Simple test to verify the verbose task name fix works."""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
||||
|
||||
from unittest.mock import Mock
|
||||
from crewai.utilities.events.utils.console_formatter import ConsoleFormatter
|
||||
|
||||
def test_task_display_name():
|
||||
"""Test the _get_task_display_name method directly."""
|
||||
print("Testing _get_task_display_name method...")
|
||||
|
||||
formatter = ConsoleFormatter(verbose=True)
|
||||
|
||||
task1 = Mock()
|
||||
task1.name = "Research Market Trends"
|
||||
task1.id = "12345678-1234-5678-9012-123456789abc"
|
||||
|
||||
result1 = formatter._get_task_display_name(task1)
|
||||
print(f"Test 1 - Task with name: {result1}")
|
||||
assert "Research Market Trends" in result1
|
||||
assert "12345678" in result1
|
||||
print("✅ Test 1 passed")
|
||||
|
||||
task2 = Mock()
|
||||
task2.name = None
|
||||
task2.description = "Analyze current market trends and provide insights"
|
||||
task2.id = "87654321-4321-8765-2109-987654321abc"
|
||||
|
||||
result2 = formatter._get_task_display_name(task2)
|
||||
print(f"Test 2 - Task with description: {result2}")
|
||||
assert "Analyze current market trends" in result2
|
||||
assert "87654321" in result2
|
||||
print("✅ Test 2 passed")
|
||||
|
||||
task3 = Mock()
|
||||
task3.name = None
|
||||
task3.description = None
|
||||
task3.id = "abcdef12-3456-7890-abcd-ef1234567890"
|
||||
|
||||
result3 = formatter._get_task_display_name(task3)
|
||||
print(f"Test 3 - Task with ID only: {result3}")
|
||||
assert result3 == "abcdef12-3456-7890-abcd-ef1234567890"
|
||||
print("✅ Test 3 passed")
|
||||
|
||||
print("\n🎉 All tests passed! The verbose task name fix is working correctly.")
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
test_task_display_name()
|
||||
print("\n✅ Implementation verified successfully!")
|
||||
except Exception as e:
|
||||
print(f"\n❌ Test failed: {e}")
|
||||
sys.exit(1)
|
||||
44
test_verbose_fix.py
Normal file
44
test_verbose_fix.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test script to verify verbose output shows task names instead of IDs."""
|
||||
|
||||
from crewai import Agent, Task, Crew
|
||||
|
||||
def test_verbose_output():
|
||||
"""Test that verbose output shows task names instead of UUIDs."""
|
||||
print("Testing verbose output with task names...")
|
||||
|
||||
agent = Agent(
|
||||
role="Research Analyst",
|
||||
goal="Analyze data and provide insights",
|
||||
backstory="You are an experienced data analyst.",
|
||||
verbose=True
|
||||
)
|
||||
|
||||
task = Task(
|
||||
name="Market Research Analysis",
|
||||
description="Research current market trends in AI technology",
|
||||
expected_output="A comprehensive report on AI market trends",
|
||||
agent=agent
|
||||
)
|
||||
|
||||
crew = Crew(
|
||||
agents=[agent],
|
||||
tasks=[task],
|
||||
verbose=True
|
||||
)
|
||||
|
||||
print("Task name:", task.name)
|
||||
print("Task ID:", task.id)
|
||||
print("\nRunning crew with verbose=True...")
|
||||
print("Expected: Should show task name 'Market Research Analysis' instead of UUID")
|
||||
|
||||
try:
|
||||
result = crew.kickoff()
|
||||
print("\nCrew execution completed successfully!")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Error during execution: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_verbose_output()
|
||||
Reference in New Issue
Block a user