mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-25 16:18:13 +00:00
feat: change human input for unit testing
added documentation and unit test
This commit is contained in:
@@ -680,3 +680,30 @@ def test_agent_definition_based_on_dict():
|
||||
assert agent.backstory == "test backstory"
|
||||
assert agent.verbose == True
|
||||
assert agent.tools == []
|
||||
|
||||
|
||||
# test for human input
|
||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||
def test_agent_human_input():
|
||||
from unittest.mock import patch
|
||||
|
||||
config = {
|
||||
"role": "test role",
|
||||
"goal": "test goal",
|
||||
"backstory": "test backstory",
|
||||
}
|
||||
|
||||
agent = Agent(config=config)
|
||||
|
||||
task = Task(
|
||||
agent=agent,
|
||||
description="Say the word: Hi",
|
||||
expected_output="The word: Hi",
|
||||
human_input=True,
|
||||
)
|
||||
|
||||
with patch.object(CrewAgentExecutor, "_ask_human_input") as mock_human_input:
|
||||
mock_human_input.return_value = "Hello"
|
||||
output = agent.execute_task(task)
|
||||
mock_human_input.assert_called_once()
|
||||
assert output == "Hello"
|
||||
|
||||
Reference in New Issue
Block a user