1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23  from unittest import TestCase 
 24   
 25   
 26  from prompt.interpreter import Interpreter 
 27  from lib.errors import RelaxError, RelaxBoolError, RelaxIntError, RelaxNumError, RelaxStrError, RelaxStrFileError 
 28  from test_suite.unit_tests.relax_data_testing_base import Relax_data_base_class 
 29   
 30   
 31  from test_suite.unit_tests._prompt.data_types import DATA_TYPES 
 32   
 33   
 35      """Unit tests for the functions of the 'prompt.relax_data' module.""" 
 36   
 50   
 51   
 53          """The ri_id arg test of the relax_data.back_calc() user function.""" 
 54   
 55           
 56          for data in DATA_TYPES: 
 57               
 58              if data[0] == 'None' or data[0] == 'str': 
 59                  continue 
 60   
 61               
 62              self.assertRaises(RelaxStrError, self.relax_data_fns.back_calc, ri_id=data[1]) 
  63   
 64   
 66          """The ri_type arg test of the relax_data.back_calc() user function.""" 
 67   
 68           
 69          for data in DATA_TYPES: 
 70               
 71              if data[0] == 'None' or data[0] == 'str': 
 72                  continue 
 73   
 74               
 75              self.assertRaises(RelaxStrError, self.relax_data_fns.back_calc, ri_id='R2', ri_type=data[1]) 
  76   
 77   
 79          """The frq arg test of the relax_data.back_calc() user function.""" 
 80   
 81           
 82          for data in DATA_TYPES: 
 83               
 84              if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 
 85                  continue 
 86   
 87               
 88              self.assertRaises(RelaxNumError, self.relax_data_fns.back_calc, ri_id='R2_1000', ri_type='R2', frq=data[1]) 
  89   
 90   
 92          """The pipe_from arg test of the relax_data.copy() user function.""" 
 93   
 94           
 95          for data in DATA_TYPES: 
 96               
 97              if data[0] == 'None' or data[0] == 'str': 
 98                  continue 
 99   
100               
101              self.assertRaises(RelaxStrError, self.relax_data_fns.copy, pipe_from=data[1]) 
 102   
103   
105          """The pipe_to arg test of the relax_data.copy() user function.""" 
106   
107           
108          for data in DATA_TYPES: 
109               
110              if data[0] == 'None' or data[0] == 'str': 
111                  continue 
112   
113               
114              self.assertRaises(RelaxStrError, self.relax_data_fns.copy, pipe_from='', pipe_to=data[1]) 
 115   
116   
118          """The pipe_from and pipe_to arg test of the relax_data.copy() user function.""" 
119   
120           
121          self.assertRaises(RelaxError, self.relax_data_fns.copy) 
 122   
123   
125          """The ri_id arg test of the relax_data.copy() user function.""" 
126   
127           
128          for data in DATA_TYPES: 
129               
130              if data[0] == 'None' or data[0] == 'str': 
131                  continue 
132   
133               
134              self.assertRaises(RelaxStrError, self.relax_data_fns.copy, pipe_from='', pipe_to='', ri_id=data[1]) 
 135   
136   
138          """The ri_id arg test of the relax_data.delete() user function.""" 
139   
140           
141          for data in DATA_TYPES: 
142               
143              if data[0] == 'str': 
144                  continue 
145   
146               
147              self.assertRaises(RelaxStrError, self.relax_data_fns.delete, ri_id=data[1]) 
 148   
149   
151          """The ri_id arg test of the relax_data.display() user function.""" 
152   
153           
154          for data in DATA_TYPES: 
155               
156              if data[0] == 'str': 
157                  continue 
158   
159               
160              self.assertRaises(RelaxStrError, self.relax_data_fns.display, ri_id=data[1]) 
 161   
162   
164          """The ri_id arg test of the relax_data.read() user function.""" 
165   
166           
167          for data in DATA_TYPES: 
168               
169              if data[0] == 'str': 
170                  continue 
171   
172               
173              self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id=data[1]) 
 174   
175   
177          """The ri_type arg test of the relax_data.read() user function.""" 
178   
179           
180          for data in DATA_TYPES: 
181               
182              if data[0] == 'str': 
183                  continue 
184   
185               
186              self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id='R2', ri_type=data[1]) 
 187   
188   
190          """The frq arg test of the relax_data.read() user function.""" 
191   
192           
193          for data in DATA_TYPES: 
194               
195              if data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 
196                  continue 
197   
198               
199              self.assertRaises(RelaxNumError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=data[1]) 
 200   
