94 lines
2.9 KiB
Python
94 lines
2.9 KiB
Python
from app.domains.rendering.workflow_config_utils import (
|
|
build_preset_workflow_config,
|
|
canonicalize_workflow_config,
|
|
extract_runtime_workflow,
|
|
)
|
|
|
|
|
|
def test_build_preset_workflow_config_creates_canonical_dag():
|
|
config = build_preset_workflow_config(
|
|
"still",
|
|
{"render_engine": "cycles", "samples": 256, "resolution": [1920, 1080]},
|
|
)
|
|
|
|
assert config["version"] == 1
|
|
assert config["ui"]["preset"] == "still"
|
|
assert [node["step"] for node in config["nodes"]] == [
|
|
"order_line_setup",
|
|
"resolve_template",
|
|
"blender_still",
|
|
"output_save",
|
|
]
|
|
render_node = next(node for node in config["nodes"] if node["step"] == "blender_still")
|
|
assert render_node["params"]["width"] == 1920
|
|
assert render_node["params"]["height"] == 1080
|
|
|
|
|
|
def test_canonicalize_workflow_config_migrates_legacy_preset():
|
|
legacy = {
|
|
"type": "turntable",
|
|
"params": {"render_engine": "cycles", "samples": 64, "fps": 24},
|
|
}
|
|
|
|
canonical = canonicalize_workflow_config(legacy)
|
|
|
|
assert canonical["version"] == 1
|
|
assert canonical["ui"]["preset"] == "turntable"
|
|
assert any(node["step"] == "blender_turntable" for node in canonical["nodes"])
|
|
|
|
|
|
def test_extract_runtime_workflow_uses_canonical_render_node_params():
|
|
config = build_preset_workflow_config(
|
|
"multi_angle",
|
|
{"render_engine": "cycles", "samples": 128, "angles": [0, 45, 90]},
|
|
)
|
|
|
|
preset, params = extract_runtime_workflow(config)
|
|
|
|
assert preset == "multi_angle"
|
|
assert params["render_engine"] == "cycles"
|
|
assert params["samples"] == 128
|
|
assert params["angles"] == [0.0, 45.0, 90.0]
|
|
|
|
|
|
def test_canonicalize_legacy_custom_config_preserves_edges():
|
|
legacy = {
|
|
"type": "custom",
|
|
"nodes": [
|
|
{
|
|
"id": "input",
|
|
"type": "inputNode",
|
|
"position": {"x": 0, "y": 0},
|
|
"data": {"label": "Input", "pipeline_step": "resolve_step_path", "params": {}},
|
|
},
|
|
{
|
|
"id": "render",
|
|
"type": "renderNode",
|
|
"position": {"x": 200, "y": 0},
|
|
"data": {"label": "Render", "pipeline_step": "blender_still", "params": {"resolution": [1024, 1024]}},
|
|
},
|
|
],
|
|
"edges": [
|
|
{"id": "e1", "source": "input", "target": "render"},
|
|
],
|
|
}
|
|
|
|
canonical = canonicalize_workflow_config(legacy)
|
|
|
|
assert canonical["ui"]["preset"] == "custom"
|
|
assert canonical["edges"] == [{"id": "e1", "from": "input", "to": "render"}]
|
|
|
|
|
|
def test_extract_runtime_workflow_converts_resolution_to_dimensions():
|
|
config = build_preset_workflow_config(
|
|
"turntable",
|
|
{"resolution": [1920, 1080], "fps": 24},
|
|
)
|
|
|
|
preset, params = extract_runtime_workflow(config)
|
|
|
|
assert preset == "turntable"
|
|
assert params["width"] == 1920
|
|
assert params["height"] == 1080
|
|
assert "resolution" not in params
|