Add files via upload
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Basic tests for ComfyUI-HunyuanWorld
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add the parent directory to the path so we can import the module
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
def test_import():
|
||||
"""Test that the module can be imported"""
|
||||
try:
|
||||
import __init__
|
||||
assert True
|
||||
except ImportError as e:
|
||||
pytest.fail(f"Failed to import module: {e}")
|
||||
|
||||
def test_node_mappings():
|
||||
"""Test that node mappings are properly defined"""
|
||||
import __init__
|
||||
|
||||
# Check that NODE_CLASS_MAPPINGS exists and is not empty
|
||||
assert hasattr(__init__, 'NODE_CLASS_MAPPINGS')
|
||||
assert isinstance(__init__.NODE_CLASS_MAPPINGS, dict)
|
||||
assert len(__init__.NODE_CLASS_MAPPINGS) > 0
|
||||
|
||||
# Check that NODE_DISPLAY_NAME_MAPPINGS exists
|
||||
assert hasattr(__init__, 'NODE_DISPLAY_NAME_MAPPINGS')
|
||||
assert isinstance(__init__.NODE_DISPLAY_NAME_MAPPINGS, dict)
|
||||
|
||||
def test_node_classes():
|
||||
"""Test that node classes have required methods"""
|
||||
import __init__
|
||||
|
||||
for node_name, node_class in __init__.NODE_CLASS_MAPPINGS.items():
|
||||
# Check that the class has INPUT_TYPES method
|
||||
assert hasattr(node_class, 'INPUT_TYPES'), f"{node_name} missing INPUT_TYPES"
|
||||
assert callable(getattr(node_class, 'INPUT_TYPES')), f"{node_name} INPUT_TYPES not callable"
|
||||
|
||||
# Check that the class has RETURN_TYPES
|
||||
assert hasattr(node_class, 'RETURN_TYPES'), f"{node_name} missing RETURN_TYPES"
|
||||
|
||||
# Check that the class has FUNCTION
|
||||
assert hasattr(node_class, 'FUNCTION'), f"{node_name} missing FUNCTION"
|
||||
|
||||
# Check that the class has CATEGORY
|
||||
assert hasattr(node_class, 'CATEGORY'), f"{node_name} missing CATEGORY"
|
||||
|
||||
def test_input_types_format():
|
||||
"""Test that INPUT_TYPES returns proper format"""
|
||||
import __init__
|
||||
|
||||
for node_name, node_class in __init__.NODE_CLASS_MAPPINGS.items():
|
||||
input_types = node_class.INPUT_TYPES()
|
||||
|
||||
# Should return a dictionary
|
||||
assert isinstance(input_types, dict), f"{node_name} INPUT_TYPES should return dict"
|
||||
|
||||
# Should have 'required' key
|
||||
assert 'required' in input_types, f"{node_name} INPUT_TYPES missing 'required' key"
|
||||
|
||||
# 'required' should be a dictionary
|
||||
assert isinstance(input_types['required'], dict), f"{node_name} 'required' should be dict"
|
||||
|
||||
def test_graceful_degradation():
|
||||
"""Test that nodes work even without optional dependencies"""
|
||||
import __init__
|
||||
|
||||
# The module should import successfully even if optional dependencies are missing
|
||||
# This is tested by the import test above, but we can add more specific checks here
|
||||
|
||||
# Check that HUNYUAN3D_AVAILABLE flag exists
|
||||
assert hasattr(__init__, 'HUNYUAN3D_AVAILABLE')
|
||||
assert isinstance(__init__.HUNYUAN3D_AVAILABLE, bool)
|
||||
|
||||
# Check that TRIMESH_AVAILABLE flag exists
|
||||
assert hasattr(__init__, 'TRIMESH_AVAILABLE')
|
||||
assert isinstance(__init__.TRIMESH_AVAILABLE, bool)
|
||||
|
||||
# Check that PIL_AVAILABLE flag exists
|
||||
assert hasattr(__init__, 'PIL_AVAILABLE')
|
||||
assert isinstance(__init__.PIL_AVAILABLE, bool)
|
||||
|
||||
def test_node_instantiation():
|
||||
"""Test that nodes can be instantiated"""
|
||||
import __init__
|
||||
|
||||
for node_name, node_class in __init__.NODE_CLASS_MAPPINGS.items():
|
||||
try:
|
||||
# Try to instantiate the node
|
||||
node_instance = node_class()
|
||||
assert node_instance is not None, f"Failed to instantiate {node_name}"
|
||||
except Exception as e:
|
||||
pytest.fail(f"Failed to instantiate {node_name}: {e}")
|
||||
|
||||
def test_display_names():
|
||||
"""Test that display names are properly mapped"""
|
||||
import __init__
|
||||
|
||||
# All nodes should have display names
|
||||
for node_name in __init__.NODE_CLASS_MAPPINGS.keys():
|
||||
assert node_name in __init__.NODE_DISPLAY_NAME_MAPPINGS, f"Missing display name for {node_name}"
|
||||
|
||||
# Display names should be strings
|
||||
display_name = __init__.NODE_DISPLAY_NAME_MAPPINGS[node_name]
|
||||
assert isinstance(display_name, str), f"Display name for {node_name} should be string"
|
||||
assert len(display_name) > 0, f"Display name for {node_name} should not be empty"
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__])
|
||||
Reference in New Issue
Block a user