mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
Add in validation for async cannot depend on other async tasks.
This commit is contained in:
@@ -7,7 +7,6 @@ from unittest.mock import patch
|
||||
|
||||
import pydantic_core
|
||||
import pytest
|
||||
|
||||
from crewai.agent import Agent
|
||||
from crewai.agents.cache import CacheHandler
|
||||
from crewai.crew import Crew
|
||||
@@ -87,6 +86,33 @@ def test_crew_config_conditional_requirement():
|
||||
]
|
||||
|
||||
|
||||
def test_async_task_context_validation():
|
||||
task1 = Task(
|
||||
description="Task 1",
|
||||
async_execution=True,
|
||||
expected_output="output",
|
||||
agent=researcher,
|
||||
)
|
||||
task2 = Task(
|
||||
description="Task 2",
|
||||
async_execution=True,
|
||||
expected_output="output",
|
||||
agent=researcher,
|
||||
context=[task1],
|
||||
)
|
||||
task3 = Task(
|
||||
description="Task 3",
|
||||
expected_output="output",
|
||||
agent=researcher,
|
||||
)
|
||||
|
||||
with pytest.raises(
|
||||
ValueError,
|
||||
match="Task 'Task 2' is asynchronous and cannot include other asynchronous tasks in its context.",
|
||||
):
|
||||
Crew(tasks=[task1, task2, task3], agents=[researcher, writer])
|
||||
|
||||
|
||||
def test_crew_config_with_wrong_keys():
|
||||
no_tasks_config = json.dumps(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user