HEL-892: document bounded MiniMax H3 Turbo Image2Video API reference
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
"""Pinned API reference rejects changed audio paths, missing-key repairs and object mutations."""
|
||||
|
||||
import copy
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from calliope.comfyui.fixed_document import DEFINITIONS, canonical
|
||||
from calliope.comfyui.library import build_document
|
||||
from calliope.comfyui.source_reviews import review_for
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
PATH = "example_ComfyUI_workflows/minimax_h3-Turbo_Image2Video_20260813_API.json"
|
||||
RAW = (ROOT / PATH).read_bytes()
|
||||
SOURCE = json.loads(RAW)
|
||||
REVIEW = review_for(PATH, hashlib.sha1(RAW).hexdigest())
|
||||
BLOCK = REVIEW["fixed_version_document"]
|
||||
|
||||
|
||||
def document(source=SOURCE, review=REVIEW):
|
||||
return build_document(PATH, source, None, None, [], review)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("field", BLOCK["fields"], ids=lambda f: f["pointer"])
|
||||
def test_every_saved_input_retains_original_type_and_unique_pointer(field):
|
||||
original = SOURCE[field["node_id"]]["inputs"][field["field"]]
|
||||
assert type(original).__name__ == field["json_type"]
|
||||
assert canonical(original) == canonical(field["value"])
|
||||
assert field["pointer"] == f"/{field['node_id']}/inputs/{field['field']}"
|
||||
assert not {"named_value", "named_pointer", "widget_index"}.intersection(field)
|
||||
assert document()["fixed_version"]["matched"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"mutation",
|
||||
[
|
||||
"seed",
|
||||
"primitive_type",
|
||||
"output_index",
|
||||
"audio",
|
||||
"dict_on",
|
||||
"dict_strength",
|
||||
"last_frame",
|
||||
"title",
|
||||
"mode",
|
||||
"colon_scope",
|
||||
"path_quotes",
|
||||
"path_slashes",
|
||||
"resize_reference",
|
||||
],
|
||||
)
|
||||
def test_source_mutation_cannot_inherit_reference_trust(mutation):
|
||||
g = copy.deepcopy(SOURCE)
|
||||
if mutation == "seed":
|
||||
g["6061:4967"]["inputs"]["noise_seed"] = 43
|
||||
elif mutation == "primitive_type":
|
||||
g["221"]["inputs"]["value"] = 10.0
|
||||
elif mutation == "output_index":
|
||||
g["213"]["inputs"]["latent_image"][1] = 0
|
||||
elif mutation == "audio":
|
||||
g["5978"]["inputs"]["audio"] = ["209", 0]
|
||||
elif mutation == "dict_on":
|
||||
g["6010"]["inputs"]["lora_1"]["on"] = 1
|
||||
elif mutation == "dict_strength":
|
||||
g["6010"]["inputs"]["lora_1"]["strength"] = 1.0
|
||||
elif mutation == "last_frame":
|
||||
g["219"]["inputs"]["last_frame"] = None
|
||||
elif mutation == "title":
|
||||
g["5978"]["_meta"]["title"] = "forged"
|
||||
elif mutation == "mode":
|
||||
g["6059"]["mode"] = 0
|
||||
elif mutation == "path_quotes":
|
||||
g["6078"]["inputs"]["image"] = g["6078"]["inputs"]["image"][1:-1]
|
||||
elif mutation == "path_slashes":
|
||||
g["6078"]["inputs"]["image"] = g["6078"]["inputs"]["image"].replace(chr(92), "/")
|
||||
elif mutation == "resize_reference":
|
||||
g["6008"]["inputs"]["resize_type.longer_size"] = ["115", 0]
|
||||
else:
|
||||
g["6061"] = {"nodes": [g.pop("6061:4969")]}
|
||||
assert not document(g)["fixed_version"]["matched"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("key", ["PowerLoraLoaderHeaderWidget", "lora_1"])
|
||||
def test_complete_objects_are_not_flattened_into_saved_fields(key):
|
||||
field = next(f for f in BLOCK["fields"] if f["node_id"] == "6010" and f["field"] == key)
|
||||
assert field["json_type"] == "dict"
|
||||
assert canonical(field["value"]) == canonical(SOURCE["6010"]["inputs"][key])
|
||||
assert len(BLOCK["fields"]) == 77
|
||||
assert sum(f["json_type"] == "dict" for f in BLOCK["fields"]) == 2
|
||||
|
||||
|
||||
def test_editorial_cannot_replace_code_pin_or_enable_generation():
|
||||
review = copy.deepcopy(REVIEW)
|
||||
review["fixed_version_document"]["fields"][0]["value"] = "forged"
|
||||
assert not document(review=review)["fixed_version"]["matched"]
|
||||
assert DEFINITIONS[PATH] == hashlib.sha256(canonical(BLOCK)).hexdigest()
|
||||
assert not document()["status"]["doc_done"] and not document()["status"]["exec_verified"]
|
||||
|
||||
|
||||
def test_audio_origin_and_declared_missing_input_boundaries_stay_closed():
|
||||
assert SOURCE["5978"]["inputs"]["audio"] == ["6063:4848", 0]
|
||||
assert SOURCE["6063:4848"]["inputs"]["samples"] == ["6061:4973", 1]
|
||||
assert SOURCE["6061:6075"]["inputs"]["audio"] == ["209", 0]
|
||||
assert set(SOURCE["219"]["inputs"]) == {
|
||||
"prompt",
|
||||
"width",
|
||||
"height",
|
||||
"length",
|
||||
"clip",
|
||||
"vae",
|
||||
"first_frame",
|
||||
}
|
||||
assert all(
|
||||
n["scope"] == "root" and not n["implementation_verified"] for n in BLOCK["node_bindings"]
|
||||
)
|
||||
assert BLOCK["sources"] == BLOCK["comments"] == BLOCK["boundaries"] == []
|
||||
|
||||
|
||||
def test_first_frame_is_resized_reference_and_windows_quotes_are_saved_data():
|
||||
assert SOURCE["219"]["inputs"]["first_frame"] == ["6008", 0]
|
||||
assert SOURCE["6008"]["inputs"]["input"] == ["6078", 0]
|
||||
assert SOURCE["6008"]["inputs"]["resize_type.longer_size"] == ["115", 1]
|
||||
assert SOURCE["6078"]["inputs"]["image"].startswith(chr(34))
|
||||
assert SOURCE["6078"]["inputs"]["image"].endswith(chr(34))
|
||||
assert "last_frame" not in SOURCE["219"]["inputs"]
|
||||
Reference in New Issue
Block a user