Skip to content

Commit

Permalink
setting up packmol tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SamCox822 committed Mar 6, 2024
1 parent 8645e70 commit a3436bd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mdagent/tools/base_tools/preprocess_tools/packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(
):
self.path_registry = path_registry
self.molecules = []
self.file_number = 1
self.file_number = file_number
self.file_description = file_description
self.final_name = None

Expand Down
44 changes: 44 additions & 0 deletions tests/test_packing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os

import pytest

from mdagent.tools.base_tools.preprocess_tools.packing import Molecule, PackmolBox
from mdagent.utils import PathRegistry


@pytest.fixture
def get_registry():
return PathRegistry()


@pytest.fixture
def packmolbox(get_registry):
return PackmolBox(get_registry)


@pytest.fixture
def dummy_molecule():
return Molecule(
filename="water", file_id=100, number_of_molecules=2, instructions=None
)


def test_add_molecule(packmolbox, dummy_molecule):
initial_length = len(packmolbox.molecules)
packmolbox.add_molecule(dummy_molecule)
assert len(packmolbox.molecules) == initial_length + 1


def test_generate_input_header(packmolbox):
packmolbox.generate_input_header()
# assert file packmol.inp exists
assert os.path.isfile("packmol.inp")
os.remove("packmol.inp")


def test_generate_input(packmolbox, dummy_molecule):
packmolbox.add_molecule(dummy_molecule)
output = packmolbox.generate_input()
assert "structure water" in output
assert "number 2" in output
assert "end structure" in output

0 comments on commit a3436bd

Please sign in to comment.