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

Source Code for Module test_suite.unit_tests._prompt.test_align_tensor

  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  # relax module imports. 
 24  from generic_fns import align_tensor 
 25  from prompt.interpreter import Interpreter 
 26  from relax_errors import RelaxError, RelaxBoolError, RelaxFloatError, RelaxIntError, RelaxNoneListStrError, RelaxNoneStrError, RelaxTupleNumError, RelaxStrError 
 27  from test_suite.unit_tests.align_tensor_testing_base import Align_tensor_base_class 
 28   
 29  # Unit test imports. 
 30  from data_types import DATA_TYPES 
 31   
 32   
33 -class Test_align_tensor(Align_tensor_base_class):
34 """Unit tests for the functions of the 'prompt.align_tensor' module.""" 35
36 - def __init__(self, methodName=None):
37 """Set up the test case class for the system tests.""" 38 39 # Execute the base __init__ methods. 40 super(Test_align_tensor, self).__init__(methodName) 41 42 # Load the interpreter. 43 self.interpreter = Interpreter(show_script=False, quit=False, raise_relax_error=True) 44 self.interpreter.populate_self() 45 self.interpreter.on(verbose=False) 46 47 # Alias the user function class. 48 self.align_tensor_fns = self.interpreter.align_tensor
49 50
52 """Failure of the tensor_from arg of the align_tensor.copy() user function.""" 53 54 # Loop over the data types. 55 for data in DATA_TYPES: 56 # Catch the str argument, and skip it. 57 if data[0] == 'str': 58 continue 59 60 # The argument test. 61 self.assertRaises(RelaxStrError, self.align_tensor_fns.copy, tensor_from=data[1])
62 63
65 """The pipe_from arg test of the align_tensor.copy() user function.""" 66 67 # Loop over the data types. 68 for data in DATA_TYPES: 69 # Catch the None and str arguments, and skip them. 70 if data[0] == 'None' or data[0] == 'str': 71 continue 72 73 # The argument test. 74 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.copy, tensor_from='Pf1', pipe_from=data[1])
75 76
78 """Failure of the tensor_to arg of the align_tensor.copy() user function.""" 79 80 # Loop over the data types. 81 for data in DATA_TYPES: 82 # Catch the str argument, and skip it. 83 if data[0] == 'str': 84 continue 85 86 # The argument test. 87 self.assertRaises(RelaxStrError, self.align_tensor_fns.copy, tensor_to=data[1])
88 89
91 """The pipe_to arg test of the align_tensor.copy() user function.""" 92 93 # Loop over the data types. 94 for data in DATA_TYPES: 95 # Catch the None and str arguments, and skip them. 96 if data[0] == 'None' or data[0] == 'str': 97 continue 98 99 # The argument test. 100 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.copy, tensor_from='Pf1', tensor_to='Pf1', pipe_to=data[1])
101 102
104 """The pipe_from and pipe_to arg test of the align_tensor.copy() user function.""" 105 106 # Test that both cannot be None (the default)! 107 self.assertRaises(RelaxError, self.align_tensor_fns.copy, tensor_from='Pf1', tensor_to='Pf1')
108 109
111 """Failure of the tensor arg of the align_tensor.delete() user function.""" 112 113 # Loop over the data types. 114 for data in DATA_TYPES: 115 # Catch the str argument, and skip it. 116 if data[0] == 'None' or data[0] == 'str': 117 continue 118 119 # The argument test. 120 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.delete, tensor=data[1])
121 122
124 """Failure of the tensor arg of the align_tensor.display() user function.""" 125 126 # Loop over the data types. 127 for data in DATA_TYPES: 128 # Catch the None and str arguments, and skip them. 129 if data[0] == 'None' or data[0] == 'str': 130 continue 131 132 # The argument test. 133 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.display, tensor=data[1])
134 135
136 - def test_init_argfail_tensor(self):
137 """Failure of the tensor arg of the align_tensor.init() user function.""" 138 139 # Loop over the data types. 140 for data in DATA_TYPES: 141 # Catch the str argument, and skip it. 142 if data[0] == 'str': 143 continue 144 145 # The argument test. 146 self.assertRaises(RelaxStrError, self.align_tensor_fns.init, tensor=data[1])
147 148
149 - def test_init_argfail_params(self):
150 """Failure of the params arg of the align_tensor.init() user function.""" 151 152 # Loop over the data types. 153 for data in DATA_TYPES: 154 # Catch the tuple arguments. 155 if data[0] == 'tuple' or data[0] == 'float tuple' or data[0] == 'str tuple': 156 # Correct tuple length. 157 if len(data[1]) == 5: 158 continue 159 160 # The argument test. 161 self.assertRaises(RelaxTupleNumError, self.align_tensor_fns.init, tensor='Pf1', params=data[1])
162 163
164 - def test_init_argfail_scale(self):
165 """The scale arg test of the align_tensor.init() user function.""" 166 167 # Loop over the data types. 168 for data in DATA_TYPES: 169 # Catch the float argument, and skip it. 170 if data[0] == 'float': 171 continue 172 173 # The argument test. 174 self.assertRaises(RelaxFloatError, self.align_tensor_fns.init, tensor='Pf1', params=(0.0, 0.0, 0.0, 0.0, 0.0), scale=data[1])
175 176
178 """The angle_units arg test of the align_tensor.init() user function.""" 179 180 # Loop over the data types. 181 for data in DATA_TYPES: 182 # Catch the str argument, and skip it. 183 if data[0] == 'str': 184 continue 185 186 # The argument test. 187 self.assertRaises(RelaxStrError, self.align_tensor_fns.init, params=(0.0, 0.0, 0.0, 0.0, 0.0), angle_units=data[1])
188 189
191 """The proper failure of the align_tensor.init() user function for the param_types argument.""" 192 193 # Loop over the data types. 194 for data in DATA_TYPES: 195 # Catch the int and bin arguments, and skip them. 196 if data[0] == 'int' or data[0] == 'bin': 197 continue 198 199 # The argument test. 200 self.assertRaises(RelaxIntError, self.align_tensor_fns.init, tensor='Pf1', params=(0.0, 0.0, 0.0, 0.0, 0.0), param_types=data[1])
201 202
203 - def test_init_argfail_errors(self):
204 """The errors arg test of the align_tensor.init() user function.""" 205 206 # Loop over the data types. 207 for data in DATA_TYPES: 208 # Catch the bool arguments, and skip them. 209 if data[0] == 'bool': 210 continue 211 212 # The argument test. 213 self.assertRaises(RelaxBoolError, self.align_tensor_fns.init, tensor='Pf1', params=(0.0, 0.0, 0.0, 0.0, 0.0), errors=data[1])
214 215
217 """The proper failure of the align_tensor.matrix_angles() user function for the basis_set argument.""" 218 219 # Add an alignment tensor. 220 align_tensor.init('a', (0.0, 0.0, 0.0, 0.0, 0.0)) 221 222 # Loop over the data types. 223 for data in DATA_TYPES: 224 # Catch the int and bin arguments, and skip them. 225 if data[0] == 'int' or data[0] == 'bin': 226 continue 227 228 # The argument test. 229 self.assertRaises(RelaxIntError, self.align_tensor_fns.matrix_angles, basis_set=data[1])
230 231
233 """The tensors arg unit test of the align_tensor.matrix_angles() user function.""" 234 235 # Add an alignment tensor. 236 align_tensor.init('a', (0.0, 0.0, 0.0, 0.0, 0.0)) 237 238 # Loop over the data types. 239 for data in DATA_TYPES: 240 # Catch the None and str list arguments, and skip them. 241 if data[0] == 'None' or data[0] == 'str list': 242 continue 243 244 # The argument test. 245 self.assertRaises(RelaxNoneListStrError, self.align_tensor_fns.matrix_angles, tensors=data[1])
246 247
249 """Failure of the full_tensor arg of the align_tensor.reduction() user function.""" 250 251 # Loop over the data types. 252 for data in DATA_TYPES: 253 # Catch the str argument, and skip it. 254 if data[0] == 'str': 255 continue 256 257 # The argument test. 258 self.assertRaises(RelaxStrError, self.align_tensor_fns.reduction, full_tensor=data[1])
259 260
262 """Failure of the red_tensor arg of the align_tensor.reduction() user function.""" 263 264 # Loop over the data types. 265 for data in DATA_TYPES: 266 # Catch the str argument, and skip it. 267 if data[0] == 'str': 268 continue 269 270 # The argument test. 271 self.assertRaises(RelaxStrError, self.align_tensor_fns.reduction, full_tensor='test', red_tensor=data[1])
272
274 """Failure of the tensor arg of the align_tensor.set_domain() user function.""" 275 276 # Loop over the data types. 277 for data in DATA_TYPES: 278 # Catch the str argument, and skip it. 279 if data[0] == 'str': 280 continue 281 282 # The argument test. 283 self.assertRaises(RelaxStrError, self.align_tensor_fns.set_domain, tensor=data[1])
284 285
287 """Failure of the domain arg of the align_tensor.set_domain() user function.""" 288 289 # Loop over the data types. 290 for data in DATA_TYPES: 291 # Catch the str argument, and skip it. 292 if data[0] == 'str': 293 continue 294 295 # The argument test. 296 self.assertRaises(RelaxStrError, self.align_tensor_fns.set_domain, domain=data[1])
297 298
300 """The proper failure of the align_tensor.svd() user function for the basis_set argument.""" 301 302 # Add an alignment tensor. 303 align_tensor.init('a', (0.0, 0.0, 0.0, 0.0, 0.0)) 304 305 # Loop over the data types. 306 for data in DATA_TYPES: 307 # Catch the int and bin arguments, and skip them. 308 if data[0] == 'int' or data[0] == 'bin': 309 continue 310 311 # The argument test. 312 self.assertRaises(RelaxIntError, self.align_tensor_fns.svd, basis_set=data[1])
313 314
316 """The tensors arg unit test of the align_tensor.svd() user function.""" 317 318 # Add an alignment tensor. 319 align_tensor.init('a', (0.0, 0.0, 0.0, 0.0, 0.0)) 320 321 # Loop over the data types. 322 for data in DATA_TYPES: 323 # Catch the None and str list arguments, and skip them. 324 if data[0] == 'None' or data[0] == 'str list': 325 continue 326 327 # The argument test. 328 self.assertRaises(RelaxNoneListStrError, self.align_tensor_fns.svd, tensors=data[1])
329