1
"""
2
test_survey_confs.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.survey_confs import *
17

18 0
import matplotlib as mpl
19 0
mpl.use("Agg")  # for Mac OS X error of NSInvalidArgumentException on Travis CI
20

21
# -----------------------
22

23
# TODO ADD FILE CHECKS!!
24
# TODO CHECK avg_coeffvar function!!
25

26 0
def test_survey_times():
27 0
    survey_confs(
28
        os.path.join(mydir, 'data_tests', 'survey_confs', 'stitch_time.in'),
29
        analyze_energies=False,
30
        analyze_times=True,
31
        ref_index=None,
32
        plot_enes=False
33
    )
34 0
    os.remove('timeAvgs.txt')
35 0
    os.remove('rename_me.png')
36

37 0
def test_survey_times_wrongtag():
38 0
    with pytest.raises(NameError):
39 0
        survey_confs(
40
            os.path.join(mydir, 'data_tests', 'survey_confs', 'stitch_wrongtag.in'),
41
            analyze_energies=False,
42
            analyze_times=True,
43
            ref_index=None,
44
            plot_enes=False
45
        )
46 0
    os.remove('timeAvgs.txt')
47 0
    assert True
48

49 0
def test_survey_energies():
50 0
    survey_confs(
51
        os.path.join(mydir, 'data_tests', 'survey_confs', 'stitch_ene.in'),
52
        analyze_energies=True,
53
        analyze_times=False,
54
        ref_index=None,
55
        plot_enes=False
56
    )
57 0
    os.remove('relene.dat')
58

59 0
def test_survey_energies_reference():
60 0
    survey_confs(
61
        os.path.join(mydir, 'data_tests', 'survey_confs', 'stitch_ene.in'),
62
        analyze_energies=True,
63
        analyze_times=False,
64
        ref_index=0,
65
        plot_enes=False
66
    )
67 0
    assert os.path.getsize('relene-rmsd.dat') == 951
68 0
    os.remove('relene-rmsd.dat')
69

70 0
def test_survey_energies_plot():
71 0
    survey_confs(
72
        os.path.join(mydir, 'data_tests', 'survey_confs', 'stitch_ene.in'),
73
        analyze_energies=True,
74
        analyze_times=False,
75
        ref_index=0,
76
        plot_enes=True
77
    )
78 0
    os.remove('relene-rmsd.dat')
79 0
    os.remove('barchart.png')
80

81

82
# test manually without pytest
83 0
if 0:
84
    sys.path.insert(0, '/home/limvt/Documents/quanformer/quanformer')
85
    from survey_confs import *
86
    test_survey_times()

Read our documentation on viewing source code .

Loading