Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions tests/test_animation_deformers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
"""
Test animation and deformer API functionality
"""

import ufbx


def test_scene_has_animation_properties():
"""Test that Scene has animation-related properties"""
assert hasattr(ufbx.Scene, 'anim_stacks')
assert hasattr(ufbx.Scene, 'anim_curves')


def test_scene_has_deformer_properties():
"""Test that Scene has deformer-related properties"""
assert hasattr(ufbx.Scene, 'skin_deformers')
assert hasattr(ufbx.Scene, 'blend_deformers')
assert hasattr(ufbx.Scene, 'blend_shapes')
assert hasattr(ufbx.Scene, 'constraints')


def test_anim_stack_class_has_properties():
"""Test that AnimStack class has expected properties"""
expected_properties = ['name', 'time_begin', 'time_end', 'layers']
for prop in expected_properties:
assert hasattr(ufbx.AnimStack, prop), f"AnimStack missing property: {prop}"


def test_anim_layer_class_has_properties():
"""Test that AnimLayer class has expected properties"""
expected_properties = [
'name', 'weight', 'weight_is_animated', 'blended',
'additive', 'compose_rotation', 'compose_scale'
]
for prop in expected_properties:
assert hasattr(ufbx.AnimLayer, prop), f"AnimLayer missing property: {prop}"


def test_anim_curve_class_has_properties():
"""Test that AnimCurve class has expected properties"""
expected_properties = [
'name', 'num_keyframes', 'min_value', 'max_value',
'min_time', 'max_time'
]
for prop in expected_properties:
assert hasattr(ufbx.AnimCurve, prop), f"AnimCurve missing property: {prop}"


def test_skin_deformer_class_has_properties():
"""Test that SkinDeformer class has expected properties"""
expected_properties = ['name', 'clusters']
for prop in expected_properties:
assert hasattr(ufbx.SkinDeformer, prop), f"SkinDeformer missing property: {prop}"


def test_skin_cluster_class_has_properties():
"""Test that SkinCluster class has expected properties"""
expected_properties = ['name', 'num_weights']
for prop in expected_properties:
assert hasattr(ufbx.SkinCluster, prop), f"SkinCluster missing property: {prop}"


def test_blend_deformer_class_has_properties():
"""Test that BlendDeformer class has expected properties"""
expected_properties = ['name', 'channels']
for prop in expected_properties:
assert hasattr(ufbx.BlendDeformer, prop), f"BlendDeformer missing property: {prop}"


def test_blend_channel_class_has_properties():
"""Test that BlendChannel class has expected properties"""
expected_properties = ['name', 'weight']
for prop in expected_properties:
assert hasattr(ufbx.BlendChannel, prop), f"BlendChannel missing property: {prop}"


def test_blend_shape_class_has_properties():
"""Test that BlendShape class has expected properties"""
expected_properties = ['name', 'num_offsets']
for prop in expected_properties:
assert hasattr(ufbx.BlendShape, prop), f"BlendShape missing property: {prop}"


def test_constraint_class_has_properties():
"""Test that Constraint class has expected properties"""
expected_properties = ['name', 'type', 'weight', 'active']
for prop in expected_properties:
assert hasattr(ufbx.Constraint, prop), f"Constraint missing property: {prop}"


def test_all_animation_deformer_classes_are_elements():
"""Test that all animation/deformer classes are subclasses of Element"""
assert issubclass(ufbx.AnimStack, ufbx.Element)
assert issubclass(ufbx.AnimLayer, ufbx.Element)
assert issubclass(ufbx.AnimCurve, ufbx.Element)
assert issubclass(ufbx.SkinDeformer, ufbx.Element)
assert issubclass(ufbx.SkinCluster, ufbx.Element)
assert issubclass(ufbx.BlendDeformer, ufbx.Element)
assert issubclass(ufbx.BlendChannel, ufbx.Element)
assert issubclass(ufbx.BlendShape, ufbx.Element)
assert issubclass(ufbx.Constraint, ufbx.Element)


