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-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  # Python module imports. 
 23  from unittest import TestCase 
 24   
 25  # relax module imports. 
 26  from prompt.interpreter import Interpreter 
 27  from lib.errors import RelaxIntError, RelaxNoneIntError, RelaxNoneIntListIntError, RelaxNoneStrError, RelaxNumError, RelaxStrError, RelaxStrListStrError 
 28   
 29  # Unit test imports. 
 30  from test_suite.unit_tests._prompt.data_types import DATA_TYPES 
 31   
 32   
33 -class Test_spectrum(TestCase):
34 """Unit tests for the functions of the 'prompt.spectrum' 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_spectrum, self).__init__(methodName) 41 42 # Load the interpreter. 43 self.interpreter = Interpreter(show_script=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.spectrum_fns = self.interpreter.spectrum
49 50
52 """The error arg test of the spectrum.baseplane_rmsd() user function.""" 53 54 # Loop over the data types. 55 for data in DATA_TYPES: 56 # Catch the float, bin, and int arguments, and skip them. 57 if data[0] == 'float' or data[0] == 'bin' or data[0] == 'int': 58 continue 59 60 # The argument test. 61 self.assertRaises(RelaxNumError, self.spectrum_fns.baseplane_rmsd, error=data[1])
62 63
65 """The spectrum_id arg test of the spectrum.baseplane_rmsd() user function.""" 66 67 # Loop over the data types. 68 for data in DATA_TYPES: 69 # Catch the str arguments, and skip them. 70 if data[0] == 'str': 71 continue 72 73 # The argument test. 74 self.assertRaises(RelaxStrError, self.spectrum_fns.baseplane_rmsd, spectrum_id=data[1])
75 76
78 """The spin_id arg test of the spectrum.baseplane_rmsd() user function.""" 79 80 # Loop over the data types. 81 for data in DATA_TYPES: 82 # Catch the None and str arguments, and skip them. 83 if data[0] == 'None' or data[0] == 'str': 84 continue 85 86 # The argument test. 87 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.baseplane_rmsd, spectrum_id='x', spin_id=data[1])
88 89
91 """The N arg test of the spectrum.integration_points() user function.""" 92 93 # Loop over the data types. 94 for data in DATA_TYPES: 95 # Catch the bin and int arguments, and skip them. 96 if data[0] == 'bin' or data[0] == 'int': 97 continue 98 99 # The argument test. 100 self.assertRaises(RelaxIntError, self.spectrum_fns.integration_points, N=data[1])
101 102
104 """The spectrum_id arg test of the spectrum.integration_points() user function.""" 105 106 # Loop over the data types. 107 for data in DATA_TYPES: 108 # Catch the str arguments, and skip them. 109 if data[0] == 'str': 110 continue 111 112 # The argument test. 113 self.assertRaises(RelaxStrError, self.spectrum_fns.integration_points, N=0, spectrum_id=data[1])
114 115
117 """The spin_id arg test of the spectrum.integration_points() user function.""" 118 119 # Loop over the data types. 120 for data in DATA_TYPES: 121 # Catch the None and str arguments, and skip them. 122 if data[0] == 'None' or data[0] == 'str': 123 continue 124 125 # The argument test. 126 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.integration_points, N=0, spectrum_id='x', spin_id=data[1])
127 128
130 """The file arg test of the spectrum.read_intensities() user function.""" 131 132 # Loop over the data types. 133 for data in DATA_TYPES: 134 # Catch the str argument, and skip it. 135 if data[0] == 'str': 136 continue 137 138 # The argument test. 139 self.assertRaises(RelaxStrListStrError, self.spectrum_fns.read_intensities, file=data[1])
140 141
143 """The dir arg test of the spectrum.read_intensities() user function.""" 144 145 # Loop over the data types. 146 for data in DATA_TYPES: 147 # Catch the None and str arguments, and skip them. 148 if data[0] == 'None' or data[0] == 'str': 149 continue 150 151 # The argument test. 152 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.read_intensities, file='a', dir=data[1])
153 154
156 """The spectrum_id arg test of the spectrum.read_intensities() user function.""" 157 158 # Loop over the data types. 159 for data in DATA_TYPES: 160 # Catch the str arguments, and skip them. 161 if data[0] == 'str': 162 continue 163 164 # The argument test. 165 self.assertRaises(RelaxStrListStrError, self.spectrum_fns.read_intensities, spectrum_id=data[1])
166 167
169 """The dim arg test of the spectrum.read_intensities() user function.""" 170 171 # Loop over the data types. 172 for data in DATA_TYPES: 173 # Catch the int argument, and skip it. 174 if data[0] == 'int' or data[0] == 'bin': 175 continue 176 177 # The argument test. 178 self.assertRaises(RelaxIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', dim=data[1])
179 180
182 """The int_col arg test of the spectrum.read_intensities() user function.""" 183 184 # Loop over the data types. 185 for data in DATA_TYPES: 186 # Catch the None, int, bin, or integer list arguments, and skip them. 187 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin' or data[0] == 'int list': 188 continue 189 190 # The argument test. 191 self.assertRaises(RelaxNoneIntListIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_col=data[1])
192 193
195 """The int_method arg test of the spectrum.read_intensities() user function.""" 196 197 # Loop over the data types. 198 for data in DATA_TYPES: 199 # Catch the str argument, and skip it. 200 if data[0] == 'str': 201 continue 202 203 # The argument test. 204 self.assertRaises(RelaxStrError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method=data[1])
205 206
208 """The mol_name_col arg test of the spectrum.read_intensities() user function.""" 209 210 # Loop over the data types. 211 for data in DATA_TYPES: 212 # Catch the None, int, and bin arguments, and skip them. 213 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 214 continue 215 216 # The argument test. 217 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', mol_name_col=data[1])
218 219
221 """The res_num_col arg test of the spectrum.read_intensities() user function.""" 222 223 # Loop over the data types. 224 for data in DATA_TYPES: 225 # Catch the None, int, and bin arguments, and skip them. 226 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 227 continue 228 229 # The argument test. 230 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', res_num_col=data[1])
231 232
234 """The res_name_col arg test of the spectrum.read_intensities() user function.""" 235 236 # Loop over the data types. 237 for data in DATA_TYPES: 238 # Catch the None, int, and bin arguments, and skip them. 239 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 240 continue 241 242 # The argument test. 243 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', res_name_col=data[1])
244 245
247 """The spin_num_col arg test of the spectrum.read_intensities() user function.""" 248 249 # Loop over the data types. 250 for data in DATA_TYPES: 251 # Catch the None, int, and bin arguments, and skip them. 252 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 253 continue 254 255 # The argument test. 256 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', spin_num_col=data[1])
257 258
260 """The spin_name_col arg test of the spectrum.read_intensities() user function.""" 261 262 # Loop over the data types. 263 for data in DATA_TYPES: 264 # Catch the None, int, and bin arguments, and skip them. 265 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 266 continue 267 268 # The argument test. 269 self.assertRaises(RelaxNoneIntError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', spin_name_col=data[1])
270 271
273 """The sep arg test of the spectrum.read_intensities() user function.""" 274 275 # Loop over the data types. 276 for data in DATA_TYPES: 277 # Catch the None and str arguments, and skip them. 278 if data[0] == 'None' or data[0] == 'str': 279 continue 280 281 # The argument test. 282 self.assertRaises(RelaxNoneStrError, self.spectrum_fns.read_intensities, file='a', spectrum_id='x', int_method='y', sep=data[1])
283