Skip to content

Commit

Permalink
add test that would previous fail
Browse files Browse the repository at this point in the history
Test would fail if trajectory doesn't update positions
  • Loading branch information
BradyAJohnston committed Jun 11, 2024
1 parent ee3d4cc commit 363bd1d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
import numpy as np
import molecularnodes as mn
from molecularnodes.blender.obj import ObjectTracker
from molecularnodes.blender.obj import ObjectTracker, get_attribute

from .utils import sample_attribute, NumpySnapshotExtension
from .constants import data_dir, codes, attributes
Expand Down Expand Up @@ -90,10 +90,21 @@ def test_op_api_mda(snapshot_custom: NumpySnapshotExtension):
name = "NewTrajectoryInMemory"

obj_2, universe = mn.io.md.load(topo, traj, name="test", style="ribbon")
frames_coll = bpy.data.collections.get(f"{obj_2.name}_frames")

assert not frames_coll
# test the 'frames' collection doesn't exist, as it should only be created when reading
# into memory
assert not bpy.data.collections.get(f"{obj_2.name}_frames")

for mol in [obj_1, obj_2]:
for att in attributes:
assert snapshot_custom == sample_attribute(mol, att)

# capture positions, change the frame number and test that the positions have updated
# and cahnged
pos_1, pos_2 = [get_attribute(x, "position") for x in [obj_1, obj_2]]
bpy.context.scene.frame_set(4)

assert not np.allclose(get_attribute(obj_1, "position"), pos_1)
assert np.allclose(
get_attribute(obj_1, "position"), get_attribute(obj_2, "position")
)

0 comments on commit 363bd1d

Please sign in to comment.