mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 15:48:29 +00:00
adding extra tests
This commit is contained in:
@@ -32,7 +32,7 @@ class Crew(BaseModel):
|
||||
|
||||
if values.get('config'):
|
||||
config = json.loads(values.get('config'))
|
||||
if not config['agents'] or not config['tasks']:
|
||||
if not config.get('agents') or not config.get('tasks'):
|
||||
raise ValueError('Config should have agents and tasks.')
|
||||
|
||||
values['agents'] = [Agent(**agent) for agent in config['agents']]
|
||||
|
||||
@@ -63,6 +63,32 @@ def test_crew_config_conditional_requirement():
|
||||
assert [agent.role for agent in crew.agents] == [agent['role'] for agent in parsed_config['agents']]
|
||||
assert [task.description for task in crew.tasks] == [task['description'] for task in parsed_config['tasks']]
|
||||
|
||||
def test_crew_config_with_wrong_keys():
|
||||
no_tasks_config = json.dumps({
|
||||
"agents": [
|
||||
{
|
||||
"role": "Senior Researcher",
|
||||
"goal": "Make the best research and analysis on content about AI and AI agents",
|
||||
"backstory": "You're an expert researcher, specialized in technology, software engineering, AI and startups. You work as a freelancer and is now working on doing research and analysis for a new customer."
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
no_agents_config = json.dumps({
|
||||
"tasks": [
|
||||
{
|
||||
"description": "Give me a list of 5 interesting ideas to explore for na article, what makes them unique and interesting.",
|
||||
"agent": "Senior Researcher"
|
||||
}
|
||||
]
|
||||
})
|
||||
with pytest.raises(ValueError):
|
||||
Crew(process=Process.sequential, config='{"wrong_key": "wrong_value"}')
|
||||
with pytest.raises(ValueError):
|
||||
Crew(process=Process.sequential, config=no_tasks_config)
|
||||
with pytest.raises(ValueError):
|
||||
Crew(process=Process.sequential, config=no_agents_config)
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_crew_creation():
|
||||
tasks = [
|
||||
|
||||
Reference in New Issue
Block a user