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, 2010 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.sequence import Sequence 
 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 # Instantiate the user function class. 39 sequence_fns = Sequence() 40 41
43 """The pipe_from arg test of the sequence.copy() user function.""" 44 45 # Loop over the data types. 46 for data in DATA_TYPES: 47 # Catch the None and str arguments, and skip them. 48 if data[0] == 'None' or data[0] == 'str': 49 continue 50 51 # The argument test. 52 self.assertRaises(RelaxNoneStrError, self.sequence_fns.copy, pipe_from=data[1])
53 54
56 """The pipe_to arg test of the sequence.copy() user function.""" 57 58 # Loop over the data types. 59 for data in DATA_TYPES: 60 # Catch the None and str arguments, and skip them. 61 if data[0] == 'None' or data[0] == 'str': 62 continue 63 64 # The argument test. 65 self.assertRaises(RelaxNoneStrError, self.sequence_fns.copy, pipe_to=data[1])
66 67
69 """The pipe_from and pipe_to arg test of the sequence.copy() user function.""" 70 71 # Test that both cannot be None (the default)! 72 self.assertRaises(RelaxError, self.sequence_fns.copy)
73 74
75 - def test_display_argfail_sep(self):
76 """The proper failure of the sequence.display() user function for the sep argument.""" 77 78 # Loop over the data types. 79 for data in DATA_TYPES: 80 # Catch the None and str arguments, and skip them. 81 if data[0] == 'None' or data[0] == 'str': 82 continue 83 84 # The argument test. 85 self.assertRaises(RelaxNoneStrError, self.sequence_fns.display, sep=data[1])
86 87
89 """The proper failure of the sequence.display() user function for the mol_name_flag argument.""" 90 91 # Loop over the data types. 92 for data in DATA_TYPES: 93 # Catch the bool arguments, and skip them. 94 if data[0] == 'bool': 95 continue 96 97 # The argument test. 98 self.assertRaises(RelaxBoolError, self.sequence_fns.display, mol_name_flag=data[1])
99 100
102 """The proper failure of the sequence.display() user function for the res_num_flag argument.""" 103 104 # Loop over the data types. 105 for data in DATA_TYPES: 106 # Catch the bool arguments, and skip them. 107 if data[0] == 'bool': 108 continue 109 110 # The argument test. 111 self.assertRaises(RelaxBoolError, self.sequence_fns.display, res_num_flag=data[1])
112 113
115 """The proper failure of the sequence.display() user function for the res_name_flag argument.""" 116 117 # Loop over the data types. 118 for data in DATA_TYPES: 119 # Catch the bool arguments, and skip them. 120 if data[0] == 'bool': 121 continue 122 123 # The argument test. 124 self.assertRaises(RelaxBoolError, self.sequence_fns.display, res_name_flag=data[1])
125 126
128 """The proper failure of the sequence.display() user function for the spin_num_flag argument.""" 129 130 # Loop over the data types. 131 for data in DATA_TYPES: 132 # Catch the bool arguments, and skip them. 133 if data[0] == 'bool': 134 continue 135 136 # The argument test. 137 self.assertRaises(RelaxBoolError, self.sequence_fns.display, spin_num_flag=data[1])
138 139
141 """The proper failure of the sequence.display() user function for the spin_name_flag argument.""" 142 143 # Loop over the data types. 144 for data in DATA_TYPES: 145 # Catch the bool arguments, and skip them. 146 if data[0] == 'bool': 147 continue 148 149 # The argument test. 150 self.assertRaises(RelaxBoolError, self.sequence_fns.display, spin_name_flag=data[1])
151 152
153 - def test_read_argfail_file(self):
154 """Test the proper failure of the sequence.read() user function for the file argument.""" 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.sequence_fns.read, file=data[1])
164 165
166 - def test_read_argfail_dir(self):
167 """Test the proper failure of the sequence.read() user function for the dir argument.""" 168 169 # Loop over the data types. 170 for data in DATA_TYPES: 171 # Catch the None and str arguments, and skip them. 172 if data[0] == 'None' or data[0] == 'str': 173 continue 174 175 # The argument test. 176 self.assertRaises(RelaxNoneStrError, self.sequence_fns.read, file='a', dir=data[1])
177 178
180 """The proper failure of the sequence.read() user function for the mol_name_col argument.""" 181 182 # Loop over the data types. 183 for data in DATA_TYPES: 184 # Catch the None, int, and bin arguments, and skip them. 185 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 186 continue 187 188 # The argument test. 189 self.assertRaises(RelaxNoneIntError, self.sequence_fns.read, file='a', mol_name_col=data[1])
190 191
193 """The proper failure of the sequence.read() user function for the res_num_col argument.""" 194 195 # Loop over the data types. 196 for data in DATA_TYPES: 197 # Catch the None, int, and bin arguments, and skip them. 198 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 199 continue 200 201 # The argument test. 202 self.assertRaises(RelaxNoneIntError, self.sequence_fns.read, file='a', res_num_col=data[1])
203 204
206 """The proper failure of the sequence.read() user function for the res_name_col argument.""" 207 208 # Loop over the data types. 209 for data in DATA_TYPES: 210 # Catch the None, int, and bin arguments, and skip them. 211 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 212 continue 213 214 # The argument test. 215 self.assertRaises(RelaxNoneIntError, self.sequence_fns.read, file='a', res_name_col=data[1])
216 217
219 """The proper failure of the sequence.read() user function for the spin_num_col argument.""" 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.sequence_fns.read, file='a', spin_num_col=data[1])
229 230
232 """The proper failure of the sequence.read() user function for the spin_name_col argument.""" 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.sequence_fns.read, file='a', spin_name_col=data[1])
242 243
244 - def test_read_argfail_sep(self):
245 """The proper failure of the sequence.read() user function for the sep argument.""" 246 247 # Loop over the data types. 248 for data in DATA_TYPES: 249 # Catch the None and str arguments, and skip them. 250 if data[0] == 'None' or data[0] == 'str': 251 continue 252 253 # The argument test. 254 self.assertRaises(RelaxNoneStrError, self.sequence_fns.read, file='a', sep=data[1])
255 256
257 - def test_write_argfail_file(self):
258 """Test the proper failure of the sequence.write() user function for the file argument.""" 259 260 # Loop over the data types. 261 for data in DATA_TYPES: 262 # Catch the str argument, and skip it. 263 if data[0] == 'str': 264 continue 265 266 # The argument test. 267 self.assertRaises(RelaxStrError, self.sequence_fns.write, file=data[1])
268 269
270 - def test_write_argfail_dir(self):
271 """Test the proper failure of the sequence.write() user function for the dir argument.""" 272 273 # Loop over the data types. 274 for data in DATA_TYPES: 275 # Catch the None and str arguments, and skip them. 276 if data[0] == 'None' or data[0] == 'str': 277 continue 278 279 # The argument test. 280 self.assertRaises(RelaxNoneStrError, self.sequence_fns.write, file='a', dir=data[1])
281 282
284 """The proper failure of the sequence.write() user function for the mol_name_flag argument.""" 285 286 # Loop over the data types. 287 for data in DATA_TYPES: 288 # Catch the bool arguments, and skip them. 289 if data[0] == 'bool': 290 continue 291 292 # The argument test. 293 self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', mol_name_flag=data[1])
294 295
297 """The proper failure of the sequence.write() user function for the res_num_flag argument.""" 298 299 # Loop over the data types. 300 for data in DATA_TYPES: 301 # Catch the bool arguments, and skip them. 302 if data[0] == 'bool': 303 continue 304 305 # The argument test. 306 self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', res_num_flag=data[1])
307 308
310 """The proper failure of the sequence.write() user function for the res_name_flag argument.""" 311 312 # Loop over the data types. 313 for data in DATA_TYPES: 314 # Catch the bool arguments, and skip them. 315 if data[0] == 'bool': 316 continue 317 318 # The argument test. 319 self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', res_name_flag=data[1])
320 321
323 """The proper failure of the sequence.write() user function for the spin_num_flag argument.""" 324 325 # Loop over the data types. 326 for data in DATA_TYPES: 327 # Catch the bool arguments, and skip them. 328 if data[0] == 'bool': 329 continue 330 331 # The argument test. 332 self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', spin_num_flag=data[1])
333 334
336 """The proper failure of the sequence.write() user function for the spin_name_flag argument.""" 337 338 # Loop over the data types. 339 for data in DATA_TYPES: 340 # Catch the bool arguments, and skip them. 341 if data[0] == 'bool': 342 continue 343 344 # The argument test. 345 self.assertRaises(RelaxBoolError, self.sequence_fns.write, file='a', spin_name_flag=data[1])
346 347
348 - def test_write_argfail_sep(self):
349 """The proper failure of the sequence.write() user function for the sep argument.""" 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.sequence_fns.write, file='a', sep=data[1])
359 360
361 - def test_write_argfail_force(self):
362 """The force arg test of the sequence.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.sequence_fns.write, file='a', force=data[1])
372