1
"""
2
test_confs_to_psi.py
3
"""
4 0
import sys
5 0
import os
6 0
import pytest
7 0
import shutil
8

9
# define location of input files for testing
10 0
mydir = os.path.dirname(os.path.abspath(__file__))
11

12
# import functions to aid testing
13 0
sys.path.append(os.path.join(os.path.dirname(__file__), 'helpers'))
14 0
from helper import *
15

16 0
from quanformer.confs_to_psi import *
17

18
# -----------------------
19

20 0
def test_make_hessian():
21 0
    mol = read_mol(os.path.join(mydir, 'data_tests', 'methane_c2p.sdf'))
22 0
    test_string = make_psi_input(mol, mol.GetTitle(), 'mp2', 'aug-cc-pVTZ',
23
                                 'hess')
24 0
    assert "H, wfn = hessian('mp2', return_wfn=True)" in test_string
25 0
    assert "wfn.hessian().print_out()" in test_string
26

27

28 0
def test_make_frozen():
29 0
    mol = read_mol(os.path.join(mydir, 'data_tests', 'freeze.sdf'))
30 0
    test_string = make_psi_input(mol, mol.GetTitle(), 'mp2', 'aug-cc-pVTZ')
31 0
    assert "4 xyz" in test_string
32 0
    assert "1 xyz" in test_string
33 0
    assert "3 xyz" in test_string
34 0
    assert "12 xyz" in test_string
35

36

37 0
def test_make_dfmp2_dunning():
38 0
    mol = read_mol(os.path.join(mydir, 'data_tests', 'methane_c2p.sdf'))
39 0
    test_string = make_psi_input(mol, mol.GetTitle(), 'mp2', 'aug-cc-pVTZ')
40 0
    assert "df_basis_mp2" not in test_string
41

42

43 0
def test_make_dfmp2_qzvpd():
44 0
    mol = read_mol(os.path.join(mydir, 'data_tests', 'methane_c2p.sdf'))
45 0
    test_string = make_psi_input(mol, mol.GetTitle(), 'mp2', 'def2-qzvpd')
46 0
    assert "df_basis_mp2" not in test_string
47 0
    return
48

49

50 0
def test_make_dfmp2_svpp():
51 0
    mol = read_mol(os.path.join(mydir, 'data_tests', 'methane_c2p.sdf'))
52 0
    test_string = make_psi_input(mol, mol.GetTitle(), 'mp2', 'def2-sv(p)')
53 0
    assert "def2-sv_p_-ri" in test_string
54 0
    return
55

56

57 0
def test_confs_to_psi():
58 0
    confs_to_psi(
59
        os.path.join(mydir, 'data_tests', 'methane_c2p.sdf'), 'mp2',
60
        'def2-sv(p)')
61
    # check file byte size (this line should be updated if confs_to_psi changes)
62 0
    assert os.path.getsize(os.path.join('methane', '1', 'input.dat')) == 358
63 0
    shutil.rmtree('methane')
64 0
    return
65

66

67 0
def test_confs_to_psi_json():
68 0
    confs_to_psi(
69
        os.path.join(mydir, 'data_tests', 'methane_c2p.sdf'),
70
        'mp2',
71
        'def2-sv(p)',
72
        calctype='spe',
73
        via_json=True)
74
    # check file byte size (this line should be updated if confs_to_psi changes)
75 0
    assert os.path.getsize(os.path.join('methane', '1', 'input.py')) == 1032
76 0
    shutil.rmtree('methane')
77 0
    return
78

79

80
# test manually without pytest
81 0
if 0:
82
    test_confs_to_psi()

Read our documentation on viewing source code .

Loading