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-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 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 - def __init__(self, methodName=None):
38 """Set up the test case class for the system tests.""" 39 40 # Execute the base __init__ methods. 41 super(Test_spectrum, self).__init__(methodName) 42 43 # Load the interpreter. 44 self.interpreter = Interpreter(show_script=False, quit=False, raise_relax_error=True) 45 self.interpreter.populate_self() 46 self.interpreter.on(verbose=False) 47 48 # Alias the user function class. 49 self.spectrum_fns = self.interpreter.spectrum
50 51
53 """The error arg test of the spectrum.baseplane_rmsd() user function.""" 54 55 # Loop over the data types. 56 for data in DATA_TYPES: 57 # Catch the float, bin, and int arguments, and skip them. 58 if data[0] == 'float' or data[0] == 'bin' or data[0] == 'int': 59 continue 60 61 # The argument test. 62 self.assertRaises(RelaxNumError, self.spectrum_fns.baseplane_rmsd, error=data[1])
63 64
66 """The spectrum_id arg test of the spectrum.baseplane_rmsd() user function.""" 67 68 # Loop over the data types. 69 for data in DATA_TYPES: 70 # Catch the str arguments, and skip them. 71 if data[0] == 'str': 72 continue 73 74 # The argument test. 75 self.assertRaises(RelaxStrError, self.spectrum_fns.baseplane_rmsd, spectrum_id=data[1])
76 77
79 """The spin_id arg test of the spectrum.baseplane_rmsd() user function.""" 80 81 # Loop over the data types. 82 for data in DATA_TYPES: 83 # Catch the None and str arguments, and skip them. 84 if data[0] == 'None' or data[0] == 'str': 85 continue 86 87 # The argument test. 88 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.baseplane_rmsd, spectrum_id='x', spin_id=data[1])
89 90
92 """The N arg test of the spectrum.integration_points() user function.""" 93 94 # Loop over the data types. 95 for data in DATA_TYPES: 96 # Catch the bin and int arguments, and skip them. 97 if data[0] == 'bin' or data[0] == 'int': 98 continue 99 100 # The argument test. 101 self.assertRaises(RelaxIntError, self.spectrum_fns.integration_points, N=data[1])
102 103
105 """The spectrum_id arg test of the spectrum.integration_points() user function.""" 106 107 # Loop over the data types. 108 for data in DATA_TYPES: 109 # Catch the str arguments, and skip them. 110 if data[0] == 'str': 111 continue 112 113 # The argument test. 114 self.assertRaises(RelaxStrError, self.spectrum_fns.integration_points, N=0, spectrum_id=data[1])
115 116
118 """The spin_id arg test of the spectrum.integration_points() user function.""" 119 120 # Loop over the data types. 121 for data in DATA_TYPES: 122 # Catch the None and str arguments, and skip them. 123 if data[0] == 'None' or data[0] == 'str': 124 continue 125 126 # The argument test. 127 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.integration_points, N=0, spectrum_id='x', spin_id=data[1])
128 129
131 """The file arg test of the spectrum.read_intensities() user function.""" 132 133 # Loop over the data types. 134 for data in DATA_TYPES: 135 # Catch the str argument, and skip it. 136 if data[0] == 'str': 137 continue 138 139 # The argument test. 140 self.assertRaises(RelaxStrError, self.spectrum_fns.read_intensities, file=data[1])
141 142
144 """The dir arg test of the spectrum.read_intensities() user function.""" 145 146 # Loop over the data types. 147 for data in DATA_TYPES: 148 # Catch the None and str arguments, and skip them. 149 if data[0] == 'None' or data[0] == 'str': 150 continue 151 152 # The argument test. 153 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.read_intensities, file='a', dir=data[1])
154 155
157 """The spectrum_id arg test of the spectrum.read_intensities() user function.""" 158 159 # Loop over the data types. 160 for data in DATA_TYPES: 161 # Catch the str arguments, and skip them. 162 if data[0] == 'str': 163 continue 164 165 # The argument test. 166 self.assertRaises(RelaxStrError, self.spectrum_fns.read_intensities, spectrum_id=data[1])
167 168
170 """The heteronuc arg test of the spectrum.read_intensities() user function.""" 171 172 # Loop over the data types. 173 for data in DATA_TYPES: 174 # Catch the str argument, and skip it. 175 if data[0] == 'str': 176 continue 177 178 # The argument test. 179 self.assertRaises(RelaxStrError, self.spectrum_fns.read_intensities, heteronuc=data[1])
180 181
183 """The proton arg test of the spectrum.read_intensities() user function.""" 184 185 # Loop over the data types. 186 for data in DATA_TYPES: 187 # Catch the str argument, and skip it. 188 if data[0] == 'str': 189 continue 190 191 # The argument test. 192 self.assertRaises(RelaxStrError, self.spectrum_fns.read_intensities, proton=data[1])
193 194
196 """The int_col arg test of the spectrum.read_intensities() user function.""" 197 198 # Loop over the data types. 199 for data in DATA_TYPES: 200 # Catch the None, int, bin, or integer list arguments, and skip them. 201 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin' or data[0] == 'int list': 202 continue 203 204 # The argument test. 205 self.assertRaises(RelaxNoneIntListIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_col=data[1])
206 207
209 """The int_method arg test of the spectrum.read_intensities() user function.""" 210 211 # Loop over the data types. 212 for data in DATA_TYPES: 213 # Catch the str argument, and skip it. 214 if data[0] == 'str': 215 continue 216 217 # The argument test. 218 self.assertRaises(RelaxStrError, self.spectrum_fns.read_intensities, int_method=data[1])
219 220
222 """The mol_name_col arg test of the spectrum.read_intensities() user function.""" 223 224 # Loop over the data types. 225 for data in DATA_TYPES: 226 # Catch the None, int, and bin arguments, and skip them. 227 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 228 continue 229 230 # The argument test. 231 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', mol_name_col=data[1])
232 233
235 """The res_num_col arg test of the spectrum.read_intensities() user function.""" 236 237 # Loop over the data types. 238 for data in DATA_TYPES: 239 # Catch the None, int, and bin arguments, and skip them. 240 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 241 continue 242 243 # The argument test. 244 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', res_num_col=data[1])
245 246
248 """The res_name_col arg test of the spectrum.read_intensities() user function.""" 249 250 # Loop over the data types. 251 for data in DATA_TYPES: 252 # Catch the None, int, and bin arguments, and skip them. 253 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 254 continue 255 256 # The argument test. 257 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', res_name_col=data[1])
258 259
261 """The spin_num_col arg test of the spectrum.read_intensities() user function.""" 262 263 # Loop over the data types. 264 for data in DATA_TYPES: 265 # Catch the None, int, and bin arguments, and skip them. 266 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 267 continue 268 269 # The argument test. 270 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', spin_num_col=data[1])
271 272
274 """The spin_name_col arg test of the spectrum.read_intensities() user function.""" 275 276 # Loop over the data types. 277 for data in DATA_TYPES: 278 # Catch the None, int, and bin arguments, and skip them. 279 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 280 continue 281 282 # The argument test. 283 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', spin_name_col=data[1])
284 285
287 """The sep arg test of the spectrum.read_intensities() user function.""" 288 289 # Loop over the data types. 290 for data in DATA_TYPES: 291 # Catch the None and str arguments, and skip them. 292 if data[0] == 'None' or data[0] == 'str': 293 continue 294 295 # The argument test. 296 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', sep=data[1])
297