Package test_suite :: Package unit_tests :: Package _prompt :: Module test_relax_data
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._prompt.test_relax_data

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2012 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Python module imports. 
 24  from unittest import TestCase 
 25   
 26  # relax module imports. 
 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  # Unit test imports. 
 32  from data_types import DATA_TYPES 
 33   
 34   
35 -class Test_relax_data(Relax_data_base_class, TestCase):
36 """Unit tests for the functions of the 'prompt.relax_data' module.""" 37
38 - def __init__(self, methodName=None):
39 """Set up the test case class for the system tests.""" 40 41 # Execute the base __init__ methods. 42 super(Test_relax_data, self).__init__(methodName) 43 44 # Load the interpreter. 45 self.interpreter = Interpreter(show_script=False, quit=False, raise_relax_error=True) 46 self.interpreter.populate_self() 47 self.interpreter.on(verbose=False) 48 49 # Alias the user function class. 50 self.relax_data_fns = self.interpreter.relax_data
51 52
54 """The ri_id arg test of the relax_data.back_calc() user function.""" 55 56 # Loop over the data types. 57 for data in DATA_TYPES: 58 # Catch the str argument, and skip it. 59 if data[0] == 'None' or data[0] == 'str': 60 continue 61 62 # The argument test. 63 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.back_calc, ri_id=data[1])
64 65
67 """The ri_type arg test of the relax_data.back_calc() user function.""" 68 69 # Loop over the data types. 70 for data in DATA_TYPES: 71 # Catch the str argument, and skip it. 72 if data[0] == 'None' or data[0] == 'str': 73 continue 74 75 # The argument test. 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 # Loop over the data types. 83 for data in DATA_TYPES: 84 # Catch the number arguments, and skip them. 85 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 86 continue 87 88 # The argument test. 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 # Loop over the data types. 96 for data in DATA_TYPES: 97 # Catch the None and str arguments, and skip them. 98 if data[0] == 'None' or data[0] == 'str': 99 continue 100 101 # The argument test. 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 # Loop over the data types. 109 for data in DATA_TYPES: 110 # Catch the None and str arguments, and skip them. 111 if data[0] == 'None' or data[0] == 'str': 112 continue 113 114 # The argument test. 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 # Test that both cannot be None (the default)! 122 self.assertRaises(RelaxError, self.relax_data_fns.copy)
123 124
125 - def test_copy_argfail_ri_id(self):
126 """The ri_id arg test of the relax_data.copy() user function.""" 127 128 # Loop over the data types. 129 for data in DATA_TYPES: 130 # Catch the str argument, and skip it. 131 if data[0] == 'None' or data[0] == 'str': 132 continue 133 134 # The argument test. 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 # Loop over the data types. 142 for data in DATA_TYPES: 143 # Catch the str argument, and skip it. 144 if data[0] == 'str': 145 continue 146 147 # The argument test. 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 # Loop over the data types. 155 for data in DATA_TYPES: 156 # Catch the str argument, and skip it. 157 if data[0] == 'str': 158 continue 159 160 # The argument test. 161 self.assertRaises(RelaxStrError, self.relax_data_fns.display, ri_id=data[1])
162 163
164 - def test_read_argfail_ri_id(self):
165 """The ri_id arg test of the relax_data.read() user function.""" 166 167 # Loop over the data types. 168 for data in DATA_TYPES: 169 # Catch the str argument, and skip it. 170 if data[0] == 'str': 171 continue 172 173 # The argument test. 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 # Loop over the data types. 181 for data in DATA_TYPES: 182 # Catch the str argument, and skip it. 183 if data[0] == 'str': 184 continue 185 186 # The argument test. 187 self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id='R2', ri_type=data[1])
188 189
190 - def test_read_argfail_frq(self):
191 """The frq arg test of the relax_data.read() user function.""" 192 193 # Loop over the data types. 194 for data in DATA_TYPES: 195 # Catch the number arguments, and skip them. 196 if data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 197 continue 198 199 # The argument test. 200 self.assertRaises(RelaxNumError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=data[1])
201 202
203 - def test_read_argfail_file(self):
204 """The file arg test of the relax_data.read() user function.""" 205 206 # Loop over the data types. 207 for data in DATA_TYPES: 208 # Catch the str argument, and skip it. 209 if data[0] == 'str': 210 continue 211 212 # The argument test. 213 self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file=data[1])
214 215
216 - def test_read_argfail_dir(self):
217 """The dir arg test of the relax_data.read() user function.""" 218 219 # Loop over the data types. 220 for data in DATA_TYPES: 221 # Catch the None and str arguments, and skip them. 222 if data[0] == 'None' or data[0] == 'str': 223 continue 224 225 # The argument test. 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 # Loop over the data types. 233 for data in DATA_TYPES: 234 # Catch the None, int, and bin arguments, and skip them. 235 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 236 continue 237 238 # The argument test. 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 # Loop over the data types. 246 for data in DATA_TYPES: 247 # Catch the None, int, and bin arguments, and skip them. 248 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 249 continue 250 251 # The argument test. 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 # Loop over the data types. 259 for data in DATA_TYPES: 260 # Catch the None, int, and bin arguments, and skip them. 261 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 262 continue 263 264 # The argument test. 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 # Loop over the data types. 272 for data in DATA_TYPES: 273 # Catch the None, int, and bin arguments, and skip them. 274 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 275 continue 276 277 # The argument test. 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 # Loop over the data types. 285 for data in DATA_TYPES: 286 # Catch the None, int, and bin arguments, and skip them. 287 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 288 continue 289 290 # The argument test. 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 # Loop over the data types. 298 for data in DATA_TYPES: 299 # Catch the int and bin arguments, and skip them. 300 if data[0] == 'int' or data[0] == 'bin': 301 continue 302 303 # The argument test. 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 # Loop over the data types. 311 for data in DATA_TYPES: 312 # Catch the int and bin arguments, and skip them. 313 if data[0] == 'int' or data[0] == 'bin': 314 continue 315 316 # The argument test. 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
320 - def test_read_argfail_sep(self):
321 """The sep arg test of the relax_data.read() user function.""" 322 323 # Loop over the data types. 324 for data in DATA_TYPES: 325 # Catch the None and str arguments, and skip them. 326 if data[0] == 'None' or data[0] == 'str': 327 continue 328 329 # The argument test. 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
333 - def test_write_argfail_ri_id(self):
334 """The ri_id arg test of the relax_data.write() user function.""" 335 336 # Loop over the data types. 337 for data in DATA_TYPES: 338 # Catch the str argument, and skip it. 339 if data[0] == 'str': 340 continue 341 342 # The argument test. 343 self.assertRaises(RelaxStrError, self.relax_data_fns.write, ri_id=data[1])
344 345
346 - def test_write_argfail_file(self):
347 """The file arg test of the relax_data.write() user function.""" 348 349 # Loop over the data types. 350 for data in DATA_TYPES: 351 # Catch the str argument, and skip it. 352 if data[0] == 'str': 353 continue 354 355 # The argument test. 356 self.assertRaises(RelaxStrError, self.relax_data_fns.write, ri_id='R2_1000', file=data[1])
357 358
359 - def test_write_argfail_dir(self):
360 """The dir arg test of the relax_data.write() user function.""" 361 362 # Loop over the data types. 363 for data in DATA_TYPES: 364 # Catch the None and str arguments, and skip them. 365 if data[0] == 'None' or data[0] == 'str': 366 continue 367 368 # The argument test. 369 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.write, ri_id='R2_1000', file='a', dir=data[1])
370 371
372 - def test_write_argfail_force(self):
373 """The force arg test of the relax_data.write() user function.""" 374 375 # Loop over the data types. 376 for data in DATA_TYPES: 377 # Catch the bool arguments, and skip them. 378 if data[0] == 'bool': 379 continue 380 381 # The argument test. 382 self.assertRaises(RelaxBoolError, self.relax_data_fns.write, ri_id='R2_1000', file='a', force=data[1])
383