feat: change human input for unit testing

added documentation and unit test
This commit is contained in:
GabeKoga
2024-04-01 10:01:54 -03:00
parent 1774fe8561
commit a07c255e06
4 changed files with 38 additions and 13 deletions

View File

@@ -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"