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-2014 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program 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 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Python module imports. 
 23  from unittest import TestCase 
 24   
 25  # relax module imports. 
 26  from prompt.interpreter import Interpreter 
 27  from lib.errors import RelaxError, RelaxBoolError, RelaxIntError, RelaxNoneIntError, RelaxNoneNumError, RelaxNoneStrError, RelaxNumError, RelaxStrError 
 28  from test_suite.unit_tests.relax_data_testing_base import Relax_data_base_class 
 29   
 30  # Unit test imports. 
 31  from test_suite.unit_tests._prompt.data_types import DATA_TYPES 
 32   
 33   
34 -class Test_relax_data(Relax_data_base_class, TestCase):
35 """Unit tests for the functions of the 'prompt.relax_data' module.""" 36
37 - def __init__(self, methodName=None):
38 """Set up the test case class for the system tests.""" 39 40 # Execute the base __init__ methods. 41 super(Test_relax_data, self).__init__(methodName) 42 43 # Load the interpreter. 44 self.interpreter = Interpreter(show_script=False, raise_relax_error=True) 45 self.interpreter.populate_self() 46 self.interpreter.on(verbose=False) 47 48 # Alias the user function class. 49 self.relax_data_fns = self.interpreter.relax_data
50 51
53 """The ri_id arg test of the relax_data.back_calc() user function.""" 54 55 # Loop over the data types. 56 for data in DATA_TYPES: 57 # Catch the str argument, and skip it. 58 if data[0] == 'None' or data[0] == 'str': 59 continue 60 61 # The argument test. 62 self.assertRaises(RelaxNoneStrError, 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 # Loop over the data types. 69 for data in DATA_TYPES: 70 # Catch the str argument, and skip it. 71 if data[0] == 'None' or data[0] == 'str': 72 continue 73 74 # The argument test. 75 self.assertRaises(RelaxNoneStrError, 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 # Loop over the data types. 82 for data in DATA_TYPES: 83 # Catch the number arguments, and skip them. 84 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 85 continue 86 87 # The argument test. 88 self.assertRaises(RelaxNoneNumError, 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 # Loop over the data types. 95 for data in DATA_TYPES: 96 # Catch the None and str arguments, and skip them. 97 if data[0] == 'None' or data[0] == 'str': 98 continue 99 100 # The argument test. 101 self.assertRaises(RelaxNoneStrError, 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 # Loop over the data types. 108 for data in DATA_TYPES: 109 # Catch the None and str arguments, and skip them. 110 if data[0] == 'None' or data[0] == 'str': 111 continue 112 113 # The argument test. 114 self.assertRaises(RelaxNoneStrError, 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 # Test that both cannot be None (the default)! 121 self.assertRaises(RelaxError, self.relax_data_fns.copy)
122 123
124 - def test_copy_argfail_ri_id(self):
125 """The ri_id arg test of the relax_data.copy() user function.""" 126 127 # Loop over the data types. 128 for data in DATA_TYPES: 129 # Catch the str argument, and skip it. 130 if data[0] == 'None' or data[0] == 'str': 131 continue 132 133 # The argument test. 134 self.assertRaises(RelaxNoneStrError, 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 # Loop over the data types. 141 for data in DATA_TYPES: 142 # Catch the str argument, and skip it. 143 if data[0] == 'str': 144 continue 145 146 # The argument test. 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 # Loop over the data types. 154 for data in DATA_TYPES: 155 # Catch the str argument, and skip it. 156 if data[0] == 'str': 157 continue 158 159 # The argument test. 160 self.assertRaises(RelaxStrError, self.relax_data_fns.display, ri_id=data[1])
161 162
163 - def test_read_argfail_ri_id(self):
164 """The ri_id arg test of the relax_data.read() user function.""" 165 166 # Loop over the data types. 167 for data in DATA_TYPES: 168 # Catch the str argument, and skip it. 169 if data[0] == 'str': 170 continue 171 172 # The argument test. 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 # Loop over the data types. 180 for data in DATA_TYPES: 181 # Catch the str argument, and skip it. 182 if data[0] == 'str': 183 continue 184 185 # The argument test. 186 self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id='R2', ri_type=data[1])
187 188
189 - def test_read_argfail_frq(self):
190 """The frq arg test of the relax_data.read() user function.""" 191 192 # Loop over the data types. 193 for data in DATA_TYPES: 194 # Catch the number arguments, and skip them. 195 if data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 196 continue 197 198 # The argument test. 199 self.assertRaises(RelaxNumError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=data[1])
200 201
202 - def test_read_argfail_file(self):
203 """The file arg test of the relax_data.read() user function.""" 204 205 # Loop over the data types. 206 for data in DATA_TYPES: 207 # Catch the str argument, and skip it. 208 if data[0] == 'str': 209 continue 210 211 # The argument test. 212 self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file=data[1])
213 214
215 - def test_read_argfail_dir(self):
216 """The dir arg test of the relax_data.read() user function.""" 217 218 # Loop over the data types. 219 for data in DATA_TYPES: 220 # Catch the None and str arguments, and skip them. 221 if data[0] == 'None' or data[0] == 'str': 222 continue 223 224 # The argument test. 225 self.assertRaises(RelaxNoneStrError, 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 # Loop over the data types. 232 for data in DATA_TYPES: 233 # Catch the None, int, and bin arguments, and skip them. 234 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 235 continue 236 237 # The argument test. 238 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])
239 240
242 """The res_num_col arg test of the relax_data.read() user function.""" 243 244 # Loop over the data types. 245 for data in DATA_TYPES: 246 # Catch the None, int, and bin arguments, and skip them. 247 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 248 continue 249 250 # The argument test. 251 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])
252 253
255 """The res_name_col arg test of the relax_data.read() user function.""" 256 257 # Loop over the data types. 258 for data in DATA_TYPES: 259 # Catch the None, int, and bin arguments, and skip them. 260 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 261 continue 262 263 # The argument test. 264 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])
265 266
268 """The spin_num_col arg test of the relax_data.read() user function.""" 269 270 # Loop over the data types. 271 for data in DATA_TYPES: 272 # Catch the None, int, and bin arguments, and skip them. 273 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 274 continue 275 276 # The argument test. 277 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])
278 279
281 """The spin_name_col arg test of the relax_data.read() user function.""" 282 283 # Loop over the data types. 284 for data in DATA_TYPES: 285 # Catch the None, int, and bin arguments, and skip them. 286 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 287 continue 288 289 # The argument test. 290 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])
291 292
294 """The data_col arg test of the relax_data.read() user function.""" 295 296 # Loop over the data types. 297 for data in DATA_TYPES: 298 # Catch the int and bin arguments, and skip them. 299 if data[0] == 'int' or data[0] == 'bin': 300 continue 301 302 # The argument test. 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 # Loop over the data types. 310 for data in DATA_TYPES: 311 # Catch the int and bin arguments, and skip them. 312 if data[0] == 'int' or data[0] == 'bin': 313 continue 314 315 # The argument test. 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
319 - def test_read_argfail_sep(self):
320 """The sep arg test of the relax_data.read() user function.""" 321 322 # Loop over the data types. 323 for data in DATA_TYPES: 324 # Catch the None and str arguments, and skip them. 325 if data[0] == 'None' or data[0] == 'str': 326 continue 327 328 # The argument test. 329 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])
330 331
332 - def test_write_argfail_ri_id(self):
333 """The ri_id arg test of the relax_data.write() user function.""" 334 335 # Loop over the data types. 336 for data in DATA_TYPES: 337 # Catch the str argument, and skip it. 338 if data[0] == 'str': 339 continue 340 341 # The argument test. 342 self.assertRaises(RelaxStrError, self.relax_data_fns.write, ri_id=data[1])
343 344
345 - def test_write_argfail_file(self):
346 """The file arg test of the relax_data.write() user function.""" 347 348 # Loop over the data types. 349 for data in DATA_TYPES: 350 # Catch the str argument, and skip it. 351 if data[0] == 'str': 352 continue 353 354 # The argument test. 355 self.assertRaises(RelaxStrError, self.relax_data_fns.write, ri_id='R2_1000', file=data[1])
356 357
358 - def test_write_argfail_dir(self):
359 """The dir arg test of the relax_data.write() user function.""" 360 361 # Loop over the data types. 362 for data in DATA_TYPES: 363 # Catch the None and str arguments, and skip them. 364 if data[0] == 'None' or data[0] == 'str': 365 continue 366 367 # The argument test. 368 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.write, ri_id='R2_1000', file='a', dir=data[1])
369 370
371 - def test_write_argfail_force(self):
372 """The force arg test of the relax_data.write() user function.""" 373 374 # Loop over the data types. 375 for data in DATA_TYPES: 376 # Catch the bool arguments, and skip them. 377 if data[0] == 'bool': 378 continue 379 380 # The argument test. 381 self.assertRaises(RelaxBoolError, self.relax_data_fns.write, ri_id='R2_1000', file='a', force=data[1])
382