Skip to content

Commit

Permalink
Update crew test to validate verbose output and kickoff_for_each method
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
lorenzejay committed Feb 14, 2025
1 parent 43064e2 commit 3e3e68e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tests/crew_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 3e3e68e

Please sign in to comment.