1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 from os import sep
25 from re import search
26 from string import split
27 from tempfile import mktemp
28
29
30 from base_classes import SystemTestCase
31 from status import Status; status = Status()
32
33
34 -class Grace(SystemTestCase):
35 """Class for testing the creation of grace plots."""
36
38 """Common set up for these system tests."""
39
40
41 self.tmpfile = mktemp()
42
43
45 """Test the plotting of the 15N data from the CaM-KKalpha save state."""
46
47
48 self.interpreter.state.load('state_cam_kkalpha', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states')
49
50
51 self.interpreter.grace.write('spin', 's2', file=self.tmpfile, spin_id='@N', dir=None)
52
53
54 file = open(self.tmpfile)
55 lines = file.readlines()
56 file.close()
57
58
59 spin = []
60 value = []
61 error = []
62
63
64 in_data = False
65 for i in range(len(lines)):
66
67 if search('G0.S0', lines[i]):
68 in_data=True
69 continue
70
71
72 if not in_data:
73 continue
74
75
76 if search('^@', lines[i]):
77 continue
78
79
80 if search('^&', lines[i]):
81 break
82
83
84 row = split(lines[i])
85
86
87 spin.append(float(row[0]))
88 value.append(float(row[1]))
89 error.append(float(row[2]))
90
91
92 real_data = [
93 [2, 0.693, 0.005],
94 [3, 0.400, 0.000],
95 [4, 0.882, 0.008],
96 [5, 0.901, 0.001],
97 [6, 0.953, 0.014],
98 [7, 0.905, 0.000],
99 [8, 0.939, 0.007],
100 [9, 0.948, 0.003],
101 [10, 0.957, 0.004]
102 ]
103
104
105 self.assertEqual(len(real_data), len(spin))
106
107
108 for i in range(len(real_data)):
109 self.assertEqual(float(real_data[i][0]), spin[i])
110 self.assertAlmostEqual(real_data[i][1], value[i])
111 self.assertAlmostEqual(real_data[i][2], error[i])
112