Added simple PSA import test

Just validates that the actions get imported.
This commit is contained in:
Colin Basnett
2025-04-02 17:34:58 -07:00
parent 6369d4997e
commit 8471cc1996
4 changed files with 46 additions and 0 deletions

BIN
tests/data/Shrek.psa LFS Normal file

Binary file not shown.

BIN
tests/data/Shrek.psk LFS Normal file

Binary file not shown.

39
tests/psa_import_test.py Normal file
View File

@@ -0,0 +1,39 @@
import bpy
import pytest
SHREK_PSK_FILEPATH = 'tests/data/Shrek.psk'
SHREK_PSA_FILEPATH = 'tests/data/Shrek.psa'
@pytest.fixture(autouse=True)
def run_before_and_after_Tests(tmpdir):
# Setup: Run before the tests
bpy.ops.wm.read_homefile(app_template='')
yield
# Teardown: Run after the tests
pass
def test_psa_import_all():
assert bpy.ops.psk.import_file(
filepath=SHREK_PSK_FILEPATH,
components='ALL',
) == {'FINISHED'}, "PSK import failed."
armature_object = bpy.data.objects.get('Shrek', None)
assert armature_object is not None, "Armature object not found in the scene."
assert armature_object.type == 'ARMATURE', "Object is not of type ARMATURE."
# Select the armature object
bpy.context.view_layer.objects.active = armature_object
armature_object.select_set(True)
# Import the associated PSA file with import_all operator.
assert bpy.ops.psa.import_all(
filepath=SHREK_PSA_FILEPATH
) == {'FINISHED'}, "PSA import failed."
# TODO: More thorough tests on the imported data for the animations.
EXPECTED_ACTION_COUNT = 135
assert len(bpy.data.actions) == EXPECTED_ACTION_COUNT, \
f"Expected {EXPECTED_ACTION_COUNT} actions, but found {len(bpy.data.actions)}."

View File

@@ -23,6 +23,7 @@ def test_psk_import_all():
armature_object = bpy.data.objects.get('Suzanne', None) armature_object = bpy.data.objects.get('Suzanne', None)
assert armature_object is not None, "Armature object not found in the scene"
assert armature_object.type == 'ARMATURE', "Armature object type should be ARMATURE" assert armature_object.type == 'ARMATURE', "Armature object type should be ARMATURE"
assert armature_object is not None, "Armature object not found in the scene" assert armature_object is not None, "Armature object not found in the scene"
assert len(armature_object.children) == 1, "Armature object should have one child" assert len(armature_object.children) == 1, "Armature object should have one child"