if __name__ == "__main__":
import sys

test_functions = [
test_scene_has_animation_properties,
test_scene_has_deformer_properties,
test_anim_stack_class_has_properties,
test_anim_layer_class_has_properties,
test_anim_curve_class_has_properties,
test_skin_deformer_class_has_properties,
test_skin_cluster_class_has_properties,
test_blend_deformer_class_has_properties,
test_blend_channel_class_has_properties,
test_blend_shape_class_has_properties,
test_constraint_class_has_properties,
test_all_animation_deformer_classes_are_elements,
]

failed = 0
for test_func in test_functions:
try:
test_func()
print(f"✓ {test_func.__name__}")
except Exception as e:
print(f"✗ {test_func.__name__}: {e}")
failed += 1

print(f"\n{len(test_functions) - failed}/{len(test_functions)} tests passed")
sys.exit(0 if failed == 0 else 1)
95 changes: 95 additions & 0 deletions tests/test_new_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"""
Test new API functionality for Light, Camera, Bone, and Texture
"""

import ufbx


def test_scene_has_new_properties():
"""Test that Scene has the new properties"""
# We can't test with real FBX data without files, but we can verify
# the properties exist and are callable
assert hasattr(ufbx.Scene, 'lights')
assert hasattr(ufbx.Scene, 'cameras')
assert hasattr(ufbx.Scene, 'bones')
assert hasattr(ufbx.Scene, 'textures')


def test_node_has_new_properties():
"""Test that Node has the new properties"""
assert hasattr(ufbx.Node, 'light')
assert hasattr(ufbx.Node, 'camera')
assert hasattr(ufbx.Node, 'bone')


def test_light_class_has_properties():
"""Test that Light class has expected properties"""
expected_properties = [
'name', 'color', 'intensity', 'local_direction',
'type', 'decay', 'area_shape', 'inner_angle',
'outer_angle', 'cast_light', 'cast_shadows'
]
for prop in expected_properties:
assert hasattr(ufbx.Light, prop), f"Light missing property: {prop}"


def test_camera_class_has_properties():
"""Test that Camera class has expected properties"""
expected_properties = [
'name', 'projection_mode', 'resolution', 'resolution_is_pixels',
'field_of_view_deg', 'field_of_view_tan', 'orthographic_extent',
'orthographic_size', 'aspect_ratio', 'near_plane', 'far_plane'
]
for prop in expected_properties:
assert hasattr(ufbx.Camera, prop), f"Camera missing property: {prop}"


def test_bone_class_has_properties():
"""Test that Bone class has expected properties"""
expected_properties = ['name', 'radius', 'relative_length', 'is_root']
for prop in expected_properties:
assert hasattr(ufbx.Bone, prop), f"Bone missing property: {prop}"


def test_texture_class_has_properties():
"""Test that Texture class has expected properties"""
expected_properties = [
'name', 'filename', 'absolute_filename',
'relative_filename', 'type'
]
for prop in expected_properties:
assert hasattr(ufbx.Texture, prop), f"Texture missing property: {prop}"


def test_light_camera_bone_are_elements():
"""Test that Light, Camera, and Bone are subclasses of Element"""
assert issubclass(ufbx.Light, ufbx.Element)
assert issubclass(ufbx.Camera, ufbx.Element)
assert issubclass(ufbx.Bone, ufbx.Element)
assert issubclass(ufbx.Texture, ufbx.Element)


if __name__ == "__main__":
import sys

test_functions = [
test_scene_has_new_properties,
test_node_has_new_properties,
test_light_class_has_properties,
test_camera_class_has_properties,
test_bone_class_has_properties,
test_texture_class_has_properties,
test_light_camera_bone_are_elements,
]

failed = 0
for test_func in test_functions:
try:
test_func()
print(f"✓ {test_func.__name__}")
except Exception as e:
print(f"✗ {test_func.__name__}: {e}")
failed += 1

print(f"\n{len(test_functions) - failed}/{len(test_functions)} tests passed")
sys.exit(0 if failed == 0 else 1)
Loading