test: close workflow phase 3 executor coverage

This commit is contained in:
2026-04-07 10:00:38 +02:00
parent 98b3eadcb2
commit ab1b220e79
4 changed files with 136 additions and 6 deletions
@@ -0,0 +1,130 @@
from __future__ import annotations
from types import SimpleNamespace
from app.core.process_steps import StepName
from app.domains.rendering.workflow_executor import _topological_sort, dispatch_workflow
from app.domains.rendering.workflow_schema import WorkflowConfig
def test_topological_sort_supports_full_phase_3_bridge_sequence():
config = WorkflowConfig.model_validate(
{
"version": 1,
"nodes": [
{"id": "setup", "step": StepName.ORDER_LINE_SETUP.value, "params": {}},
{"id": "template", "step": StepName.RESOLVE_TEMPLATE.value, "params": {}},
{"id": "materials", "step": StepName.MATERIAL_MAP_RESOLVE.value, "params": {}},
{"id": "autofill", "step": StepName.AUTO_POPULATE_MATERIALS.value, "params": {}},
{"id": "bbox", "step": StepName.GLB_BBOX.value, "params": {}},
{"id": "render", "step": StepName.BLENDER_STILL.value, "params": {}},
{"id": "save", "step": StepName.OUTPUT_SAVE.value, "params": {}},
{"id": "notify", "step": StepName.NOTIFY.value, "params": {}},
],
"edges": [
{"from": "setup", "to": "template"},
{"from": "template", "to": "materials"},
{"from": "materials", "to": "autofill"},
{"from": "autofill", "to": "bbox"},
{"from": "bbox", "to": "render"},
{"from": "render", "to": "save"},
{"from": "save", "to": "notify"},
],
}
)
ordered_nodes = _topological_sort(config)
assert [node.id for node in ordered_nodes] == [
"setup",
"template",
"materials",
"autofill",
"bbox",
"render",
"save",
"notify",
]
def test_dispatch_workflow_skips_bridge_nodes_and_dispatches_mapped_render_tasks(monkeypatch):
calls: list[tuple[str, list[str], dict]] = []
def _fake_send_task(task_name: str, args: list[str], kwargs: dict):
calls.append((task_name, args, kwargs))
return SimpleNamespace(id=f"task-{len(calls)}")
monkeypatch.setattr("app.tasks.celery_app.celery_app.send_task", _fake_send_task)
task_ids = dispatch_workflow(
{
"version": 1,
"nodes": [
{"id": "setup", "step": StepName.ORDER_LINE_SETUP.value, "params": {}},
{"id": "template", "step": StepName.RESOLVE_TEMPLATE.value, "params": {}},
{"id": "render", "step": StepName.BLENDER_STILL.value, "params": {"samples": 128}},
{"id": "save", "step": StepName.OUTPUT_SAVE.value, "params": {}},
{"id": "notify", "step": StepName.NOTIFY.value, "params": {}},
],
"edges": [
{"from": "setup", "to": "template"},
{"from": "template", "to": "render"},
{"from": "render", "to": "save"},
{"from": "save", "to": "notify"},
],
},
context_id="line-123",
)
assert task_ids == ["task-1"]
assert calls == [
(
"app.domains.rendering.tasks.render_order_line_still_task",
["line-123"],
{"samples": 128},
)
]
def test_dispatch_workflow_preserves_mapped_task_order_around_phase_3_bridge_nodes(monkeypatch):
calls: list[tuple[str, list[str], dict]] = []
def _fake_send_task(task_name: str, args: list[str], kwargs: dict):
calls.append((task_name, args, kwargs))
return SimpleNamespace(id=f"task-{len(calls)}")
monkeypatch.setattr("app.tasks.celery_app.celery_app.send_task", _fake_send_task)
task_ids = dispatch_workflow(
{
"version": 1,
"nodes": [
{"id": "setup", "step": StepName.ORDER_LINE_SETUP.value, "params": {}},
{"id": "render", "step": StepName.BLENDER_STILL.value, "params": {"width": 1024}},
{"id": "save", "step": StepName.OUTPUT_SAVE.value, "params": {}},
{"id": "export", "step": StepName.EXPORT_BLEND.value, "params": {"include_textures": True}},
{"id": "notify", "step": StepName.NOTIFY.value, "params": {}},
],
"edges": [
{"from": "setup", "to": "render"},
{"from": "render", "to": "save"},
{"from": "save", "to": "export"},
{"from": "export", "to": "notify"},
],
},
context_id="line-456",
)
assert task_ids == ["task-1", "task-2"]
assert calls == [
(
"app.domains.rendering.tasks.render_order_line_still_task",
["line-456"],
{"width": 1024},
),
(
"app.domains.rendering.tasks.export_blend_for_order_line_task",
["line-456"],
{"include_textures": True},
),
]
@@ -19,10 +19,10 @@
### Phase 3
- [ ] Missing legacy steps extracted into reusable executors
- [ ] Extracted node behavior matches legacy services
- [ ] Node-level tests cover success and failure paths
- Progress: `order_line_setup`, `resolve_template`, `material_map_resolve`, `auto_populate_materials`, `glb_bbox`, `output_save`, and `notify` are extracted and covered by targeted backend tests; remaining parity nodes are still open.
- [x] Missing legacy steps extracted into reusable executors
- [x] Extracted node behavior matches legacy services
- [x] Node-level tests cover success and failure paths
- Progress: Phase 3 parity nodes are extracted, covered by targeted runtime tests, and exercised through the workflow executor with legacy-safe bridge dispatch.
### Phase 4
@@ -58,7 +58,7 @@
- `E3-T6` Extract `glb_bbox`. `completed`
- `E3-T7` Extract `output_save`. `completed`
- `E3-T8` Extract `notify`. `completed`
- `E3-T9` Add executor tests for all extracted nodes.
- `E3-T9` Add executor tests for all extracted nodes. `completed`
### Legacy Sources
+1 -1
View File
@@ -8,7 +8,7 @@ Bring `/workflows` to full production parity with the existing legacy render pip
- Phase 1 completed on canonical config storage, preset migration, and legacy-safe runtime extraction.
- Phase 2 completed on backend node registry, node definitions API, and schema-driven editor palette/settings.
- Phase 3 in progress: `order_line_setup`, `resolve_template`, `material_map_resolve`, `auto_populate_materials`, `glb_bbox`, `output_save`, and `notify` are extracted behind the legacy task boundary and validated with targeted backend tests.
- Phase 3 completed: `order_line_setup`, `resolve_template`, `material_map_resolve`, `auto_populate_materials`, `glb_bbox`, `output_save`, and `notify` are extracted behind the legacy task boundary, validated with targeted backend tests, and covered by workflow executor dispatch tests.
## Non-Negotiables