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

Source Code for Module test_suite.unit_tests._prompt.test_molecule

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-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 RelaxNoneStrError, RelaxStrError 
 29  from test_suite.unit_tests.molecule_testing_base import Molecule_base_class 
 30   
 31  # Unit test imports. 
 32  from data_types import DATA_TYPES 
 33   
 34   
35 -class Test_molecule(Molecule_base_class, TestCase):
36 """Unit tests for the functions of the 'prompt.molecule' module.""" 37
38 - def __init__(self, methodName=None):
39 """Set up the test case class for the system tests.""" 40 41 # Execute the base __init__ methods. 42 super(Test_molecule, self).__init__(methodName) 43 44 # Load the interpreter. 45 self.interpreter = Interpreter(show_script=False, quit=False, raise_relax_error=True) 46 self.interpreter.populate_self() 47 self.interpreter.on(verbose=False) 48 49 # Alias the user function class. 50 self.molecule_fns = self.interpreter.molecule
51 52
54 """Test the proper failure of the molecule.copy() user function for the pipe_from argument.""" 55 56 # Loop over the data types. 57 for data in DATA_TYPES: 58 # Catch the None and str arguments, and skip them. 59 if data[0] == 'None' or data[0] == 'str': 60 continue 61 62 # The argument test. 63 self.assertRaises(RelaxNoneStrError, self.molecule_fns.copy, pipe_from=data[1], mol_from='#Old mol', mol_to='#Old mol')
64 65
67 """Test the proper failure of the molecule.copy() user function for the mol_from argument.""" 68 69 # Loop over the data types. 70 for data in DATA_TYPES: 71 # Catch the str argument, and skip it. 72 if data[0] == 'str': 73 continue 74 75 # The argument test. 76 self.assertRaises(RelaxStrError, self.molecule_fns.copy, mol_from=data[1], mol_to='#Old mol')
77 78
80 """Test the proper failure of the molecule.copy() user function for the pipe_to argument.""" 81 82 # Loop over the data types. 83 for data in DATA_TYPES: 84 # Catch the None and str arguments, and skip them. 85 if data[0] == 'None' or data[0] == 'str': 86 continue 87 88 # The argument test. 89 self.assertRaises(RelaxNoneStrError, self.molecule_fns.copy, pipe_to=data[1], mol_from='#Old mol', mol_to='#New mol2')
90 91
92 - def test_copy_argfail_mol_to(self):
93 """Test the proper failure of the molecule.copy() user function for the mol_to argument.""" 94 95 # Set up some data. 96 self.setup_data() 97 98 # Loop over the data types. 99 for data in DATA_TYPES: 100 # Catch the None and str arguments, and skip them. 101 if data[0] == 'None' or data[0] == 'str': 102 continue 103 104 # The argument test. 105 self.assertRaises(RelaxNoneStrError, self.molecule_fns.copy, mol_from='#Old mol', mol_to=data[1])
106 107
109 """Test the proper failure of the molecule.create() user function for the mol_name argument.""" 110 111 # Loop over the data types. 112 for data in DATA_TYPES: 113 # Catch the str arguments, and skip them. 114 if data[0] == 'str': 115 continue 116 117 # The argument test. 118 self.assertRaises(RelaxStrError, self.molecule_fns.create, mol_name=data[1])
119 120
122 """Test the proper failure of the molecule.delete() user function for the mol_id argument.""" 123 124 # Loop over the data types. 125 for data in DATA_TYPES: 126 # Catch the str arguments, and skip them. 127 if data[0] == 'str': 128 continue 129 130 # The argument test. 131 self.assertRaises(RelaxStrError, self.molecule_fns.delete, mol_id=data[1])
132 133
135 """Test the proper failure of the molecule.display() user function for the mol_id argument.""" 136 137 # Loop over the data types. 138 for data in DATA_TYPES: 139 # Catch the None and str arguments, and skip them. 140 if data[0] == 'None' or data[0] == 'str': 141 continue 142 143 # The argument test. 144 self.assertRaises(RelaxNoneStrError, self.molecule_fns.display, mol_id=data[1])
145 146
147 - def test_name_argfail_mol_id(self):
148 """Test the proper failure of the molecule.name() user function for the mol_id argument.""" 149 150 # Loop over the data types. 151 for data in DATA_TYPES: 152 # Catch the None and str arguments, and skip them. 153 if data[0] == 'None' or data[0] == 'str': 154 continue 155 156 # The argument test. 157 self.assertRaises(RelaxNoneStrError, self.molecule_fns.name, mol_id=data[1])
158 159
160 - def test_name_argfail_name(self):
161 """Test the proper failure of the molecule.name() user function for the name argument.""" 162 163 # Loop over the data types. 164 for data in DATA_TYPES: 165 # Catch the str arguments, and skip them. 166 if data[0] == 'str': 167 continue 168 169 # The argument test. 170 self.assertRaises(RelaxStrError, self.molecule_fns.name, name=data[1])
171