mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-14 10:38:29 +00:00
Address code review comments and fix lint error
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import unittest
|
||||
|
||||
from crewai import Agent, Task
|
||||
|
||||
|
||||
@@ -30,3 +31,21 @@ class TestTaskInitFix(unittest.TestCase):
|
||||
self.assertIsInstance(task.agent, Agent)
|
||||
self.assertEqual(task.agent.role, "Test Agent")
|
||||
self.assertIs(task.agent, agent_instance)
|
||||
|
||||
def test_task_init_handles_invalid_callable_agent(self):
|
||||
"""Test that the Task.__init__ method correctly handles invalid callable agents."""
|
||||
|
||||
# Create a callable that returns an invalid agent (not an Agent instance)
|
||||
def invalid_callable_agent():
|
||||
return "Not an agent"
|
||||
|
||||
# Create a task with the invalid callable agent
|
||||
with self.assertRaises(ValueError) as context:
|
||||
task = Task(
|
||||
description="Test Task",
|
||||
expected_output="Test Output",
|
||||
agent=invalid_callable_agent
|
||||
)
|
||||
|
||||
# Verify that the error message is correct
|
||||
self.assertIn("Expected BaseAgent instance", str(context.exception))
|
||||
|
||||
Reference in New Issue
Block a user