Update crew test to validate verbose output and kickoff_for_each method

- Enhance test_crew_verbose_output to check specific listener log messages
- Modify test_kickoff_for_each_invalid_input to use Pydantic validation error
- Improve test coverage for crew logging and input validation
This commit is contained in:
Lorenze Jay
2025-02-14 08:34:18 -08:00
parent 43064e2a0e
commit 3e3e68ed75

View File

@@ -850,8 +850,21 @@ def test_crew_verbose_output(capsys):
crew.verbose = False
crew._logger = Logger(verbose=False)
crew.kickoff()
expected_listener_logs = [
"[🚀 CREW 'CREW' STARTED]",
"[📋 TASK STARTED: RESEARCH AI ADVANCEMENTS.]",
"[🤖 AGENT 'RESEARCHER' STARTED TASK]",
"[👍 AGENT 'RESEARCHER' COMPLETED TASK]",
"[📋 TASK COMPLETED: RESEARCH AI ADVANCEMENTS.]",
"[📋 TASK STARTED: WRITE ABOUT AI IN HEALTHCARE.]",
"[🤖 AGENT 'SENIOR WRITER' STARTED TASK]",
"[👍 AGENT 'SENIOR WRITER' COMPLETED TASK]",
"[📋 TASK COMPLETED: WRITE ABOUT AI IN HEALTHCARE.]",
"[✅ CREW 'CREW' COMPLETED]"
]
captured = capsys.readouterr()
assert captured.out == ""
for log in expected_listener_logs:
assert log in captured.out
@pytest.mark.vcr(filter_headers=["authorization"])
@@ -1289,9 +1302,9 @@ def test_kickoff_for_each_invalid_input():
crew = Crew(agents=[agent], tasks=[task])
with pytest.raises(TypeError):
with pytest.raises(pydantic_core._pydantic_core.ValidationError):
# Pass a string instead of a list
crew.kickoff_for_each("invalid input")
crew.kickoff_for_each(["invalid input"])
def test_kickoff_for_each_error_handling():