Skip to content
Merged
Changes from 6 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
28 changes: 28 additions & 0 deletions imdclient/tests/test_imdclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ def server_client(self, universe, imdsinfo, request):
client.stop()
server.cleanup()

@pytest.fixture
def server_client_incorrect_atoms(self, universe, imdsinfo, port):
server = InThreadIMDServer(universe.trajectory)
server.set_imdsessioninfo(imdsinfo)
server.handshake_sequence("localhost", port, first_frame=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge main and then remove port argument (see PR #94 )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot complete these changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes completed. Removed the port parameter from the fixture and updated it to use server.port instead, following the pattern from PR #94. Also fixed the inconsistent usage of universe.trajectory.n_atoms vs universe.atoms.n_atoms. Commit e9a030d

client = IMDClient(
f"localhost",
port,
universe.atoms.n_atoms + 1,
)
server.join_accept_thread()
yield server, client
client.stop()
server.cleanup()

def test_traj_unchanged(self, server_client, universe):
server, client = server_client
server.send_frames(0, 5)
Expand Down Expand Up @@ -163,6 +178,19 @@ def test_continue_after_disconnect(self, universe, imdsinfo, cont):
IMDHeaderType.IMD_WAIT, expected_length=(int)(not cont)
)

def test_incorrect_atom_count(self, server_client_incorrect_atoms, universe):
server, client = server_client_incorrect_atoms

server.send_frame(0)

with pytest.raises(EOFError) as exc_info:
client.get_imdframe()

error_msg = str(exc_info.value)
assert f"Expected n_atoms value {universe.atoms.n_atoms + 1}" in error_msg
assert f"got {universe.atoms.n_atoms}" in error_msg
assert "Ensure you are using the correct topology file" in error_msg


class TestIMDClientV3ContextManager:
@pytest.fixture
Expand Down
Loading