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-2014 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program 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 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # relax module imports. 
 23  from pipe_control import align_tensor 
 24  from prompt.interpreter import Interpreter 
 25  from lib.errors import RelaxError, RelaxBoolError, RelaxFloatError, RelaxIntError, RelaxNoneListStrError, RelaxNoneStrError, RelaxTupleNumError, RelaxStrError 
 26  from test_suite.unit_tests.align_tensor_testing_base import Align_tensor_base_class 
 27   
 28  # Unit test imports. 
 29  from test_suite.unit_tests._prompt.data_types import DATA_TYPES 
 30   
 31   
32 -class Test_align_tensor(Align_tensor_base_class):
33 """Unit tests for the functions of the 'prompt.align_tensor' module.""" 34
35 - def __init__(self, methodName=None):
36 """Set up the test case class for the system tests.""" 37 38 # Execute the base __init__ methods. 39 super(Test_align_tensor, self).__init__(methodName) 40 41 # Load the interpreter. 42 self.interpreter = Interpreter(show_script=False, raise_relax_error=True) 43 self.interpreter.populate_self() 44 self.interpreter.on(verbose=False) 45 46 # Alias the user function class. 47 self.align_tensor_fns = self.interpreter.align_tensor
48 49
51 """Failure of the tensor_from arg of the align_tensor.copy() user function.""" 52 53 # Loop over the data types. 54 for data in DATA_TYPES: 55 # Catch the str argument, and skip it. 56 if data[0] == 'str': 57 continue 58 59 # The argument test. 60 self.assertRaises(RelaxStrError, self.align_tensor_fns.copy, tensor_from=data[1])
61 62
64 """The pipe_from arg test of the align_tensor.copy() user function.""" 65 66 # Loop over the data types. 67 for data in DATA_TYPES: 68 # Catch the None and str arguments, and skip them. 69 if data[0] == 'None' or data[0] == 'str': 70 continue 71 72 # The argument test. 73 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.copy, tensor_from='Pf1', pipe_from=data[1])
74 75
77 """Failure of the tensor_to arg of the align_tensor.copy() user function.""" 78 79 # Loop over the data types. 80 for data in DATA_TYPES: 81 # Catch the str argument, and skip it. 82 if data[0] == 'str': 83 continue 84 85 # The argument test. 86 self.assertRaises(RelaxStrError, self.align_tensor_fns.copy, tensor_to=data[1])
87 88
90 """The pipe_to arg test of the align_tensor.copy() user function.""" 91 92 # Loop over the data types. 93 for data in DATA_TYPES: 94 # Catch the None and str arguments, and skip them. 95 if data[0] == 'None' or data[0] == 'str': 96 continue 97 98 # The argument test. 99 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.copy, tensor_from='Pf1', tensor_to='Pf1', pipe_to=data[1])
100 101
103 """The pipe_from and pipe_to arg test of the align_tensor.copy() user function.""" 104 105 # Test that both cannot be None (the default)! 106 self.assertRaises(RelaxError, self.align_tensor_fns.copy, tensor_from='Pf1', tensor_to='Pf1')
107 108
110 """Failure of the tensor arg of the align_tensor.delete() user function.""" 111 112 # Loop over the data types. 113 for data in DATA_TYPES: 114 # Catch the str argument, and skip it. 115 if data[0] == 'None' or data[0] == 'str': 116 continue 117 118 # The argument test. 119 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.delete, tensor=data[1])
120 121
123 """Failure of the tensor arg of the align_tensor.display() user function.""" 124 125 # Loop over the data types. 126 for data in DATA_TYPES: 127 # Catch the None and str arguments, and skip them. 128 if data[0] == 'None' or data[0] == 'str': 129 continue 130 131 # The argument test. 132 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.display, tensor=data[1])
133 134
135 - def test_init_argfail_tensor(self):
136 """Failure of the tensor arg of the align_tensor.init() user function.""" 137 138 # Loop over the data types. 139 for data in DATA_TYPES: 140 # Catch the None and str arguments, and skip them. 141 if data[0] == 'None' or data[0] == 'str': 142 continue 143 144 # The argument test. 145 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.init, tensor=data[1])
146 147
149 """Failure of the align_id arg of the align_tensor.init() user function.""" 150 151 # Loop over the data types. 152 for data in DATA_TYPES: 153 # Catch the str argument, and skip it. 154 if data[0] == 'str': 155 continue 156 157 # The argument test. 158 self.assertRaises(RelaxStrError, self.align_tensor_fns.init, align_id=data[1])
159 160
161 - def test_init_argfail_domain(self):
162 """Failure of the domain arg of the align_tensor.init() user function.""" 163 164 # Loop over the data types. 165 for data in DATA_TYPES: 166 # Catch the None and str arguments, and skip them. 167 if data[0] == 'None' or data[0] == 'str': 168 continue 169 170 # The argument test. 171 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.init, align_id='Pf1', domain=data[1])
172 173
174 - def test_init_argfail_params(self):
175 """Failure of the params arg of the align_tensor.init() user function.""" 176 177 # Loop over the data types. 178 for data in DATA_TYPES: 179 # Catch the tuple arguments. 180 if data[0] == 'tuple' or data[0] == 'float tuple' or data[0] == 'str tuple': 181 # Correct tuple length. 182 if len(data[1]) == 5: 183 continue 184 185 # The argument test. 186 self.assertRaises(RelaxTupleNumError, self.align_tensor_fns.init, align_id='Pf1', params=data[1])
187 188
189 - def test_init_argfail_scale(self):
190 """The scale arg test of the align_tensor.init() user function.""" 191 192 # Loop over the data types. 193 for data in DATA_TYPES: 194 # Catch the float argument, and skip it. 195 if data[0] == 'float': 196 continue 197 198 # The argument test. 199 self.assertRaises(RelaxFloatError, self.align_tensor_fns.init, align_id='Pf1', params=(0.0, 0.0, 0.0, 0.0, 0.0), scale=data[1])
200 201
203 """The angle_units arg test of the align_tensor.init() user function.""" 204 205 # Loop over the data types. 206 for data in DATA_TYPES: 207 # Catch the str argument, and skip it. 208 if data[0] == 'str': 209 continue 210 211 # The argument test. 212 self.assertRaises(RelaxStrError, self.align_tensor_fns.init, params=(0.0, 0.0, 0.0, 0.0, 0.0), angle_units=data[1])
213 214
216 """The proper failure of the align_tensor.init() user function for the param_types argument.""" 217 218 # Loop over the data types. 219 for data in DATA_TYPES: 220 # Catch the int and bin arguments, and skip them. 221 if data[0] == 'int' or data[0] == 'bin': 222 continue 223 224 # The argument test. 225 self.assertRaises(RelaxIntError, self.align_tensor_fns.init, align_id='Pf1', params=(0.0, 0.0, 0.0, 0.0, 0.0), param_types=data[1])
226 227
228 - def test_init_argfail_errors(self):
229 """The errors arg test of the align_tensor.init() user function.""" 230 231 # Loop over the data types. 232 for data in DATA_TYPES: 233 # Catch the bool arguments, and skip them. 234 if data[0] == 'bool': 235 continue 236 237 # The argument test. 238 self.assertRaises(RelaxBoolError, self.align_tensor_fns.init, align_id='Pf1', params=(0.0, 0.0, 0.0, 0.0, 0.0), errors=data[1])
239 240
242 """The proper failure of the align_tensor.matrix_angles() user function for the basis_set argument.""" 243 244 # Add an alignment tensor. 245 align_tensor.init(align_id='a', params=(0.0, 0.0, 0.0, 0.0, 0.0)) 246 247 # Loop over the data types. 248 for data in DATA_TYPES: 249 # Catch the int and bin arguments, and skip them. 250 if data[0] == 'int' or data[0] == 'bin': 251 continue 252 253 # The argument test. 254 self.assertRaises(RelaxIntError, self.align_tensor_fns.matrix_angles, basis_set=data[1])
255 256
258 """The tensors arg unit test of the align_tensor.matrix_angles() user function.""" 259 260 # Add an alignment tensor. 261 align_tensor.init(align_id='a', params=(0.0, 0.0, 0.0, 0.0, 0.0)) 262 263 # Loop over the data types. 264 for data in DATA_TYPES: 265 # Catch the None and str list arguments, and skip them. 266 if data[0] == 'None' or data[0] == 'str list': 267 continue 268 269 # The argument test. 270 self.assertRaises(RelaxNoneListStrError, self.align_tensor_fns.matrix_angles, tensors=data[1])
271 272
274 """Failure of the full_tensor arg of the align_tensor.reduction() 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.reduction, full_tensor=data[1])
284 285
287 """Failure of the red_tensor arg of the align_tensor.reduction() 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.reduction, full_tensor='test', red_tensor=data[1])
297
299 """Failure of the tensor arg of the align_tensor.set_domain() user function.""" 300 301 # Loop over the data types. 302 for data in DATA_TYPES: 303 # Catch the str argument, and skip it. 304 if data[0] == 'str': 305 continue 306 307 # The argument test. 308 self.assertRaises(RelaxStrError, self.align_tensor_fns.set_domain, tensor=data[1])
309 310
312 """Failure of the domain arg of the align_tensor.set_domain() user function.""" 313 314 # Loop over the data types. 315 for data in DATA_TYPES: 316 # Catch the str argument, and skip it. 317 if data[0] == 'str': 318 continue 319 320 # The argument test. 321 self.assertRaises(RelaxStrError, self.align_tensor_fns.set_domain, domain=data[1])
322 323
325 """The proper failure of the align_tensor.svd() user function for the basis_set argument.""" 326 327 # Add an alignment tensor. 328 align_tensor.init(align_id='a', params=(0.0, 0.0, 0.0, 0.0, 0.0)) 329 330 # Loop over the data types. 331 for data in DATA_TYPES: 332 # Catch the int and bin arguments, and skip them. 333 if data[0] == 'int' or data[0] == 'bin': 334 continue 335 336 # The argument test. 337 self.assertRaises(RelaxIntError, self.align_tensor_fns.svd, basis_set=data[1])
338 339
341 """The tensors arg unit test of the align_tensor.svd() user function.""" 342 343 # Add an alignment tensor. 344 align_tensor.init(align_id='a', params=(0.0, 0.0, 0.0, 0.0, 0.0)) 345 346 # Loop over the data types. 347 for data in DATA_TYPES: 348 # Catch the None and str list arguments, and skip them. 349 if data[0] == 'None' or data[0] == 'str list': 350 continue 351 352 # The argument test. 353 self.assertRaises(RelaxNoneListStrError, self.align_tensor_fns.svd, tensors=data[1])
354