Skip to content

Commit

Permalink
Added more tests for presets
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelRobidas committed Mar 8, 2022
1 parent 850320f commit 51a645f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ccinput/tests/presets/whitespace.preset
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"software": "gaussian",
"type": "opt",
"method": "HF",
"basis_set": "Def2tzvp",
"version": "-"
}
7 changes: 7 additions & 0 deletions ccinput/tests/presets/winchars.preset
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"software": "gaussian",
"type": "opt",
"method": "HF",
"basis_set": "Def2tzvp",
"version": "-"
}
36 changes: 36 additions & 0 deletions ccinput/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from contextlib import contextmanager, redirect_stdout
from os import devnull

PRESET_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'presets')

@contextmanager
def hide_cmd_output():
with open(devnull, 'w') as gobble:
Expand Down Expand Up @@ -363,6 +365,38 @@ def test_d3bj_orca(self):
line = "orca opt PBE0 -bs Def2SVP --xyz 'Cl 0 0 0' -n 1 --mem 1G -c -1 --d3bj"
self.assertTrue(self.args_cmd_equivalent(args, line))

def test_load_preset_winchars(self):
presets.data_dir = PRESET_DIR
args = {
'software': "gaussian",
'type': "opt",
'method': "HF",
'basis_set': "def2tzvp",
'xyz': "Cl 0 0 0\n",
'nproc': 1,
'mem': "1G",
'charge': -1,
}

line = '--preset winchars --xyz "Cl 0 0 0" -c -1'
self.assertTrue(self.args_cmd_equivalent(args, line))

def test_load_preset_whitespace(self):
presets.data_dir = PRESET_DIR
args = {
'software': "gaussian",
'type': "opt",
'method': "HF",
'basis_set': "def2tzvp",
'xyz': "Cl 0 0 0\n",
'nproc': 1,
'mem': "1G",
'charge': -1,
}

line = '--preset whitespace --xyz "Cl 0 0 0" -c -1'
self.assertTrue(self.args_cmd_equivalent(args, line))

class ManualCliTests(InputTests):
def setUp(self):
self.warnings = []
Expand Down Expand Up @@ -894,3 +928,5 @@ def test_save_and_load(self):
line = 'Gaussian sp tpsstpss -bs ccpvdz -o calc.com --save my_preset --preset my_preset'
with self.assertRaises(SystemExit):
cmd(cmd_line=line)


0 comments on commit 51a645f

Please sign in to comment.