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

Source Code for Module test_suite.unit_tests._prompt.test_spectrum

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 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.spectrum import Spectrum 
 28  from relax_errors import RelaxIntError, RelaxListIntError, RelaxNoneIntError, RelaxNoneIntListIntError, RelaxNoneStrError, RelaxNumError, RelaxStrError 
 29   
 30  # Unit test imports. 
 31  from data_types import DATA_TYPES 
 32   
 33   
34 -class Test_spectrum(TestCase):
35 """Unit tests for the functions of the 'prompt.spectrum' module.""" 36 37 # Instantiate the user function class. 38 spectrum_fns = Spectrum() 39 40
42 """The error arg test of the spectrum.baseplane_rmsd() user function.""" 43 44 # Loop over the data types. 45 for data in DATA_TYPES: 46 # Catch the float, bin, and int arguments, and skip them. 47 if data[0] == 'float' or data[0] == 'bin' or data[0] == 'int': 48 continue 49 50 # The argument test. 51 self.assertRaises(RelaxNumError, self.spectrum_fns.baseplane_rmsd, error=data[1])
52 53
55 """The spectrum_id arg test of the spectrum.baseplane_rmsd() user function.""" 56 57 # Loop over the data types. 58 for data in DATA_TYPES: 59 # Catch the str arguments, and skip them. 60 if data[0] == 'str': 61 continue 62 63 # The argument test. 64 self.assertRaises(RelaxStrError, self.spectrum_fns.baseplane_rmsd, spectrum_id=data[1])
65 66
68 """The spin_id arg test of the spectrum.baseplane_rmsd() user function.""" 69 70 # Loop over the data types. 71 for data in DATA_TYPES: 72 # Catch the None and str arguments, and skip them. 73 if data[0] == 'None' or data[0] == 'str': 74 continue 75 76 # The argument test. 77 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.baseplane_rmsd, spectrum_id='x', spin_id=data[1])
78 79
81 """The N arg test of the spectrum.integration_points() user function.""" 82 83 # Loop over the data types. 84 for data in DATA_TYPES: 85 # Catch the bin and int arguments, and skip them. 86 if data[0] == 'bin' or data[0] == 'int': 87 continue 88 89 # The argument test. 90 self.assertRaises(RelaxIntError, self.spectrum_fns.integration_points, N=data[1])
91 92
94 """The spectrum_id arg test of the spectrum.integration_points() user function.""" 95 96 # Loop over the data types. 97 for data in DATA_TYPES: 98 # Catch the str arguments, and skip them. 99 if data[0] == 'str': 100 continue 101 102 # The argument test. 103 self.assertRaises(RelaxStrError, self.spectrum_fns.integration_points, N=0, spectrum_id=data[1])
104 105
107 """The spin_id arg test of the spectrum.integration_points() user function.""" 108 109 # Loop over the data types. 110 for data in DATA_TYPES: 111 # Catch the None and str arguments, and skip them. 112 if data[0] == 'None' or data[0] == 'str': 113 continue 114 115 # The argument test. 116 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.integration_points, N=0, spectrum_id='x', spin_id=data[1])
117 118
120 """The file arg test of the spectrum.read_intensities() user function.""" 121 122 # Loop over the data types. 123 for data in DATA_TYPES: 124 # Catch the str argument, and skip it. 125 if data[0] == 'str': 126 continue 127 128 # The argument test. 129 self.assertRaises(RelaxStrError, self.spectrum_fns.read_intensities, file=data[1])
130 131
133 """The dir arg test of the spectrum.read_intensities() user function.""" 134 135 # Loop over the data types. 136 for data in DATA_TYPES: 137 # Catch the None and str arguments, and skip them. 138 if data[0] == 'None' or data[0] == 'str': 139 continue 140 141 # The argument test. 142 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.read_intensities, file='a', dir=data[1])
143 144
146 """The spectrum_id arg test of the spectrum.read_intensities() user function.""" 147 148 # Loop over the data types. 149 for data in DATA_TYPES: 150 # Catch the str arguments, and skip them. 151 if data[0] == 'str': 152 continue 153 154 # The argument test. 155 self.assertRaises(RelaxStrError, self.spectrum_fns.read_intensities, spectrum_id=data[1])
156 157
159 """The heteronuc arg test of the spectrum.read_intensities() user function.""" 160 161 # Loop over the data types. 162 for data in DATA_TYPES: 163 # Catch the str argument, and skip it. 164 if data[0] == 'str': 165 continue 166 167 # The argument test. 168 self.assertRaises(RelaxStrError, self.spectrum_fns.read_intensities, heteronuc=data[1])
169 170
172 """The proton arg test of the spectrum.read_intensities() user function.""" 173 174 # Loop over the data types. 175 for data in DATA_TYPES: 176 # Catch the str argument, and skip it. 177 if data[0] == 'str': 178 continue 179 180 # The argument test. 181 self.assertRaises(RelaxStrError, self.spectrum_fns.read_intensities, proton=data[1])
182 183
185 """The int_col arg test of the spectrum.read_intensities() user function.""" 186 187 # Loop over the data types. 188 for data in DATA_TYPES: 189 # Catch the None, int, bin, or integer list arguments, and skip them. 190 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin' or data[0] == 'int list': 191 continue 192 193 # The argument test. 194 self.assertRaises(RelaxNoneIntListIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_col=data[1])
195 196
198 """The int_method arg test of the spectrum.read_intensities() user function.""" 199 200 # Loop over the data types. 201 for data in DATA_TYPES: 202 # Catch the str argument, and skip it. 203 if data[0] == 'str': 204 continue 205 206 # The argument test. 207 self.assertRaises(RelaxStrError, self.spectrum_fns.read_intensities, int_method=data[1])
208 209
211 """The mol_name_col arg test of the spectrum.read_intensities() user function.""" 212 213 # Loop over the data types. 214 for data in DATA_TYPES: 215 # Catch the None, int, and bin arguments, and skip them. 216 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 217 continue 218 219 # The argument test. 220 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', mol_name_col=data[1])
221 222
224 """The res_num_col arg test of the spectrum.read_intensities() user function.""" 225 226 # Loop over the data types. 227 for data in DATA_TYPES: 228 # Catch the None, int, and bin arguments, and skip them. 229 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 230 continue 231 232 # The argument test. 233 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', res_num_col=data[1])
234 235
237 """The res_name_col arg test of the spectrum.read_intensities() user function.""" 238 239 # Loop over the data types. 240 for data in DATA_TYPES: 241 # Catch the None, int, and bin arguments, and skip them. 242 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 243 continue 244 245 # The argument test. 246 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', res_name_col=data[1])
247 248
250 """The spin_num_col arg test of the spectrum.read_intensities() user function.""" 251 252 # Loop over the data types. 253 for data in DATA_TYPES: 254 # Catch the None, int, and bin arguments, and skip them. 255 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 256 continue 257 258 # The argument test. 259 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', spin_num_col=data[1])
260 261
263 """The spin_name_col arg test of the spectrum.read_intensities() user function.""" 264 265 # Loop over the data types. 266 for data in DATA_TYPES: 267 # Catch the None, int, and bin arguments, and skip them. 268 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 269 continue 270 271 # The argument test. 272 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', spin_name_col=data[1])
273 274
276 """The sep arg test of the spectrum.read_intensities() user function.""" 277 278 # Loop over the data types. 279 for data in DATA_TYPES: 280 # Catch the None and str arguments, and skip them. 281 if data[0] == 'None' or data[0] == 'str': 282 continue 283 284 # The argument test. 285 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', sep=data[1])
286