@@ -483,6 +483,23 @@ async def test_pipeline_event_notification() -> None:
483483 previous_ts = actual_event .timestamp
484484
485485
486+ @pytest .mark .asyncio
487+ async def test_pipeline_event_notification_error_in_pipeline_run () -> None :
488+ callback = AsyncMock (spec = EventCallbackProtocol )
489+ pipe = Pipeline (callback = callback )
490+ component_a = ComponentAdd ()
491+ component_b = ComponentAdd ()
492+ pipe .add_component (component_a , "a" )
493+ pipe .add_component (component_b , "b" )
494+ pipe .connect ("a" , "b" , {"number1" : "a.result" })
495+
496+ with pytest .raises (PipelineDefinitionError ):
497+ await pipe .run ({"a" : {"number1" : 1 , "number2" : 2 }})
498+ assert len (callback .await_args_list ) == 2
499+ assert callback .await_args_list [0 ][0 ][0 ].event_type == EventType .PIPELINE_STARTED
500+ assert callback .await_args_list [1 ][0 ][0 ].event_type == EventType .PIPELINE_FAILED
501+
502+
486503def test_event_model_no_warning (recwarn : Sized ) -> None :
487504 event = Event (
488505 event_type = EventType .PIPELINE_STARTED ,
@@ -557,10 +574,9 @@ async def test_pipeline_streaming_error_in_pipeline_definition() -> None:
557574 with pytest .raises (PipelineDefinitionError ):
558575 async for e in pipe .stream ({"a" : {"number1" : 1 , "number2" : 2 }}):
559576 events .append (e )
560- # validation happens before pipeline run actually starts
561- # but we have the PIPELINE_FAILED event
562- assert len (events ) == 1
563- assert events [0 ].event_type == EventType .PIPELINE_FAILED
577+ assert len (events ) == 2
578+ assert events [0 ].event_type == EventType .PIPELINE_STARTED
579+ assert events [1 ].event_type == EventType .PIPELINE_FAILED
564580
565581
566582@pytest .mark .asyncio
0 commit comments