"""Tests de estructura para comfyui_build_view_3d_workflow (funcion pura)."""

import os
import sys

sys.path.insert(0, os.path.dirname(__file__))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))

from ml.comfyui_build_view_3d_workflow import comfyui_build_view_3d_workflow
from _comfyui_wf_assert import assert_api_format, class_types, node_by_ct


def test_load3d_simple():
    wf = comfyui_build_view_3d_workflow("mesh.glb", width=800, height=600)
    assert_api_format(wf)
    # Visor minimo: un unico nodo Load3D.
    assert class_types(wf) == {"Load3D"}
    n = node_by_ct(wf, "Load3D")["inputs"]
    assert n["model_file"] == "mesh.glb"
    assert n["width"] == 800 and n["height"] == 600


def test_animation_usa_load3d_advanced():
    wf = comfyui_build_view_3d_workflow("mesh.glb", animation=True)
    assert class_types(wf) == {"Load3DAdvanced"}
    assert node_by_ct(wf, "Load3DAdvanced")["inputs"]["model_file"] == "mesh.glb"


def test_determinista():
    # Builder puro: misma entrada -> mismo dict (sin red ni estado).
    a = comfyui_build_view_3d_workflow("mesh.glb", width=800, height=600)
    b = comfyui_build_view_3d_workflow("mesh.glb", width=800, height=600)
    assert a == b
