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

Source Code for Module test_suite.unit_tests._prompt.test_diffusion_tensor

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2008, 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.diffusion_tensor import Diffusion_tensor 
 28  from relax_errors import RelaxError, RelaxBoolError, RelaxIntError, RelaxNoneStrError, RelaxNumError, RelaxNumTupleNumError, RelaxStrError 
 29  from test_suite.unit_tests.diffusion_tensor_testing_base import Diffusion_tensor_base_class 
 30   
 31  # Unit test imports. 
 32  from data_types import DATA_TYPES 
 33   
 34   
35 -class Test_diffusion_tensor(Diffusion_tensor_base_class, TestCase):
36 """Unit tests for the functions of the 'prompt.diffusion_tensor' module.""" 37 38 # Instantiate the user function class. 39 diffusion_tensor_fns = Diffusion_tensor() 40 41
43 """The pipe_from arg test of the diffusion_tensor.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.diffusion_tensor_fns.copy, pipe_from=data[1])
53 54
56 """The pipe_to arg test of the diffusion_tensor.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.diffusion_tensor_fns.copy, pipe_to=data[1])
66 67
69 """The pipe_from and pipe_to arg test of the diffusion_tensor.copy() user function.""" 70 71 # Test that both cannot be None (the default)! 72 self.assertRaises(RelaxError, self.diffusion_tensor_fns.copy)
73 74
75 - def test_init_argfail_params(self):
76 """The params arg test of diffusion_tensor.init() user function.""" 77 78 # Loop over the data types. 79 for data in DATA_TYPES: 80 # Catch a single float, int, or bin, and skip them. 81 if data[0] == 'int' or data[0] == 'bin' or data[0] == 'float': 82 continue 83 84 # Catch the tuple arguments. 85 if data[0] == 'tuple' or data[0] == 'float tuple' or data[0] == 'str tuple': 86 # Correct tuple length. 87 if len(data[1]) == 4 or len(data[1]) == 6: 88 continue 89 90 # The argument test. 91 self.assertRaises(RelaxNumTupleNumError, self.diffusion_tensor_fns.init, params=data[1])
92 93
95 """The time_scale arg test of the diffusion_tensor.init() user function.""" 96 97 # Loop over the data types. 98 for data in DATA_TYPES: 99 # Catch the number arguments, and skip them. 100 if data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 101 continue 102 103 # The argument test. 104 self.assertRaises(RelaxNumError, self.diffusion_tensor_fns.init, params=1e-9, time_scale=data[1])
105 106
108 """The d_scale arg test of the diffusion_tensor.init() user function.""" 109 110 # Loop over the data types. 111 for data in DATA_TYPES: 112 # Catch the number arguments, and skip them. 113 if data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 114 continue 115 116 # The argument test. 117 self.assertRaises(RelaxNumError, self.diffusion_tensor_fns.init, params=1e-9, d_scale=data[1])
118 119
121 """The angle_units arg test of the diffusion_tensor.init() user function.""" 122 123 # Loop over the data types. 124 for data in DATA_TYPES: 125 # Catch the str argument, and skip it. 126 if data[0] == 'str': 127 continue 128 129 # The argument test. 130 self.assertRaises(RelaxStrError, self.diffusion_tensor_fns.init, params=1e-9, angle_units=data[1])
131 132
134 """The param_types arg test of the diffusion_tensor.init() user function.""" 135 136 # Loop over the data types. 137 for data in DATA_TYPES: 138 # Catch the int and bin arguments, and skip them. 139 if data[0] == 'int' or data[0] == 'bin': 140 continue 141 142 # The argument test. 143 self.assertRaises(RelaxIntError, self.diffusion_tensor_fns.init, params=1e-9, param_types=data[1])
144 145
147 """The spheroid_type arg test of the diffusion_tensor.init() user function.""" 148 149 # Loop over the data types. 150 for data in DATA_TYPES: 151 # Catch the None and str arguments, and skip them. 152 if data[0] == 'None' or data[0] == 'str': 153 continue 154 155 # The argument test. 156 self.assertRaises(RelaxNoneStrError, self.diffusion_tensor_fns.init, params=1e-9, spheroid_type=data[1])
157 158
159 - def test_init_argfail_fixed(self):
160 """The fixed arg test of the diffusion_tensor.init() user function.""" 161 162 # Loop over the data types. 163 for data in DATA_TYPES: 164 # Catch the bool arguments, and skip them. 165 if data[0] == 'bool': 166 continue 167 168 # The argument test. 169 self.assertRaises(RelaxBoolError, self.diffusion_tensor_fns.init, params=1e-9, fixed=data[1])
170