-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'chemle:main' into main
- Loading branch information
Showing
6 changed files
with
129 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
import pytest | ||
import shlex | ||
import subprocess | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def wrapper(): | ||
""" | ||
A wrapper function that clears the environment variables before each test | ||
and stops the EMLE server after each test. | ||
""" | ||
|
||
# Clear the environment. | ||
|
||
for env in os.environ: | ||
if env.startswith("EMLE_"): | ||
del os.environ[env] | ||
|
||
yield | ||
|
||
# Stop the EMLE server. | ||
process = subprocess.run( | ||
shlex.split("emle-stop"), | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
import pytest | ||
import shlex | ||
import shutil | ||
import subprocess | ||
import tempfile | ||
|
||
|
||
def test_qm_xyz(): | ||
""" | ||
Make sure that an xyz file for the QM region is written when requested. | ||
""" | ||
|
||
with tempfile.TemporaryDirectory() as tmpdir: | ||
# Copy files to temporary directory. | ||
shutil.copyfile("tests/input/adp.parm7", tmpdir + "/adp.parm7") | ||
shutil.copyfile("tests/input/adp.rst7", tmpdir + "/adp.rst7") | ||
shutil.copyfile("tests/input/emle_prod.in", tmpdir + "/emle_prod.in") | ||
|
||
# Set environment variables. | ||
os.environ["EMLE_PORT"] = "12345" | ||
os.environ["EMLE_QM_XYZ_FREQUENCY"] = "2" | ||
|
||
# Create the sander command. | ||
command = "sander -O -i emle_prod.in -p adp.parm7 -c adp.rst7 -o emle.out" | ||
|
||
process = subprocess.run( | ||
shlex.split(command), | ||
cwd=tmpdir, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
|
||
# Make sure that the process exited successfully. | ||
assert process.returncode == 0 | ||
|
||
# Make sure that an xyz file was written. | ||
assert os.path.isfile(tmpdir + "/qm.xyz") | ||
|
||
# Make sure that the file contains the expected number of frames. | ||
with open(tmpdir + "/qm.xyz", "r") as f: | ||
num_frames = 0 | ||
for line in f: | ||
if line.startswith("22"): | ||
num_frames += 1 | ||
assert num_frames == 11 |