sudden Code review

This commit is contained in:
lda
2026-05-22 12:35:37 +07:00 Verified
parent d8d5770c9f
commit 4a7f7a5bec
5 changed files with 79 additions and 20 deletions
+40
View File
@@ -64,3 +64,43 @@ def test_foreach_barrier_state_rejects_malformed_metadata() -> None:
with pytest.raises(WorkflowExecutionError, match="next_index"):
ForeachBarrierState.from_frame(frame, "each")
def test_item_error_record_rejects_negative_index() -> None:
with pytest.raises(WorkflowExecutionError, match="index"):
ItemErrorRecord.from_metadata(
{
"index": -1,
"frame_id": "child",
"node_id": "work",
"error_type": "ValueError",
"message": "bad",
}
)
def test_pending_item_result_reports_missing_required_field() -> None:
with pytest.raises(WorkflowExecutionError, match="missing 'frame_id'"):
PendingItemResult.from_metadata({"index": 0, "status": "succeeded"})
def test_pending_item_result_rejects_negative_index() -> None:
with pytest.raises(WorkflowExecutionError, match="index"):
PendingItemResult.from_metadata(
{"index": -1, "frame_id": "child", "status": "succeeded"}
)
def test_save_to_frame_rejects_corrupt_table_without_mutating() -> None:
frame = ExecutionFrame(
id="root",
kind="root",
node_id="each",
metadata={"foreach_barriers": "corrupt"},
)
barrier = ForeachBarrierState(next_index=1)
with pytest.raises(WorkflowExecutionError, match="barrier table"):
barrier.save_to_frame(frame, "each")
assert frame.metadata["foreach_barriers"] == "corrupt"
+8
View File
@@ -96,6 +96,14 @@ def test_blocked_frame_is_not_selectable_until_woken() -> None:
assert selected.id == "parent"
def test_block_frame_on_children_rejects_empty_child_set() -> None:
run = _run()
add_frame(run, ExecutionFrame(id="parent", kind="root", node_id="foreach"))
with pytest.raises(WorkflowExecutionError, match="empty child set"):
block_frame_on_children(run, "parent", ())
def test_create_run_state_queues_root_frame() -> None:
workflow = Workflow(
name="demo",