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, 2010 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.molecule import Molecule 
 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 # Instantiate the user function class. 39 molecule_fns = Molecule() 40 41
43 """Test the proper failure of the molecule.copy() user function for the pipe_from argument.""" 44 45 # Loop over the data types. 46 for data in DATA_TYPES: 47 # Catch the None and str arguments, and skip them. 48 if data[0] == 'None' or data[0] == 'str': 49 continue 50 51 # The argument test. 52 self.assertRaises(RelaxNoneStrError, self.molecule_fns.copy, pipe_from=data[1], mol_from='#Old mol', mol_to='#Old mol')
53 54
56 """Test the proper failure of the molecule.copy() user function for the mol_from argument.""" 57 58 # Loop over the data types. 59 for data in DATA_TYPES: 60 # Catch the str argument, and skip it. 61 if data[0] == 'str': 62 continue 63 64 # The argument test. 65 self.assertRaises(RelaxStrError, self.molecule_fns.copy, mol_from=data[1], mol_to='#Old mol')
66 67
69 """Test the proper failure of the molecule.copy() user function for the pipe_to argument.""" 70 71 # Loop over the data types. 72 for data in DATA_TYPES: 73 # Catch the None and str arguments, and skip them. 74 if data[0] == 'None' or data[0] == 'str': 75 continue 76 77 # The argument test. 78 self.assertRaises(RelaxNoneStrError, self.molecule_fns.copy, pipe_to=data[1], mol_from='#Old mol', mol_to='#New mol2')
79 80
81 - def test_copy_argfail_mol_to(self):
82 """Test the proper failure of the molecule.copy() user function for the mol_to argument.""" 83 84 # Set up some data. 85 self.setup_data() 86 87 # Loop over the data types. 88 for data in DATA_TYPES: 89 # Catch the None and str arguments, and skip them. 90 if data[0] == 'None' or data[0] == 'str': 91 continue 92 93 # The argument test. 94 self.assertRaises(RelaxNoneStrError, self.molecule_fns.copy, mol_from='#Old mol', mol_to=data[1])
95 96
98 """Test the proper failure of the molecule.create() user function for the mol_name argument.""" 99 100 # Loop over the data types. 101 for data in DATA_TYPES: 102 # Catch the str arguments, and skip them. 103 if data[0] == 'str': 104 continue 105 106 # The argument test. 107 self.assertRaises(RelaxStrError, self.molecule_fns.create, mol_name=data[1])
108 109
111 """Test the proper failure of the molecule.delete() user function for the mol_id argument.""" 112 113 # Loop over the data types. 114 for data in DATA_TYPES: 115 # Catch the str arguments, and skip them. 116 if data[0] == 'str': 117 continue 118 119 # The argument test. 120 self.assertRaises(RelaxStrError, self.molecule_fns.delete, mol_id=data[1])
121 122
124 """Test the proper failure of the molecule.display() user function for the mol_id argument.""" 125 126 # Loop over the data types. 127 for data in DATA_TYPES: 128 # Catch the None and str arguments, and skip them. 129 if data[0] == 'None' or data[0] == 'str': 130 continue 131 132 # The argument test. 133 self.assertRaises(RelaxNoneStrError, self.molecule_fns.display, mol_id=data[1])
134 135
136 - def test_name_argfail_mol_id(self):
137 """Test the proper failure of the molecule.name() user function for the mol_id argument.""" 138 139 # Loop over the data types. 140 for data in DATA_TYPES: 141 # Catch the None and str arguments, and skip them. 142 if data[0] == 'None' or data[0] == 'str': 143 continue 144 145 # The argument test. 146 self.assertRaises(RelaxNoneStrError, self.molecule_fns.name, mol_id=data[1])
147 148
149 - def test_name_argfail_name(self):
150 """Test the proper failure of the molecule.name() user function for the name argument.""" 151 152 # Loop over the data types. 153 for data in DATA_TYPES: 154 # Catch the str arguments, and skip them. 155 if data[0] == 'str': 156 continue 157 158 # The argument test. 159 self.assertRaises(RelaxStrError, self.molecule_fns.name, name=data[1])
160