mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +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
|
from datetime import datetime
|
||||||
|
|
||||||
import pytest
|
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.event_bus import crewai_event_bus
|
||||||
from crewai.events.types.flow_events import (
|
from crewai.events.types.flow_events import (
|
||||||
FlowFinishedEvent,
|
FlowFinishedEvent,
|
||||||
FlowStartedEvent,
|
|
||||||
FlowPlotEvent,
|
FlowPlotEvent,
|
||||||
|
FlowStartedEvent,
|
||||||
MethodExecutionFinishedEvent,
|
MethodExecutionFinishedEvent,
|
||||||
MethodExecutionStartedEvent,
|
MethodExecutionStartedEvent,
|
||||||
)
|
)
|
||||||
|
from crewai.flow.flow import Flow, and_, listen, or_, router, start
|
||||||
|
|
||||||
|
|
||||||
def test_simple_sequential_flow():
|
def test_simple_sequential_flow():
|
||||||
@@ -679,11 +679,11 @@ def test_structured_flow_event_emission():
|
|||||||
assert isinstance(received_events[3], MethodExecutionStartedEvent)
|
assert isinstance(received_events[3], MethodExecutionStartedEvent)
|
||||||
assert received_events[3].method_name == "send_welcome_message"
|
assert received_events[3].method_name == "send_welcome_message"
|
||||||
assert received_events[3].params == {}
|
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 isinstance(received_events[4], MethodExecutionFinishedEvent)
|
||||||
assert received_events[4].method_name == "send_welcome_message"
|
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 received_events[4].result == "Welcome, Anakin!"
|
||||||
|
|
||||||
assert isinstance(received_events[5], FlowFinishedEvent)
|
assert isinstance(received_events[5], FlowFinishedEvent)
|
||||||
@@ -930,8 +930,8 @@ def test_flow_init_with_required_fields_missing_values():
|
|||||||
def step_1(self):
|
def step_1(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
with pytest.raises(Exception):
|
with pytest.raises(ValidationError):
|
||||||
flow = RequiredFieldsFlow()
|
RequiredFieldsFlow()
|
||||||
|
|
||||||
|
|
||||||
def test_flow_init_with_mixed_required_optional_fields():
|
def test_flow_init_with_mixed_required_optional_fields():
|
||||||
|
|||||||
Reference in New Issue
Block a user