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-2011 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.relax_data import Relax_data 
 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 # Instantiate the user function class. 39 relax_data_fns = Relax_data() 40 41
43 """The ri_id arg test of the relax_data.back_calc() user function.""" 44 45 # Loop over the data types. 46 for data in DATA_TYPES: 47 # Catch the str argument, and skip it. 48 if data[0] == 'None' or data[0] == 'str': 49 continue 50 51 # The argument test. 52 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.back_calc, ri_id=data[1])
53 54
56 """The ri_type arg test of the relax_data.back_calc() user function.""" 57 58 # Loop over the data types. 59 for data in DATA_TYPES: 60 # Catch the str argument, and skip it. 61 if data[0] == 'None' or data[0] == 'str': 62 continue 63 64 # The argument test. 65 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.back_calc, ri_id='R2', ri_type=data[1])
66 67
69 """The frq arg test of the relax_data.back_calc() user function.""" 70 71 # Loop over the data types. 72 for data in DATA_TYPES: 73 # Catch the number arguments, and skip them. 74 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 75 continue 76 77 # The argument test. 78 self.assertRaises(RelaxNoneNumError, self.relax_data_fns.back_calc, ri_id='R2_1000', ri_type='R2', frq=data[1])
79 80
82 """The pipe_from arg test of the relax_data.copy() user function.""" 83 84 # Loop over the data types. 85 for data in DATA_TYPES: 86 # Catch the None and str arguments, and skip them. 87 if data[0] == 'None' or data[0] == 'str': 88 continue 89 90 # The argument test. 91 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.copy, pipe_from=data[1])
92 93
95 """The pipe_to arg test of the relax_data.copy() user function.""" 96 97 # Loop over the data types. 98 for data in DATA_TYPES: 99 # Catch the None and str arguments, and skip them. 100 if data[0] == 'None' or data[0] == 'str': 101 continue 102 103 # The argument test. 104 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.copy, pipe_from='', pipe_to=data[1])
105 106
108 """The pipe_from and pipe_to arg test of the relax_data.copy() user function.""" 109 110 # Test that both cannot be None (the default)! 111 self.assertRaises(RelaxError, self.relax_data_fns.copy)
112 113
114 - def test_copy_argfail_ri_id(self):
115 """The ri_id arg test of the relax_data.copy() user function.""" 116 117 # Loop over the data types. 118 for data in DATA_TYPES: 119 # Catch the str argument, and skip it. 120 if data[0] == 'None' or data[0] == 'str': 121 continue 122 123 # The argument test. 124 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.copy, pipe_from='', pipe_to='', ri_id=data[1])
125 126
128 """The ri_id arg test of the relax_data.delete() user function.""" 129 130 # Loop over the data types. 131 for data in DATA_TYPES: 132 # Catch the str argument, and skip it. 133 if data[0] == 'str': 134 continue 135 136 # The argument test. 137 self.assertRaises(RelaxStrError, self.relax_data_fns.delete, ri_id=data[1])
138 139
141 """The ri_id arg test of the relax_data.display() user function.""" 142 143 # Loop over the data types. 144 for data in DATA_TYPES: 145 # Catch the str argument, and skip it. 146 if data[0] == 'str': 147 continue 148 149 # The argument test. 150 self.assertRaises(RelaxStrError, self.relax_data_fns.display, ri_id=data[1])
151 152
153 - def test_read_argfail_ri_id(self):
154 """The ri_id arg test of the relax_data.read() user function.""" 155 156 # Loop over the data types. 157 for data in DATA_TYPES: 158 # Catch the str argument, and skip it. 159 if data[0] == 'str': 160 continue 161 162 # The argument test. 163 self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id=data[1])
164 165
167 """The ri_type arg test of the relax_data.read() user function.""" 168 169 # Loop over the data types. 170 for data in DATA_TYPES: 171 # Catch the str argument, and skip it. 172 if data[0] == 'str': 173 continue 174 175 # The argument test. 176 self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id='R2', ri_type=data[1])
177 178
179 - def test_read_argfail_frq(self):
180 """The frq arg test of the relax_data.read() user function.""" 181 182 # Loop over the data types. 183 for data in DATA_TYPES: 184 # Catch the number arguments, and skip them. 185 if data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 186 continue 187 188 # The argument test. 189 self.assertRaises(RelaxNumError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=data[1])
190 191
192 - def test_read_argfail_file(self):
193 """The file arg test of the relax_data.read() user function.""" 194 195 # Loop over the data types. 196 for data in DATA_TYPES: 197 # Catch the str argument, and skip it. 198 if data[0] == 'str': 199 continue 200 201 # The argument test. 202 self.assertRaises(RelaxStrError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file=data[1])
203 204
205 - def test_read_argfail_dir(self):
206 """The dir arg test of the relax_data.read() user function.""" 207 208 # Loop over the data types. 209 for data in DATA_TYPES: 210 # Catch the None and str arguments, and skip them. 211 if data[0] == 'None' or data[0] == 'str': 212 continue 213 214 # The argument test. 215 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', dir=data[1])
216 217
219 """The mol_name_col arg test of the relax_data.read() user function.""" 220 221 # Loop over the data types. 222 for data in DATA_TYPES: 223 # Catch the None, int, and bin arguments, and skip them. 224 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 225 continue 226 227 # The argument test. 228 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])
229 230
232 """The res_num_col arg test of the relax_data.read() user function.""" 233 234 # Loop over the data types. 235 for data in DATA_TYPES: 236 # Catch the None, int, and bin arguments, and skip them. 237 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 238 continue 239 240 # The argument test. 241 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])
242 243
245 """The res_name_col arg test of the relax_data.read() user function.""" 246 247 # Loop over the data types. 248 for data in DATA_TYPES: 249 # Catch the None, int, and bin arguments, and skip them. 250 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 251 continue 252 253 # The argument test. 254 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])
255 256
258 """The spin_num_col arg test of the relax_data.read() user function.""" 259 260 # Loop over the data types. 261 for data in DATA_TYPES: 262 # Catch the None, int, and bin arguments, and skip them. 263 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 264 continue 265 266 # The argument test. 267 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])
268 269
271 """The spin_name_col arg test of the relax_data.read() user function.""" 272 273 # Loop over the data types. 274 for data in DATA_TYPES: 275 # Catch the None, int, and bin arguments, and skip them. 276 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 277 continue 278 279 # The argument test. 280 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])
281 282
284 """The data_col arg test of the relax_data.read() user function.""" 285 286 # Loop over the data types. 287 for data in DATA_TYPES: 288 # Catch the int and bin arguments, and skip them. 289 if data[0] == 'int' or data[0] == 'bin': 290 continue 291 292 # The argument test. 293 self.assertRaises(RelaxIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', data_col=data[1])
294 295
297 """The error_col arg test of the relax_data.read() user function.""" 298 299 # Loop over the data types. 300 for data in DATA_TYPES: 301 # Catch the int and bin arguments, and skip them. 302 if data[0] == 'int' or data[0] == 'bin': 303 continue 304 305 # The argument test. 306 self.assertRaises(RelaxIntError, self.relax_data_fns.read, ri_id='R2_1000', ri_type='R2', frq=1e9, file='R2_1000MHz', error_col=data[1])
307 308
309 - def test_read_argfail_sep(self):
310 """The sep arg test of the relax_data.read() user function.""" 311 312 # Loop over the data types. 313 for data in DATA_TYPES: 314 # Catch the None and str arguments, and skip them. 315 if data[0] == 'None' or data[0] == 'str': 316 continue 317 318 # The argument test. 319 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])
320 321
322 - def test_write_argfail_ri_id(self):
323 """The ri_id arg test of the relax_data.write() user function.""" 324 325 # Loop over the data types. 326 for data in DATA_TYPES: 327 # Catch the str argument, and skip it. 328 if data[0] == 'str': 329 continue 330 331 # The argument test. 332 self.assertRaises(RelaxStrError, self.relax_data_fns.write, ri_id=data[1])
333 334
335 - def test_write_argfail_file(self):
336 """The file arg test of the relax_data.write() user function.""" 337 338 # Loop over the data types. 339 for data in DATA_TYPES: 340 # Catch the str argument, and skip it. 341 if data[0] == 'str': 342 continue 343 344 # The argument test. 345 self.assertRaises(RelaxStrError, self.relax_data_fns.write, ri_id='R2_1000', file=data[1])
346 347
348 - def test_write_argfail_dir(self):
349 """The dir arg test of the relax_data.write() user function.""" 350 351 # Loop over the data types. 352 for data in DATA_TYPES: 353 # Catch the None and str arguments, and skip them. 354 if data[0] == 'None' or data[0] == 'str': 355 continue 356 357 # The argument test. 358 self.assertRaises(RelaxNoneStrError, self.relax_data_fns.write, ri_id='R2_1000', file='a', dir=data[1])
359 360
361 - def test_write_argfail_force(self):
362 """The force arg test of the relax_data.write() user function.""" 363 364 # Loop over the data types. 365 for data in DATA_TYPES: 366 # Catch the bool arguments, and skip them. 367 if data[0] == 'bool': 368 continue 369 370 # The argument test. 371 self.assertRaises(RelaxBoolError, self.relax_data_fns.write, ri_id='R2_1000', file='a', force=data[1])
372