Skip to content

Commit

Permalink
Add test for cli
Browse files Browse the repository at this point in the history
  • Loading branch information
ralf-meyer committed Nov 11, 2023
1 parent 3ae9f04 commit 69d5b63
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 1 deletion.
2 changes: 1 addition & 1 deletion molSimplify/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def main(args=None):
parser = argparse.ArgumentParser(description=DescString_basic,
formatter_class=argparse.RawDescriptionHelpFormatter)
parseinputs_basic(parser)
exit()
return
# ## run with gui ###
elif gui and len(args) == 0:
print('molSimplify is starting!')
Expand Down
22 changes: 22 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
from molSimplify.__main__ import main


def test_main_empty(tmpdir, resource_path_root):
main(args=[f"-rundir {tmpdir}"])
with open(tmpdir / "fe_oct_2_water_6_s_5" /
"fe_oct_2_water_6_s_5_conf_1" /
"fe_oct_2_water_6_s_5_conf_1.report", "r") as fin:
lines = fin.readlines()
with open(resource_path_root / "refs" / "test_cli" /
"fe_oct_2_water_6_s_5_conf_1.report", "r") as fin:
lines_ref = fin.readlines()
assert lines == lines_ref


@pytest.mark.skip("Test for help not working yet.")
def test_help(capsys):
main(args=["--help",])
captured = capsys.readouterr()
print(captured.out)
assert "Welcome to molSimplify. Only basic usage is described here." in captured.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Input file generated from molSimplify at 11/10/2023 22:28
-checkdirb True
-core Fe
-oxstate 2
-coord 6
-geometry oct
-lig water
-ligocc 6
-spin 5
-keepHs auto
-rundir /private/var/folders/l6/1j71dcgj4j7c_vc466yjsq3r0000gn/T/pytest-of-ralf/pytest-5/test_main0
-ffoption N
-nconfs 1
-charge 2
-calccharge True
-distort 0
-qccode terachem
-runtyp energy
-method b3lyp
-basis lacvps_ecp
-jsched sge
-bcharge 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Bad structure?, False
Min_dist (A), 1000
Was ANN used?, True
geo_label, 1
geo_prob, 0.830863893032074
geo_LSE, 0.056454913968045105
geo_label_trust, very high
sc_label, 1
sc_prob, 0.7422247529029846
sc_LSE, 0.0010312223992481981
sc_label_trust, very high
split, -24.547232997490973
split_dist, 3.5700187674544474e-15
This spin, 5
ANN_ground_state, 5
homo, -14.943396781167465
gap, 4.31362875686047
homo_dist, 0.17068386
gap_dist, 0.0
ANN_bondl, [2.1664019408351636, 2.1664019408351636, 2.1664019408351636, 2.1664019408351636, 2.134863201844001, 2.1218319126203653]
homo_trust, high
gap_trust, high
split_trust, high
Was Catalytic ANN used?, False
Catalytic ANN reason, False
ML-bl (database, A), 2.12
21 changes: 21 additions & 0 deletions tests/testresources/refs/test_cli/fe_oct_2_water_6_s_5_conf_1.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
19
11/10/2023 22:23, XYZ structure generated by mol3D Class, molSimplify
Fe 0.000000 0.000000 0.000000
O 0.000000 2.120000 0.000000
H 0.685027 2.726198 -0.379294
H -0.685027 2.726184 0.379294
O 2.120000 0.000000 0.000000
H 2.726198 -0.671373 -0.402970
H 2.726184 0.671373 0.402970
O 0.000000 -2.120000 0.000000
H -0.656900 -2.726198 -0.426155
H 0.656900 -2.726184 0.426155
O -2.120000 0.000000 0.000000
H -2.726198 0.641627 -0.448821
H -2.726184 -0.641627 0.448821
O 0.000000 0.000000 2.120000
H -0.470940 0.625573 2.726198
H 0.470940 -0.625573 2.726184
O 0.000000 0.000000 -2.120000
H 0.492486 0.608756 -2.726198
H -0.492486 -0.608756 -2.726184

0 comments on commit 69d5b63

Please sign in to comment.