201   
203          """The file arg test of the relax_data.read() user function.""" 
204   
205           
206          for data in DATA_TYPES: 
207               
208              if data[0] in ['file', 'str']: 
209                  continue 
210   
211               
212              self.assertRaises(RelaxStrFileError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file=data[1]) 
 213   
214   
216          """The dir arg test of the relax_data.read() user function.""" 
217   
218           
219          for data in DATA_TYPES: 
220               
221              if data[0] == 'None' or data[0] == 'str': 
222                  continue 
223   
224               
225              self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', dir=data[1]) 
 226   
227   
229          """The mol_name_col arg test of the relax_data.read() user function.""" 
230   
231           
232          for data in DATA_TYPES: 
233               
234              if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 
235                  continue 
236   
237               
238              self.assertRaises(RelaxIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', mol_name_col=data[1]) 
 239   
240   
242          """The res_num_col arg test of the relax_data.read() user function.""" 
243   
244           
245          for data in DATA_TYPES: 
246               
247              if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 
248                  continue 
249   
250               
251              self.assertRaises(RelaxIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', res_num_col=data[1]) 
 252   
253   
255          """The res_name_col arg test of the relax_data.read() user function.""" 
256   
257           
258          for data in DATA_TYPES: 
259               
260              if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 
261                  continue 
262   
263               
264              self.assertRaises(RelaxIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', res_name_col=data[1]) 
 265   
266   
268          """The spin_num_col arg test of the relax_data.read() user function.""" 
269   
270           
271          for data in DATA_TYPES: 
272               
273              if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 
274                  continue 
275   
276               
277              self.assertRaises(RelaxIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', spin_num_col=data[1]) 
 278   
279   
281          """The spin_name_col arg test of the relax_data.read() user function.""" 
282   
283           
284          for data in DATA_TYPES: 
285               
286              if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 
287                  continue 
288   
289               
290              self.assertRaises(RelaxIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', spin_name_col=data[1]) 
 291   
292   
294          """The data_col arg test of the relax_data.read() user function.""" 
295   
296           
297          for data in DATA_TYPES: 
298               
299              if data[0] == 'int' or data[0] == 'bin': 
300                  continue 
301   
302               
303              self.assertRaises(RelaxIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', data_col=data[1]) 
 304   
305   
307          """The error_col arg test of the relax_data.read() user function.""" 
308   
309           
310          for data in DATA_TYPES: 
311               
312              if data[0] == 'int' or data[0] == 'bin': 
313                  continue 
314   
315               
316              self.assertRaises(RelaxIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', error_col=data[1]) 
 317   
318   
320          """The sep arg test of the relax_data.read() user function.""" 
321   
322           
323          for data in DATA_TYPES: 
324               
325              if data[0] == 'None' or data[0] == 'str': 
326                  continue 
327   
328               
329              self.assertRaises(RelaxStrError, 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]) 
 330   
331   
333          """The ri_id arg test of the relax_data.write() user function.""" 
334   
335           
336          for data in DATA_TYPES: 
337               
338              if data[0] == 'str': 
339                  continue 
340   
341               
342              self.assertRaises(RelaxStrError, self.relax_data_fns.write, ri_id=data[1]) 
 343   
344   
346          """The file arg test of the relax_data.write() user function.""" 
347   
348           
349          for data in DATA_TYPES: 
350               
351              if data[0] in ['file', 'str']: 
352                  continue 
353   
354               
355              self.assertRaises(RelaxStrFileError, self.relax_data_fns.write, ri_id='R2_1000', file=data[1]) 
 356   
357   
359          """The dir arg test of the relax_data.write() user function.""" 
360   
361           
362          for data in DATA_TYPES: 
363               
364              if data[0] == 'None' or data[0] == 'str': 
365                  continue 
366   
367               
368              self.assertRaises(RelaxStrError, self.relax_data_fns.write, ri_id='R2_1000', file='a', dir=data[1]) 
 369   
370   
372          """The force arg test of the relax_data.write() user function.""" 
373   
374           
375          for data in DATA_TYPES: 
376               
377              if data[0] == 'bool': 
378                  continue 
379   
380               
381              self.assertRaises(RelaxBoolError, self.relax_data_fns.write, ri_id='R2_1000', file='a', force=data[1]) 
  382