mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 15:48:29 +00:00
Fix lint issues in test_flow.py
- Add ValidationError import from pydantic - Use ValidationError instead of generic Exception in test - Remove unused flow variable - Apply ruff formatting (import ordering and getattr simplification) Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -4,17 +4,17 @@ import asyncio
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, ValidationError
|
||||
|
||||
from crewai.flow.flow import Flow, and_, listen, or_, router, start
|
||||
from crewai.events.event_bus import crewai_event_bus
|
||||
from crewai.events.types.flow_events import (
|
||||
FlowFinishedEvent,
|
||||
FlowStartedEvent,
|
||||
FlowPlotEvent,
|
||||
FlowStartedEvent,
|
||||
MethodExecutionFinishedEvent,
|
||||
MethodExecutionStartedEvent,
|
||||
)
|
||||
from crewai.flow.flow import Flow, and_, listen, or_, router, start
|
||||
|
||||
|
||||
def test_simple_sequential_flow():
|
||||
@@ -679,11 +679,11 @@ def test_structured_flow_event_emission():
|
||||
assert isinstance(received_events[3], MethodExecutionStartedEvent)
|
||||
assert received_events[3].method_name == "send_welcome_message"
|
||||
assert received_events[3].params == {}
|
||||
assert getattr(received_events[3].state, "sent") is False
|
||||
assert received_events[3].state.sent is False
|
||||
|
||||
assert isinstance(received_events[4], MethodExecutionFinishedEvent)
|
||||
assert received_events[4].method_name == "send_welcome_message"
|
||||
assert getattr(received_events[4].state, "sent") is True
|
||||
assert received_events[4].state.sent is True
|
||||
assert received_events[4].result == "Welcome, Anakin!"
|
||||
|
||||
assert isinstance(received_events[5], FlowFinishedEvent)
|
||||
@@ -930,8 +930,8 @@ def test_flow_init_with_required_fields_missing_values():
|
||||
def step_1(self):
|
||||
pass
|
||||
|
||||
with pytest.raises(Exception):
|
||||
flow = RequiredFieldsFlow()
|
||||
with pytest.raises(ValidationError):
|
||||
RequiredFieldsFlow()
|
||||
|
||||
|
||||
def test_flow_init_with_mixed_required_optional_fields():
|
||||
|
||||
Reference in New Issue
Block a user