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

Source Code for Module test_suite.unit_tests._prompt.test_residue

  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 RelaxIntError, RelaxNoneIntError, RelaxNoneStrError, RelaxStrError 
 28  from test_suite.unit_tests.residue_testing_base import Residue_base_class 
 29   
 30  # Unit test imports. 
 31  from test_suite.unit_tests._prompt.data_types import DATA_TYPES 
 32   
 33   
34 -class Test_residue(Residue_base_class, TestCase):
35 """Unit tests for the functions of the 'prompt.residue' 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_residue, 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.residue_fns = self.interpreter.residue
50 51
53 """Test the proper failure of the residue.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.residue_fns.copy, pipe_from=data[1], res_from='#Old mol:1', res_to='#Old mol:2')
63 64
66 """Test the proper failure of the residue.copy() user function for the res_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.residue_fns.copy, res_from=data[1], res_to='#Old mol:2')
76 77
79 """Test the proper failure of the residue.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.residue_fns.copy, pipe_to=data[1], res_from='#Old mol:1', res_to='#Old mol:2')
89 90
91 - def test_copy_argfail_res_to(self):
92 """Test the proper failure of the residue.copy() user function for the res_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.residue_fns.copy, res_from='#Old mol:1@111', res_to=data[1])
102 103
105 """Test the proper failure of the residue.create() user function for the res_num argument.""" 106 107 # Loop over the data types. 108 for data in DATA_TYPES: 109 # Catch the None, 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.residue_fns.create, res_num=data[1], res_name='NH')
115 116
118 """Test the proper failure of the residue.create() user function for the res_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.residue_fns.create, res_name=data[1], res_num=1)
128 129
131 """Test the proper failure of the residue.create() user function for the mol_name argument.""" 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.residue_fns.create, mol_name=data[1], res_num=1, res_name='NH')
141 142
144 """Test the proper failure of the residue.delete() user function for the res_id argument.""" 145 146 # Loop over the data types. 147 for data in DATA_TYPES: 148 # Catch the str arguments, and skip them. 149 if data[0] == 'str': 150 continue 151 152 # The argument test. 153 self.assertRaises(RelaxStrError, self.residue_fns.delete, res_id=data[1])
154 155
157 """Test the proper failure of the residue.display() user function for the res_id 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.residue_fns.display, res_id=data[1])
167 168
169 - def test_name_argfail_res_id(self):
170 """Test the proper failure of the residue.name() user function for the res_id argument.""" 171 172 # Loop over the data types. 173 for data in DATA_TYPES: 174 # Catch the str arguments, and skip them. 175 if data[0] == 'str': 176 continue 177 178 # The argument test. 179 self.assertRaises(RelaxStrError, self.residue_fns.name, res_id=data[1])
180 181
182 - def test_name_argfail_name(self):
183 """Test the proper failure of the residue.name() user function for the name argument.""" 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.residue_fns.name, name=data[1])
193 194
196 """Test the proper failure of the residue.number() user function for the res_id argument.""" 197 198 # Loop over the data types. 199 for data in DATA_TYPES: 200 # Catch the str arguments, and skip them. 201 if data[0] == 'str': 202 continue 203 204 # The argument test. 205 self.assertRaises(RelaxStrError, self.residue_fns.number, res_id=data[1])
206 207
209 """Test the proper failure of the residue.number() user function for the number argument.""" 210 211 # Loop over the data types. 212 for data in DATA_TYPES: 213 # Catch the int and bin arguments, and skip them. 214 if data[0] == 'int' or data[0] == 'bin': 215 continue 216 217 # The argument test. 218 self.assertRaises(RelaxIntError, self.residue_fns.number, res_id=':1', number=data[1])
219