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

Source Code for Module test_suite.unit_tests._prompt.test_structure

  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 RelaxBoolError, RelaxNoneIntListIntError, RelaxNoneStrError, RelaxNoneStrListStrError, RelaxNumError, RelaxStrError 
 28  from test_suite.unit_tests.structure_testing_base import Structure_base_class 
 29   
 30  # Unit test imports. 
 31  from test_suite.unit_tests._prompt.data_types import DATA_TYPES 
 32   
 33   
34 -class Test_structure(Structure_base_class, TestCase):
35 """Unit tests for the functions of the 'prompt.structure' 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_structure, 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.structure_fns = self.interpreter.structure
50 51
53 """The scale arg test of the structure.create_diff_tensor_pdb() 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.structure_fns.create_diff_tensor_pdb, scale=data[1])
63 64
66 """The file arg test of the structure.create_diff_tensor_pdb() 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.structure_fns.create_diff_tensor_pdb, file=data[1])
76 77
79 """The dir arg test of the structure.create_diff_tensor_pdb() 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.structure_fns.create_diff_tensor_pdb, dir=data[1])
89 90
92 """The force arg test of the structure.create_diff_tensor_pdb() user function.""" 93 94 # Loop over the data types. 95 for data in DATA_TYPES: 96 # Catch the bool arguments, and skip them. 97 if data[0] == 'bool': 98 continue 99 100 # The argument test. 101 self.assertRaises(RelaxBoolError, self.structure_fns.create_diff_tensor_pdb, force=data[1])
102 103
105 """The length arg test of the structure.create_vector_dist() user function.""" 106 107 # Loop over the data types. 108 for data in DATA_TYPES: 109 # Catch the number arguments, and skip them. 110 if data[0] == 'bin' or data[0] == 'int' or data[0] == 'float': 111 continue 112 113 # The argument test. 114 self.assertRaises(RelaxNumError, self.structure_fns.create_vector_dist, length=data[1])
115 116
118 """The file arg test of the structure.create_vector_dist() user function.""" 119 120 # Loop over the data types. 121 for data in DATA_TYPES: 122 # Catch the str arguments, and skip them. 123 if data[0] == 'str': 124 continue 125 126 # The argument test. 127 self.assertRaises(RelaxStrError, self.structure_fns.create_vector_dist, file=data[1])
128 129
131 """The dir arg test of the structure.create_vector_dist() user function.""" 132 133 # Loop over the data types. 134 for data in DATA_TYPES: 135 # Catch the None and str arguments, and skip them. 136 if data[0] == 'None' or data[0] == 'str': 137 continue 138 139 # The argument test. 140 self.assertRaises(RelaxNoneStrError, self.structure_fns.create_vector_dist, dir=data[1])
141 142
144 """The symmetry arg test of the structure.create_vector_dist() user function.""" 145 146 # Loop over the data types. 147 for data in DATA_TYPES: 148 # Catch the bool arguments, and skip them. 149 if data[0] == 'bool': 150 continue 151 152 # The argument test. 153 self.assertRaises(RelaxBoolError, self.structure_fns.create_vector_dist, symmetry=data[1])
154 155
157 """The force arg test of the structure.create_vector_dist() user function.""" 158 159 # Loop over the data types. 160 for data in DATA_TYPES: 161 # Catch the bool arguments, and skip them. 162 if data[0] == 'bool': 163 continue 164 165 # The argument test. 166 self.assertRaises(RelaxBoolError, self.structure_fns.create_vector_dist, force=data[1])
167 168
170 """The spin_id arg test of the structure.load_spins() 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] == 'None' or data[0] == 'str': 176 continue 177 178 # The argument test. 179 self.assertRaises(RelaxNoneStrError, self.structure_fns.load_spins, spin_id=data[1])
180 181
183 """The file arg test of the structure.read_pdb() user function.""" 184 185 # Loop over the data types. 186 for data in DATA_TYPES: 187 # Catch the str arguments, and skip them. 188 if data[0] == 'str': 189 continue 190 191 # The argument test. 192 self.assertRaises(RelaxStrError, self.structure_fns.read_pdb, file=data[1])
193 194
196 """The dir arg test of the structure.read_pdb() 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.structure_fns.read_pdb, file='test.pdb', dir=data[1])
206 207
209 """The read_mol arg test of the structure.read_pdb() user function.""" 210 211 # Loop over the data types. 212 for data in DATA_TYPES: 213 # Catch the None, bin, int, and int list arguments, and skip them. 214 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'int list': 215 continue 216 217 # The argument test. 218 self.assertRaises(RelaxNoneIntListIntError, self.structure_fns.read_pdb, file='test.pdb', read_mol=data[1])
219 220
222 """The set_mol_name arg test of the structure.read_pdb() user function.""" 223 224 # Loop over the data types. 225 for data in DATA_TYPES: 226 # Catch the None, str, and str list arguments, and skip them. 227 if data[0] == 'None' or data[0] == 'str' or data[0] == 'str list': 228 continue 229 230 # The argument test. 231 self.assertRaises(RelaxNoneStrListStrError, self.structure_fns.read_pdb, file='test.pdb', set_mol_name=data[1])
232 233
235 """The read_model arg test of the structure.read_pdb() user function.""" 236 237 # Loop over the data types. 238 for data in DATA_TYPES: 239 # Catch the None, bin, int, and int list arguments, and skip them. 240 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'int list': 241 continue 242 243 # The argument test. 244 self.assertRaises(RelaxNoneIntListIntError, self.structure_fns.read_pdb, file='test.pdb', read_model=data[1])
245 246
248 """The set_model_num arg test of the structure.read_pdb() user function.""" 249 250 # Loop over the data types. 251 for data in DATA_TYPES: 252 # Catch the None, bin, int, and int list arguments, and skip them. 253 if data[0] == 'None' or data[0] == 'bin' or data[0] == 'int' or data[0] == 'int list': 254 continue 255 256 # The argument test. 257 self.assertRaises(RelaxNoneIntListIntError, self.structure_fns.read_pdb, file='test.pdb', set_model_num=data[1])
258