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

Source Code for Module test_suite.unit_tests._prompt.test_structure

  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 RelaxBoolError, RelaxFloatError, RelaxIntError, RelaxNoneIntError, RelaxNoneIntListIntError, RelaxNoneStrError, RelaxNoneStrListStrError, RelaxNumError, RelaxStrError 
 29  from test_suite.unit_tests.structure_testing_base import Structure_base_class 
 30   
 31  # Unit test imports. 
 32  from data_types import DATA_TYPES 
 33   
 34   
35 -class Test_structure(Structure_base_class, TestCase):
36 """Unit tests for the functions of the 'prompt.structure' 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_structure, 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.structure_fns = self.interpreter.structure
51 52
54 """The scale arg test of the structure.create_diff_tensor_pdb() user function.""" 55 56 # Loop over the data types. 57 for data in DATA_TYPES: 58 # Catch the float, bin, and int arguments, and skip them. 59 if data[0] == 'float' or data[0] == 'bin' or data[0] == 'int': 60 continue 61 62 # The argument test. 63 self.assertRaises(RelaxNumError, self.structure_fns.create_diff_tensor_pdb, scale=data[1])
64 65
67 """The file arg test of the structure.create_diff_tensor_pdb() user function.""" 68 69 # Loop over the data types. 70 for data in DATA_TYPES: 71 # Catch the str arguments, and skip them. 72 if data[0] == 'str': 73 continue 74 75 # The argument test. 76 self.assertRaises(RelaxStrError, self.structure_fns.create_diff_tensor_pdb, file=data[1])
77 78
80 """The dir arg test of the structure.create_diff_tensor_pdb() user function.""" 81 82 # Loop over the data types. 83 for data in DATA_TYPES: 84 # Catch the None and str arguments, and skip them. 85 if data[0] == 'None' or data[0] == 'str': 86 continue 87 88 # The argument test. 89 self.assertRaises(RelaxNoneStrError, self.structure_fns.create_diff_tensor_pdb, dir=data[1])
90 91
93 """The force arg test of the structure.create_diff_tensor_pdb() user function.""" 94 95 # Loop over the data types. 96 for data in DATA_TYPES: 97 # Catch the bool arguments, and skip them. 98 if data[0] == 'bool': 99 continue 100 101 # The argument test. 102 self.assertRaises(RelaxBoolError, self.structure_fns.create_diff_tensor_pdb, force=data[1])
103 104
106 """The length arg test of the structure.create_vector_dist() user function.""" 107 108 # Loop over the data types. 109 for data in DATA_TYPES: 110 # Catch the number arguments, and skip them. 111 if data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 112 continue 113 114 # The argument test. 115 self.assertRaises(RelaxNumError, self.structure_fns.create_vector_dist, length=data[1])
116 117
119 """The file arg test of the structure.create_vector_dist() user function.""" 120 121 # Loop over the data types. 122 for data in DATA_TYPES: 123 # Catch the str arguments, and skip them. 124 if data[0] == 'str': 125 continue 126 127 # The argument test. 128 self.assertRaises(RelaxStrError, self.structure_fns.create_vector_dist, file=data[1])
129 130
132 """The dir arg test of the structure.create_vector_dist() user function.""" 133 134 # Loop over the data types. 135 for data in DATA_TYPES: 136 # Catch the None and str arguments, and skip them. 137 if data[0] == 'None' or data[0] == 'str': 138 continue 139 140 # The argument test. 141 self.assertRaises(RelaxNoneStrError, self.structure_fns.create_vector_dist, dir=data[1])
142 143
145 """The symmetry arg test of the structure.create_vector_dist() user function.""" 146 147 # Loop over the data types. 148 for data in DATA_TYPES: 149 # Catch the bool arguments, and skip them. 150 if data[0] == 'bool': 151 continue 152 153 # The argument test. 154 self.assertRaises(RelaxBoolError, self.structure_fns.create_vector_dist, symmetry=data[1])
155 156
158 """The force arg test of the structure.create_vector_dist() user function.""" 159 160 # Loop over the data types. 161 for data in DATA_TYPES: 162 # Catch the bool arguments, and skip them. 163 if data[0] == 'bool': 164 continue 165 166 # The argument test. 167 self.assertRaises(RelaxBoolError, self.structure_fns.create_vector_dist, force=data[1])
168 169
171 """The spin_id arg test of the structure.load_spins() user function.""" 172 173 # Loop over the data types. 174 for data in DATA_TYPES: 175 # Catch the None and str arguments, and skip them. 176 if data[0] == 'None' or data[0] == 'str': 177 continue 178 179 # The argument test. 180 self.assertRaises(RelaxNoneStrError, self.structure_fns.load_spins, spin_id=data[1])
181 182
184 """The file arg test of the structure.read_pdb() user function.""" 185 186 # Loop over the data types. 187 for data in DATA_TYPES: 188 # Catch the str arguments, and skip them. 189 if data[0] == 'str': 190 continue 191 192 # The argument test. 193 self.assertRaises(RelaxStrError, self.structure_fns.read_pdb, file=data[1])
194 195
197 """The dir arg test of the structure.read_pdb() user function.""" 198 199 # Loop over the data types. 200 for data in DATA_TYPES: 201 # Catch the None and str arguments, and skip them. 202 if data[0] == 'None' or data[0] == 'str': 203 continue 204 205 # The argument test. 206 self.assertRaises(RelaxNoneStrError, self.structure_fns.read_pdb, file='test.pdb', dir=data[1])
207 208
210 """The read_mol arg test of the structure.read_pdb() user function.""" 211 212 # Loop over the data types. 213 for data in DATA_TYPES: 214 # Catch the None, bin, int, and int list arguments, and skip them. 215 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'int list': 216 continue 217 218 # The argument test. 219 self.assertRaises(RelaxNoneIntListIntError, self.structure_fns.read_pdb, file='test.pdb', read_mol=data[1])
220 221
223 """The set_mol_name arg test of the structure.read_pdb() user function.""" 224 225 # Loop over the data types. 226 for data in DATA_TYPES: 227 # Catch the None, str, and str list arguments, and skip them. 228 if data[0] == 'None' or data[0] == 'str' or data[0] == 'str list': 229 continue 230 231 # The argument test. 232 self.assertRaises(RelaxNoneStrListStrError, self.structure_fns.read_pdb, file='test.pdb', set_mol_name=data[1])
233 234
236 """The read_model arg test of the structure.read_pdb() user function.""" 237 238 # Loop over the data types. 239 for data in DATA_TYPES: 240 # Catch the None, bin, int, and int list arguments, and skip them. 241 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'int list': 242 continue 243 244 # The argument test. 245 self.assertRaises(RelaxNoneIntListIntError, self.structure_fns.read_pdb, file='test.pdb', read_model=data[1])
246 247
249 """The set_model_num arg test of the structure.read_pdb() user function.""" 250 251 # Loop over the data types. 252 for data in DATA_TYPES: 253 # Catch the None, bin, int, and int list arguments, and skip them. 254 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'int list': 255 continue 256 257 # The argument test. 258 self.assertRaises(RelaxNoneIntListIntError, self.structure_fns.read_pdb, file='test.pdb', set_model_num=data[1])
259 260
262 """The parser arg test of the structure.read_pdb() user function.""" 263 264 # Loop over the data types. 265 for data in DATA_TYPES: 266 # Catch the str arguments, and skip them. 267 if data[0] == 'str': 268 continue 269 270 # The argument test. 271 self.assertRaises(RelaxStrError, self.structure_fns.read_pdb, parser=data[1])
272 273
275 """The attached arg test of the structure.vectors() user function.""" 276 277 # Loop over the data types. 278 for data in DATA_TYPES: 279 # Catch the str arguments, and skip them. 280 if data[0] == 'str': 281 continue 282 283 # The argument test. 284 self.assertRaises(RelaxStrError, self.structure_fns.vectors, attached=data[1])
285 286
288 """The spin_id arg test of the structure.vectors() user function.""" 289 290 # Loop over the data types. 291 for data in DATA_TYPES: 292 # Catch the None and str arguments, and skip them. 293 if data[0] == 'None' or data[0] == 'str': 294 continue 295 296 # The argument test. 297 self.assertRaises(RelaxNoneStrError, self.structure_fns.vectors, spin_id=data[1])
298 299
301 """The model arg test of the structure.vectors() user function.""" 302 303 # Loop over the data types. 304 for data in DATA_TYPES: 305 # Catch the None, bin, and int arguments, and skip them. 306 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int': 307 continue 308 309 # The argument test. 310 self.assertRaises(RelaxNoneIntError, self.structure_fns.vectors, model=data[1])
311 312
314 """The verbosity arg test of the structure.vectors() user function.""" 315 316 # Loop over the data types. 317 for data in DATA_TYPES: 318 # Catch the bin and int arguments, and skip them. 319 if data[0] == 'bin' or data[0] == 'int': 320 continue 321 322 # The argument test. 323 self.assertRaises(RelaxIntError, self.structure_fns.vectors, verbosity=data[1])
324 325
326 - def test_vectors_argfail_ave(self):
327 """The ave arg test of the structure.vectors() user function.""" 328 329 # Loop over the data types. 330 for data in DATA_TYPES: 331 # Catch the bool arguments, and skip them. 332 if data[0] == 'bool': 333 continue 334 335 # The argument test. 336 self.assertRaises(RelaxBoolError, self.structure_fns.vectors, ave=data[1])
337 338
340 """The unit arg test of the structure.vectors() user function.""" 341 342 # Loop over the data types. 343 for data in DATA_TYPES: 344 # Catch the bool arguments, and skip them. 345 if data[0] == 'bool': 346 continue 347 348 # The argument test. 349 self.assertRaises(RelaxBoolError, self.structure_fns.vectors, unit=data[1])
350