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

Source Code for Module test_suite.unit_tests._prompt.test_spin

  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  # Python module imports. 
 23  from unittest import TestCase 
 24   
 25  # relax module imports. 
 26  from prompt.interpreter import Interpreter 
 27  from lib.errors import RelaxListStrError, RelaxNoneIntError, RelaxNoneStrError, RelaxStrError 
 28  from test_suite.unit_tests.spin_testing_base import Spin_base_class 
 29   
 30  # Unit test imports. 
 31  from test_suite.unit_tests._prompt.data_types import DATA_TYPES 
 32   
 33   
34 -class Test_spin(Spin_base_class, TestCase):
35 """Unit tests for the functions of the 'prompt.spin' 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_spin, self).__init__(methodName) 42 43 # Load the interpreter. 44 self.interpreter = Interpreter(show_script=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.spin_fns = self.interpreter.spin
50 51
53 """Test the proper failure of the spin.copy() user function for the pipe_from argument.""" 54 55 # Loop over the data types. 56 for data in DATA_TYPES: 57 # Catch the None and str arguments, and skip them. 58 if data[0] == 'None' or data[0] == 'str': 59 continue 60 61 # The argument test. 62 self.assertRaises(RelaxNoneStrError, self.spin_fns.copy, pipe_from=data[1], spin_from='#Old mol:1@111', spin_to='#Old mol:2')
63 64
66 """Test the proper failure of the spin.copy() user function for the spin_from argument.""" 67 68 # Loop over the data types. 69 for data in DATA_TYPES: 70 # Catch the str argument, and skip it. 71 if data[0] == 'str': 72 continue 73 74 # The argument test. 75 self.assertRaises(RelaxStrError, self.spin_fns.copy, spin_from=data[1], spin_to='#Old mol:2')
76 77
79 """Test the proper failure of the spin.copy() user function for the pipe_to argument.""" 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.spin_fns.copy, pipe_to=data[1], spin_from='#Old mol:1@111', spin_to='#Old mol:2')
89 90
92 """Test the proper failure of the spin.copy() user function for the spin_to argument.""" 93 94 # Loop over the data types. 95 for data in DATA_TYPES: 96 # Catch the None and str arguments, and skip them. 97 if data[0] == 'None' or data[0] == 'str': 98 continue 99 100 # The argument test. 101 self.assertRaises(RelaxNoneStrError, self.spin_fns.copy, spin_from='#Old mol:1@111', spin_to=data[1])
102 103
105 """Test the proper failure of the spin.create() user function for the spin_num argument.""" 106 107 # Loop over the data types. 108 for data in DATA_TYPES: 109 # Catch the int and bin arguments, and skip them. 110 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 111 continue 112 113 # The argument test. 114 self.assertRaises(RelaxNoneIntError, self.spin_fns.create, spin_num=data[1], spin_name='NH')
115 116
118 """Test the proper failure of the spin.create() user function for the spin_name argument.""" 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.spin_fns.create, spin_name=data[1], spin_num=1)
128 129
131 """Test the proper failure of the spin.create() user function for the res_num argument.""" 132 133 # Loop over the data types. 134 for data in DATA_TYPES: 135 # Catch the int and bin arguments, and skip them. 136 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 137 continue 138 139 # The argument test. 140 self.assertRaises(RelaxNoneIntError, self.spin_fns.create, res_num=data[1], spin_name='NH')
141 142
144 """Test the proper failure of the spin.create() user function for the res_name argument.""" 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.spin_fns.create, res_name=data[1], spin_num=1, spin_name='NH')
154 155
157 """Test the proper failure of the spin.create() user function for the mol_name argument.""" 158 159 # Loop over the data types. 160 for data in DATA_TYPES: 161 # Catch the None and str arguments, and skip them. 162 if data[0] == 'None' or data[0] == 'str': 163 continue 164 165 # The argument test. 166 self.assertRaises(RelaxNoneStrError, self.spin_fns.create, mol_name=data[1], spin_num=1, spin_name='NH')
167 168
170 """The spin_name arg test of the spin.create_pseudo() user function.""" 171 172 # Loop over the data types. 173 for data in DATA_TYPES: 174 # Catch the None and str arguments, and skip them. 175 if data[0] == 'str': 176 continue 177 178 # The argument test. 179 self.assertRaises(RelaxStrError, self.spin_fns.create_pseudo, spin_name=data[1])
180 181
183 """The spin_num arg test of the spin.create_pseudo() user function.""" 184 185 # Loop over the data types. 186 for data in DATA_TYPES: 187 # Catch the int and bin arguments, and skip them. 188 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 189 continue 190 191 # The argument test. 192 self.assertRaises(RelaxNoneIntError, self.spin_fns.create_pseudo, spin_num=data[1], spin_name='Q')
193 194
196 """The res_id arg test of the spin.create_pseudo() user function.""" 197 198 # Loop over the data types. 199 for data in DATA_TYPES: 200 # Catch the None and str arguments, and skip them. 201 if data[0] == 'None' or data[0] == 'str': 202 continue 203 204 # The argument test. 205 self.assertRaises(RelaxNoneStrError, self.spin_fns.create_pseudo, res_id=data[1], spin_name='Q')
206 207
209 """The members arg test of the spin.create_pseudo() user function.""" 210 211 # Loop over the data types. 212 for data in DATA_TYPES: 213 # Catch the str list argument, and skip it. 214 if data[0] == 'str list': 215 continue 216 217 # The argument test. 218 self.assertRaises(RelaxListStrError, self.spin_fns.create_pseudo, members=data[1], spin_name='Q')
219 220
222 """The averaging arg test of the spin.create_pseudo() user function.""" 223 224 # Loop over the data types. 225 for data in DATA_TYPES: 226 # Catch the str arguments, and skip them. 227 if data[0] == 'str': 228 continue 229 230 # The argument test. 231 self.assertRaises(RelaxStrError, self.spin_fns.create_pseudo, averaging=data[1], spin_name='Q', members=['x'])
232 233
235 """Test the proper failure of the spin.delete() user function for the spin_id argument.""" 236 237 # Loop over the data types. 238 for data in DATA_TYPES: 239 # Catch the str arguments, and skip them. 240 if data[0] == 'str': 241 continue 242 243 # The argument test. 244 self.assertRaises(RelaxStrError, self.spin_fns.delete, spin_id=data[1])
245 246
248 """Test the proper failure of the spin.display() user function for the spin_id argument.""" 249 250 # Loop over the data types. 251 for data in DATA_TYPES: 252 # Catch the None and str arguments, and skip them. 253 if data[0] == 'None' or data[0] == 'str': 254 continue 255 256 # The argument test. 257 self.assertRaises(RelaxNoneStrError, self.spin_fns.display, spin_id=data[1])
258 259
261 """Test the proper failure of the spin.name() user function for the spin_id argument.""" 262 263 # Loop over the data types. 264 for data in DATA_TYPES: 265 # Catch the None and str arguments, and skip them. 266 if data[0] == 'None' or data[0] == 'str': 267 continue 268 269 # The argument test. 270 self.assertRaises(RelaxNoneStrError, self.spin_fns.name, name='N', spin_id=data[1])
271 272
273 - def test_name_argfail_name(self):
274 """Test the proper failure of the spin.name() user function for the name argument.""" 275 276 # Loop over the data types. 277 for data in DATA_TYPES: 278 # Catch the str arguments, and skip them. 279 if data[0] == 'str': 280 continue 281 282 # The argument test. 283 self.assertRaises(RelaxStrError, self.spin_fns.name, name=data[1])
284 285
287 """Test the proper failure of the spin.number() user function for the spin_id argument.""" 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.spin_fns.number, spin_id=data[1])
297 298
300 """Test the proper failure of the spin.number() user function for the number argument.""" 301 302 # Loop over the data types. 303 for data in DATA_TYPES: 304 # Catch the None, int and bin arguments, and skip them. 305 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': 306 continue 307 308 # The argument test. 309 self.assertRaises(RelaxNoneIntError, self.spin_fns.number, spin_id='@111', number=data[1])
310