Close workflow smoke template drift

This commit is contained in:
2026-04-18 13:16:54 +02:00
parent 9f1ccec8f0
commit 98455ee579
3 changed files with 507 additions and 0 deletions
@@ -209,6 +209,93 @@ def test_choose_template_backed_output_type_prefers_requested_name():
assert [template["id"] for template in matches] == ["template-1"]
def test_workflow_golden_template_name_maps_cases_to_expected_templates():
module = _load_render_pipeline_script()
assert module.workflow_golden_template_name({"key": "still_graph"}) == "BlenderStudio"
assert module.workflow_golden_template_name({"key": "still_shadow"}) == "BlenderStudio"
assert module.workflow_golden_template_name({"key": "turntable_graph"}) == "Blender_Studio_Schadowcatcher_Anim"
assert module.workflow_golden_template_name({"key": "unknown"}) is None
def test_workflow_smoke_template_name_maps_supported_modes_to_blenderstudio():
module = _load_render_pipeline_script()
assert module.workflow_smoke_template_name("legacy") == "BlenderStudio"
assert module.workflow_smoke_template_name("graph") == "BlenderStudio"
assert module.workflow_smoke_template_name("shadow") == "BlenderStudio"
assert module.workflow_smoke_template_name("turntable") is None
def test_ensure_output_type_render_template_binding_moves_output_type_to_preferred_template():
module = _load_render_pipeline_script()
templates_state = [
{
"id": "template-preferred",
"name": "BlenderStudio",
"is_active": True,
"output_type_ids": ["ot-existing"],
"output_type_id": "ot-existing",
},
{
"id": "template-other",
"name": "Other Template",
"is_active": True,
"output_type_ids": ["ot-golden", "ot-other"],
"output_type_id": "ot-golden",
},
]
patch_calls: list[tuple[str, dict]] = []
class _Response:
def __init__(self, payload: dict):
self.status_code = 200
self._payload = payload
self.text = ""
def json(self):
return self._payload
class _Client:
def patch(self, path: str, **kwargs):
payload = kwargs["json"]
patch_calls.append((path, payload))
template_id = path.rsplit("/", 1)[-1]
template = next(item for item in templates_state if item["id"] == template_id)
template["output_type_ids"] = list(payload["output_type_ids"])
template["output_type_id"] = payload["output_type_ids"][0] if payload["output_type_ids"] else None
return _Response(template)
client = _Client()
original_get_render_templates = module.get_render_templates
try:
module.get_render_templates = lambda _client: [
{
"id": item["id"],
"name": item["name"],
"is_active": item["is_active"],
"output_type_ids": list(item["output_type_ids"]),
"output_type_id": item["output_type_id"],
}
for item in templates_state
]
matches = module.ensure_output_type_render_template_binding(
client,
output_type={"id": "ot-golden", "name": "[Workflow Golden] Canonical Still Graph"},
preferred_template_name="BlenderStudio",
)
finally:
module.get_render_templates = original_get_render_templates
assert patch_calls == [
("/render-templates/template-preferred", {"output_type_ids": ["ot-existing", "ot-golden"]}),
("/render-templates/template-other", {"output_type_ids": ["ot-other"]}),
]
assert [template["name"] for template in matches] == ["BlenderStudio"]
def test_build_output_type_workflow_snapshot_keeps_restore_contract():
module = _load_render_pipeline_script()