mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-08-13 01:38:41 +00:00
test(flow): make the checkpoint-restore guard actually guard
The test asserted that flow:resumed was absent from feature usage, but that
signal moved onto the Flow Execution span. The assertion could no longer fail,
so a regression that mis-tagged checkpoint restores as resumes would have gone
unnoticed.
Now asserts the resumed attribute, and waits for the handlers: the manual emit
dispatches asynchronously, so the previous shape also read its result before the
listener had run.
Confirmed it discriminates - keying resumed off _is_execution_resuming again
fails it with [('RestoredFlow', True)] == [('RestoredFlow', False)].
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ASfWmW3RGy4qAQm6s8U9jH
This commit is contained in:
@@ -22,6 +22,8 @@ from crewai.flow.flow import Flow, listen, start
|
||||
from crewai.flow.human_feedback import human_feedback
|
||||
from crewai.flow.input_provider import InputResponse
|
||||
|
||||
from ..utils import wait_for_event_handlers
|
||||
|
||||
|
||||
def _reregister_listener() -> None:
|
||||
"""Re-subscribe the global listener to the event bus.
|
||||
@@ -589,9 +591,9 @@ def test_infrastructure_flows_do_not_pollute_outcome_signals(
|
||||
|
||||
|
||||
def test_a_checkpoint_restore_is_not_counted_as_a_resume(
|
||||
features: list[str],
|
||||
starts: list[tuple[str, bool]],
|
||||
) -> None:
|
||||
"""Only a run restored from a human pause counts as resumed.
|
||||
"""Only a run restored from a human pause is marked resumed.
|
||||
|
||||
``_is_execution_resuming`` is also set by checkpoint restores that never
|
||||
paused for anyone. Counting those would push resumes above pauses and make
|
||||
@@ -610,5 +612,6 @@ def test_a_checkpoint_restore_is_not_counted_as_a_resume(
|
||||
assert flow._pending_feedback_context is None
|
||||
|
||||
crewai_event_bus.emit(flow, FlowStartedEvent(flow_name="RestoredFlow"))
|
||||
wait_for_event_handlers()
|
||||
|
||||
assert "flow:resumed" not in features
|
||||
assert starts == [("RestoredFlow", False)]
|
||||
|
||||
Reference in New Issue
Block a user