Skip to content

Commit e5b90e1

Browse files
committed
Adds smoke tests for docker images
Adds smoke tests to verify basic functionality of ARC, Arkane, and RMG-Py within the Docker images. These tests ensure that the core components can be imported and that the command-line interfaces are operational. It also checks basic execution capabilities of ARC/Arkane. This provides a quick way to check the health of the docker images after building.
1 parent 5561c64 commit e5b90e1

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import pytest
2+
import subprocess
3+
import tempfile
4+
import pathlib
5+
import textwrap
6+
7+
8+
@pytest.mark.smoke
9+
def test_import_arc():
10+
"""Test that ARC can be imported in the docker image."""
11+
try:
12+
import arc
13+
assert hasattr(arc, '__file__')
14+
except ImportError as e:
15+
pytest.fail(f"ImportError: {e}")
16+
17+
18+
@pytest.mark.smoke
19+
def test_arc_cli_help_runs():
20+
"""Test that ARC CLI help runs in the docker image."""
21+
cmd = ["bash", "-lc", "micromamba run -n arc_env python -m ARC --help || true"]
22+
p = subprocess.run(cmd, capture_output=True, text=True)
23+
# Just ensure it executes and prints usage/help
24+
assert "help" in (p.stdout + p.stderr).lower()
25+
26+
27+
@pytest.mark.smoke
28+
def test_arkane_cli_help_runs():
29+
"""Test that Arkane CLI help runs in the docker image."""
30+
cmd = ["bash", "-lc","micromamba run -n rmg_env python -m arkane --help || true"]
31+
p = subprocess.run(cmd, capture_output=True, text=True)
32+
# Just ensure it executes and prints usage/help
33+
assert "arkane" in (p.stdout + p.stderr).lower()
34+
35+
36+
@pytest.mark.smoke
37+
def test_arc_can_execute_arkane_minimal():
38+
"""Test that ARC can execute Arkane with a minimal input in the docker image."""
39+
arkane_input = textwrap.dedent("""\
40+
#!/usr/bin/env python
41+
modelChemistry = 'wb97m-v/def2-tzvpd' # irrelevant here, just parseable
42+
useHinderedRotors = False
43+
thermo('H2', 'H298')
44+
""")
45+
with tempfile.TemporaryDirectory() as td:
46+
inp = pathlib.Path(td, "input.py")
47+
inp.write_text(arkane_input)
48+
# Call arkane via rmg_env the same way ARC would (subprocess)
49+
cmd = ["bash", "-lc", f"micromamba run -n rmg_env python -m arkane {inp} || true"]
50+
p = subprocess.run(cmd, capture_output=True, text=True)
51+
# We only assert it runs and produces any Arkane header/output (no heavy calc)
52+
assert "arkane" in (p.stdout + p.stderr).lower()
53+
54+
55+
@pytest.mark.smoke
56+
def test_rmgpy_imports():
57+
"""Test that RMG-Py can be imported in the docker image."""
58+
code = r"""
59+
import importlib, sys
60+
m = importlib.import_module('rmgpy')
61+
print('rmgpy OK', getattr(m, '__version__', 'unknown'))
62+
"""
63+
cmd = ["bash", "-lc", f"micromamba run -n rmg_env python - <<'PY'\n{code}\nPY"]
64+
p = subprocess.run(cmd, capture_output=True, text=True)
65+
assert p.returncode == 0, p.stderr
66+
assert "rmgpy OK" in p.stdout
67+
68+
69+
@pytest.mark.smoke
70+
def test_rmg_cli_help_runs():
71+
"""Test that RMG CLI help runs in the docker image."""
72+
cmd = ["bash", "-lc", "micromamba run -n rmg_env rmg --help || true"]
73+
p = subprocess.run(cmd, capture_output=True, text=True)
74+
# Just ensure it executes and prints usage/help
75+
assert "rmg" in (p.stdout + p.stderr).lower()

0 commit comments

Comments
 (0)