"""Tests de godot_clean_asset_name (pura, offline)."""

import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from core.godot_clean_asset_name import godot_clean_asset_name  # noqa: E402


def test_strips_comfyui_suffix():
    assert godot_clean_asset_name("svd_motion_hi_00001_.webp") == "svd_motion_hi.webp"
    assert godot_clean_asset_name("3d_robot_mesh_00001_.glb") == "3d_robot_mesh.glb"


def test_normalizes_spaces_and_case():
    assert godot_clean_asset_name("My Hero Sprite.PNG") == "my_hero_sprite.png"
    assert godot_clean_asset_name("fire-flare.png") == "fire_flare.png"


def test_takes_basename_from_path():
    assert godot_clean_asset_name("/home/x/ComfyUI/output/bench_00042_.png") == "bench.png"


def test_override_name():
    assert godot_clean_asset_name("svd_00001_.webp", override="explosion loop") == "explosion_loop.webp"
    # override conserva digitos finales (no es sufijo ComfyUI a quitar)
    assert godot_clean_asset_name("x.png", override="hero_v2") == "hero_v2.png"


def test_empty_fallback():
    assert godot_clean_asset_name("_00001_.png") == "asset.png"
