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 unittest import TestCase
25
26
27 from prompt.interpreter import Interpreter
28 from relax_errors import RelaxError, RelaxBoolError, RelaxFloatError, RelaxIntError, RelaxNoneIntError, RelaxNoneNumError, RelaxNoneStrError, RelaxNumError, RelaxStrError
29 from test_suite.unit_tests.relax_data_testing_base import Relax_data_base_class
30
31
32 from data_types import DATA_TYPES
33
34
36 """Unit tests for the functions of the 'prompt.relax_data' module."""
37
51
52
64
65
67 """The ri_type arg test of the relax_data.back_calc() user function."""
68
69
70 for data in DATA_TYPES:
71
72 if data[0] == 'None' or data[0] == 'str':
73 continue
74
75
76 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.back_calc, ri_id='R2', ri_type=data[1])
77
78
80 """The frq arg test of the relax_data.back_calc() user function."""
81
82
83 for data in DATA_TYPES:
84
85 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'float':
86 continue
87
88
89 self.assertRaises(RelaxNoneNumError, self.relax_data_fns.back_calc, ri_id='R2_1000', ri_type='R2', frq=data[1])
90
91
93 """The pipe_from arg test of the relax_data.copy() user function."""
94
95
96 for data in DATA_TYPES:
97
98 if data[0] == 'None' or data[0] == 'str':
99 continue
100
101
102 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.copy, pipe_from=data[1])
103
104
106 """The pipe_to arg test of the relax_data.copy() user function."""
107
108
109 for data in DATA_TYPES:
110
111 if data[0] == 'None' or data[0] == 'str':
112 continue
113
114
115 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.copy, pipe_from='', pipe_to=data[1])
116
117
119 """The pipe_from and pipe_to arg test of the relax_data.copy() user function."""
120
121
122 self.assertRaises(RelaxError, self.relax_data_fns.copy)
123
124
126 """The ri_id arg test of the relax_data.copy() user function."""
127
128
129 for data in DATA_TYPES:
130
131 if data[0] == 'None' or data[0] == 'str':
132 continue
133
134
135 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.copy, pipe_from='', pipe_to='', ri_id=data[1])
136
137
139 """The ri_id arg test of the relax_data.delete() user function."""
140
141
142 for data in DATA_TYPES:
143
144 if data[0] == 'str':
145 continue
146
147
148 self.assertRaises(RelaxStrError, self.relax_data_fns.delete, ri_id=data[1])
149
150
152 """The ri_id arg test of the relax_data.display() user function."""
153
154
155 for data in DATA_TYPES:
156
157 if data[0] == 'str':
158 continue
159
160
161 self.assertRaises(RelaxStrError, self.relax_data_fns.display, ri_id=data[1])
162
163
165 """The ri_id arg test of the relax_data.read() user function."""
166
167
168 for data in DATA_TYPES:
169
170 if data[0] == 'str':
171 continue
172
173
174 self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id=data[1])
175
176
178 """The ri_type arg test of the relax_data.read() user function."""
179
180
181 for data in DATA_TYPES:
182
183 if data[0] == 'str':
184 continue
185
186
187 self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id='R2', ri_type=data[1])
188
189
191 """The frq arg test of the relax_data.read() user function."""
192
193
194 for data in DATA_TYPES:
195
196 if data[0] == 'bin' or data[0] == 'int' or data[0] == 'float':
197 continue
198
199
200 self.assertRaises(RelaxNumError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=data[1])
201
202
204 """The file arg test of the relax_data.read() user function."""
205
206
207 for data in DATA_TYPES:
208
209 if data[0] == 'str':
210 continue
211
212
213 self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file=data[1])
214
215
217 """The dir arg test of the relax_data.read() user function."""
218
219
220 for data in DATA_TYPES:
221
222 if data[0] == 'None' or data[0] == 'str':
223 continue
224
225
226 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', dir=data[1])
227
228
230 """The mol_name_col arg test of the relax_data.read() user function."""
231
232
233 for data in DATA_TYPES:
234
235 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin':
236 continue
237
238
239 self.assertRaises(RelaxNoneIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', mol_name_col=data[1])
240
241
243 """The res_num_col arg test of the relax_data.read() user function."""
244
245
246 for data in DATA_TYPES:
247
248 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin':
249 continue
250
251
252 self.assertRaises(RelaxNoneIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', res_num_col=data[1])
253
254
256 """The res_name_col arg test of the relax_data.read() user function."""
257
258
259 for data in DATA_TYPES:
260
261 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin':
262 continue
263
264
265 self.assertRaises(RelaxNoneIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', res_name_col=data[1])
266
267
269 """The spin_num_col arg test of the relax_data.read() user function."""
270
271
272 for data in DATA_TYPES:
273
274 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin':
275 continue
276
277
278 self.assertRaises(RelaxNoneIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', spin_num_col=data[1])
279
280
282 """The spin_name_col arg test of the relax_data.read() user function."""
283
284
285 for data in DATA_TYPES:
286
287 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin':
288 continue
289
290
291 self.assertRaises(RelaxNoneIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', spin_name_col=data[1])
292
293
295 """The data_col arg test of the relax_data.read() user function."""
296
297
298 for data in DATA_TYPES:
299
300 if data[0] == 'int' or data[0] == 'bin':
301 continue
302
303
304 self.assertRaises(RelaxIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', data_col=data[1])
305
306
308 """The error_col arg test of the relax_data.read() user function."""
309
310
311 for data in DATA_TYPES:
312
313 if data[0] == 'int' or data[0] == 'bin':
314 continue
315
316
317 self.assertRaises(RelaxIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', error_col=data[1])
318
319
321 """The sep arg test of the relax_data.read() user function."""
322
323
324 for data in DATA_TYPES:
325
326 if data[0] == 'None' or data[0] == 'str':
327 continue
328
329
330 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', data_col=0, error_col=0, sep=data[1])
331
332
334 """The ri_id arg test of the relax_data.write() user function."""
335
336
337 for data in DATA_TYPES:
338
339 if data[0] == 'str':
340 continue
341
342
343 self.assertRaises(RelaxStrError, self.relax_data_fns.write, ri_id=data[1])
344
345
347 """The file arg test of the relax_data.write() user function."""
348
349
350 for data in DATA_TYPES:
351
352 if data[0] == 'str':
353 continue
354
355
356 self.assertRaises(RelaxStrError, self.relax_data_fns.write, ri_id='R2_1000', file=data[1])
357
358
360 """The dir arg test of the relax_data.write() user function."""
361
362
363 for data in DATA_TYPES:
364
365 if data[0] == 'None' or data[0] == 'str':
366 continue
367
368
369 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.write, ri_id='R2_1000', file='a', dir=data[1])
370
371
373 """The force arg test of the relax_data.write() user function."""
374
375
376 for data in DATA_TYPES:
377
378 if data[0] == 'bool':
379 continue
380
381
382 self.assertRaises(RelaxBoolError, self.relax_data_fns.write, ri_id='R2_1000', file='a', force=data[1])
383