1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from copy import deepcopy
24 from os import sep
25 import sys
26 from tempfile import mktemp
27
28
29 from data import Relax_data_store; ds = Relax_data_store()
30 import dep_check
31 from generic_fns.interatomic import interatomic_loop
32 from generic_fns.pipes import VALID_TYPES, get_pipe
33 from generic_fns.reset import reset
34 from status import Status; status = Status()
35 from test_suite.system_tests.base_classes import SystemTestCase
36
37
38 -class State(SystemTestCase):
39 """Class for testing the state saving and loading user functions."""
40
41 - def __init__(self, methodName='runTest'):
42 """Skip the tests if the C modules are non-functional.
43
44 @keyword methodName: The name of the test.
45 @type methodName: str
46 """
47
48
49 super(State, self).__init__(methodName)
50
51
52 if not dep_check.C_module_exp_fn and methodName in ['test_write_read_pipes']:
53
54 status.skipped_tests.append([methodName, 'Relax curve-fitting C module', self._skip_type])
55
56
58 """Common set up for these system tests."""
59
60
61 self.tmpfile = mktemp()
62
63
65 """Test the loading of a relax state with an alignment tensor with MC simulation structures."""
66
67
68 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'+sep+'align_tensor_mc.bz2'
69
70
71 self.interpreter.state.load(path)
72
73
74 domains = ['Dy N-dom', 'Dy C-dom']
75 rdc = {
76 "Dy N-dom" : [-6.41, -21.55],
77 "Dy C-dom" : [-21.55]
78 }
79 rdc_bc = {
80 "Dy N-dom" : [None, -20.87317257368743],
81 "Dy C-dom" : [None]
82 }
83
84 rdc_err = {
85 "Dy N-dom" : [1.0, 1.0],
86 "Dy C-dom" : [1.0]
87 }
88
89
90 for domain in domains:
91
92 self.interpreter.pipe.switch(domain)
93
94
95 i = 0
96 for interatom in interatomic_loop():
97
98 self.assertEqual(interatom.rdc[domain], rdc[domain][i])
99 if rdc_bc[domain][i]:
100 self.assertEqual(interatom.rdc_bc[domain], rdc_bc[domain][i])
101 if rdc_err[domain][i]:
102 self.assertEqual(interatom.rdc_err[domain], rdc_err[domain][i])
103
104
105 i += 1
106
107
125
126
128 """Test the writing out, and re-reading of data pipes from the state file."""
129
130
131 self.interpreter.pipe.create('test', 'mf')
132
133
134 reset()
135
136
137 pipe_types = deepcopy(VALID_TYPES)
138 pipe_types.pop(pipe_types.index("frame order"))
139
140
141 for i in range(len(pipe_types)):
142 self.interpreter.pipe.create('test' + repr(i), pipe_types[i])
143
144
145 self.interpreter.state.save(self.tmpfile)
146
147
148 reset()
149
150
151 self.interpreter.state.load(self.tmpfile)
152
153
154 for i in range(len(pipe_types)):
155
156 name = 'test' + repr(i)
157 self.assert_(name in ds)
158
159
160 pipe = get_pipe(name)
161 self.assertEqual(pipe.pipe_type, pipe_types[i])
162