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

Source Code for Module test_suite.unit_tests._prompt.test_sequence

  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, RelaxNoneIntError, RelaxNoneStrError, RelaxStrError 
 29  from test_suite.unit_tests.sequence_testing_base import Sequence_base_class 
 30   
 31  # Unit test imports. 
 32  from data_types import DATA_TYPES 
 33   
 34   
35 -class Test_sequence(Sequence_base_class, TestCase):
36 """Unit tests for the functions of the 'prompt.sequence' 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_sequence, 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.sequence_fns = self.interpreter.sequence
51 52
54 """The pipe_from arg test of the sequence.copy() user function.""" 55 56 # Loop over the data types. 57 for data in DATA_TYPES: 58 # Catch the None and str arguments, and skip them. 59 if data[0] == 'None' or data[0] == 'str': 60 continue 61 62 # The argument test. 63 self.assertRaises(RelaxNoneStrError, self.sequence_fns.copy, pipe_from=data[1])
64 65
67 """The pipe_to arg test of the sequence.copy() user function.""" 68 69 # Loop over the data types. 70 for data in DATA_TYPES: 71 # Catch the None and str arguments, and skip them. 72 if data[0] == 'None' or data[0] == 'str': 73 continue 74 75 # The argument test. 76 self.assertRaises(RelaxNoneStrError, self.sequence_fns.copy, pipe_to=data[1])
77 78
80 """The pipe_from and pipe_to arg test of the sequence.copy() user function.""" 81 82 # Test that both cannot be None (the default)! 83 self.assertRaises(RelaxError, self.sequence_fns.copy)
84 85
86 - def test_display_argfail_sep(self):
87 """The proper failure of the sequence.display() user function for the sep argument.""" 88 89 # Loop over the data types. 90 for data in DATA_TYPES: 91 # Catch the None and str arguments, and skip them. 92 if data[0] == 'None' or data[0] == 'str': 93 continue 94 95 # The argument test. 96 self.assertRaises(RelaxNoneStrError, self.sequence_fns.display, sep=data[1])
97 98
100 """The proper failure of the sequence.display() user function for the mol_name_flag argument.""" 101 102 # Loop over the data types. 103 for data in DATA_TYPES: 104 # Catch the bool arguments, and skip them. 105 if data[0] == 'bool': 106 continue 107 108 # The argument test. 109 self.assertRaises(RelaxBoolError, self.sequence_fns.display, mol_name_flag=data[1])
110 111
113 """The proper failure of the sequence.display() user function for the res_num_flag argument.""" 114 115 # Loop over the data types. 116 for data in DATA_TYPES: 117 # Catch the bool arguments, and skip them. 118 if data[0] == 'bool': 119 continue 120 121 # The argument test. 122 self.assertRaises(RelaxBoolError, self.sequence_fns.display, res_num_flag=data[1])
123 124
126 """The proper failure of the sequence.display() user function for the res_name_flag argument.""" 127 128 # Loop over the data types. 129 for data in DATA_TYPES: 130 # Catch the bool arguments, and skip them. 131 if data[0] == 'bool': 132 continue 133 134 # The argument test. 135 self.assertRaises(RelaxBoolError, self.sequence_fns.display, res_name_flag=data[1])
136 137
139 """The proper failure of the sequence.display() user function for the spin_num_flag argument.""" 140 141 # Loop over the data types. 142 for data in DATA_TYPES: 143 # Catch the bool arguments, and skip them. 144 if data[0] == 'bool': 145 continue 146 147 # The argument test. 148 self.assertRaises(RelaxBoolError, self.sequence_fns.display, spin_num_flag=data[1])
149 150
152 """The proper failure of the sequence.display() user function for the spin_name_flag argument.""" 153 154 # Loop over the data types. 155 for data in DATA_TYPES: 156 # Catch the bool arguments, and skip them. 157 if data[0] == 'bool': 158 continue 159 160 # The argument test. 161 self.assertRaises(RelaxBoolError, self.sequence_fns.display, spin_name_flag=data[1])
162 163
164 - def test_read_argfail_file(self):
165 """Test the proper failure of the sequence.read() user function for the file argument.""" 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.sequence_fns.read, file=data[1])
175 176
177 - def test_read_argfail_dir(self):
178 """Test the proper failure of the sequence.read() user function for the dir argument.""" 179 180 # Loop over the data types. 181 for data in DATA_TYPES: 182 # Catch the None and str arguments, and skip them. 183 if data[0] == 'None' or data[0] == 'str': 184 continue 185 186 # The argument test. 187 self.assertRaises(RelaxNoneStrError, self.sequence_fns.read, file='a', dir=data[1])
188 189
191 """The proper failure of the sequence.read() user function for the mol_name_col argument.""" 192 193 # Loop over the data types. 194 for data in DATA_TYPES: 195 # Catch the None, int, and bin arguments, and skip them. 196 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 197 continue 198 199 # The argument test. 200 self.assertRaises(RelaxNoneIntError, self.sequence_fns.read, file='a', mol_name_col=data[1])
201 202
204 """The proper failure of the sequence.read() user function for the res_num_col argument.""" 205 206 # Loop over the data types. 207 for data in DATA_TYPES: 208 # Catch the None, int, and bin arguments, and skip them. 209 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 210 continue 211 212 # The argument test. 213 self.assertRaises(RelaxNoneIntError, self.sequence_fns.read, file='a', res_num_col=data[1])
214 215
217 """The proper failure of the sequence.read() user function for the res_name_col argument.""" 218 219 # Loop over the data types. 220 for data in DATA_TYPES: 221 # Catch the None, int, and bin arguments, and skip them. 222 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 223 continue 224 225 # The argument test. 226 self.assertRaises(RelaxNoneIntError, self.sequence_fns.read, file='a', res_name_col=data[1])
227 228
230 """The proper failure of the sequence.read() user function for the spin_num_col argument.""" 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.sequence_fns.read, file='a', spin_num_col=data[1])
240 241
243 """The proper failure of the sequence.read() user function for the spin_name_col argument.""" 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.sequence_fns.read, file='a', spin_name_col=data[1])
253 254
255 - def test_read_argfail_sep(self):
256 """The proper failure of the sequence.read() user function for the sep argument.""" 257 258 # Loop over the data types. 259 for data in DATA_TYPES: 260 # Catch the None and str arguments, and skip them. 261 if data[0] == 'None' or data[0] == 'str': 262 continue 263 264 # The argument test. 265 self.assertRaises(RelaxNoneStrError, self.sequence_fns.read, file='a', sep=data[1])
266 267
268 - def test_write_argfail_file(self):
269 """Test the proper failure of the sequence.write() user function for the file argument.""" 270 271 # Loop over the data types. 272 for data in DATA_TYPES: 273 # Catch the str argument, and skip it. 274 if data[0] == 'str': 275 continue 276 277 # The argument test. 278 self.assertRaises(RelaxStrError, self.sequence_fns.write, file=data[1])
279 280
281 - def test_write_argfail_dir(self):
282 """Test the proper failure of the sequence.write() user function for the dir argument.""" 283 284 # Loop over the data types. 285 for data in DATA_TYPES: 286 # Catch the None and str arguments, and skip them. 287 if data[0] == 'None' or data[0] == 'str': 288 continue 289 290 # The argument test. 291 self.assertRaises(RelaxNoneStrError, self.sequence_fns.write, file='a', dir=data[1])
292 293
295 """The proper failure of the sequence.write() user function for the mol_name_flag argument.""" 296 297 # Loop over the data types. 298 for data in DATA_TYPES: 299 # Catch the bool arguments, and skip them. 300 if data[0] == 'bool': 301 continue 302 303 # The argument test. 304 self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', mol_name_flag=data[1])
305 306
308 """The proper failure of the sequence.write() user function for the res_num_flag argument.""" 309 310 # Loop over the data types. 311 for data in DATA_TYPES: 312 # Catch the bool arguments, and skip them. 313 if data[0] == 'bool': 314 continue 315 316 # The argument test. 317 self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', res_num_flag=data[1])
318 319
321 """The proper failure of the sequence.write() user function for the res_name_flag argument.""" 322 323 # Loop over the data types. 324 for data in DATA_TYPES: 325 # Catch the bool arguments, and skip them. 326 if data[0] == 'bool': 327 continue 328 329 # The argument test. 330 self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', res_name_flag=data[1])
331 332
334 """The proper failure of the sequence.write() user function for the spin_num_flag argument.""" 335 336 # Loop over the data types. 337 for data in DATA_TYPES: 338 # Catch the bool arguments, and skip them. 339 if data[0] == 'bool': 340 continue 341 342 # The argument test. 343 self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', spin_num_flag=data[1])
344 345
347 """The proper failure of the sequence.write() user function for the spin_name_flag argument.""" 348 349 # Loop over the data types. 350 for data in DATA_TYPES: 351 # Catch the bool arguments, and skip them. 352 if data[0] == 'bool': 353 continue 354 355 # The argument test. 356 self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', spin_name_flag=data[1])
357 358
359 - def test_write_argfail_sep(self):
360 """The proper failure of the sequence.write() user function for the sep argument.""" 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.sequence_fns.write, file='a', sep=data[1])
370 371
372 - def test_write_argfail_force(self):
373 """The force arg test of the sequence.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.sequence_fns.write, file='a', force=data[1])
383