78 lines
2.4 KiB
Python
78 lines
2.4 KiB
Python
from app.domains.rendering.template_input_audit import (
|
|
extract_template_input_marker,
|
|
suggest_workflow_input_schema,
|
|
)
|
|
|
|
|
|
def test_extract_template_input_marker_from_combined_property() -> None:
|
|
marker = extract_template_input_marker(props={"template_input": "studio_variant=warm"})
|
|
assert marker == ("studio_variant", "warm")
|
|
|
|
|
|
def test_extract_template_input_marker_from_json_property() -> None:
|
|
marker = extract_template_input_marker(
|
|
props={"hartomat_template_input": '{"key":"lighting_profile","value":"shadow"}'}
|
|
)
|
|
assert marker == ("lighting_profile", "shadow")
|
|
|
|
|
|
def test_extract_template_input_marker_from_split_properties() -> None:
|
|
marker = extract_template_input_marker(
|
|
props={"template_input_key": "alpha_mode", "template_input_value": "transparent"}
|
|
)
|
|
assert marker == ("alpha_mode", "transparent")
|
|
|
|
|
|
def test_extract_template_input_marker_from_name_pattern() -> None:
|
|
marker = extract_template_input_marker(name="template-input:studio_variant=warm")
|
|
assert marker == ("studio_variant", "warm")
|
|
|
|
|
|
def test_suggest_workflow_input_schema_builds_select_fields() -> None:
|
|
schema = suggest_workflow_input_schema(
|
|
[
|
|
("studio_variant", "warm"),
|
|
("studio_variant", "cool"),
|
|
("alpha_mode", "transparent"),
|
|
("alpha_mode", "opaque"),
|
|
]
|
|
)
|
|
|
|
assert schema == [
|
|
{
|
|
"default": "opaque",
|
|
"key": "alpha_mode",
|
|
"label": "Alpha Mode",
|
|
"options": [
|
|
{"label": "Opaque", "value": "opaque"},
|
|
{"label": "Transparent", "value": "transparent"},
|
|
],
|
|
"section": "Template Inputs",
|
|
"type": "select",
|
|
},
|
|
{
|
|
"default": "cool",
|
|
"key": "studio_variant",
|
|
"label": "Studio Variant",
|
|
"options": [
|
|
{"label": "Cool", "value": "cool"},
|
|
{"label": "Warm", "value": "warm"},
|
|
],
|
|
"section": "Template Inputs",
|
|
"type": "select",
|
|
},
|
|
]
|
|
|
|
|
|
def test_suggest_workflow_input_schema_builds_boolean_field() -> None:
|
|
schema = suggest_workflow_input_schema([("shadow_pass", "true"), ("shadow_pass", "false")])
|
|
assert schema == [
|
|
{
|
|
"default": False,
|
|
"key": "shadow_pass",
|
|
"label": "Shadow Pass",
|
|
"section": "Template Inputs",
|
|
"type": "boolean",
|
|
}
|
|
]
|