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-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 RelaxNoneStrError, RelaxStrError 
 28  from test_suite.unit_tests.molecule_testing_base import Molecule_base_class 
 29   
 30  # Unit test imports. 
 31  from test_suite.unit_tests._prompt.data_types import DATA_TYPES 
 32   
 33   
34 -class Test_molecule(Molecule_base_class, TestCase):
35 """Unit tests for the functions of the 'prompt.molecule' 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_molecule, 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.molecule_fns = self.interpreter.molecule
50 51
53 """Test the proper failure of the molecule.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.molecule_fns.copy, pipe_from=data[1], mol_from='#Old mol', mol_to='#Old mol')
63 64
66 """Test the proper failure of the molecule.copy() user function for the mol_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.molecule_fns.copy, mol_from=data[1], mol_to='#Old mol')
76 77
79 """Test the proper failure of the molecule.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.molecule_fns.copy, pipe_to=data[1], mol_from='#Old mol', mol_to='#New mol2')
89 90
91 - def test_copy_argfail_mol_to(self):
92 """Test the proper failure of the molecule.copy() user function for the mol_to argument.""" 93 94 # Set up some data. 95 self.setup_data() 96 97 # Loop over the data types. 98 for data in DATA_TYPES: 99 # Catch the None and str arguments, and skip them. 100 if data[0] == 'None' or data[0] == 'str': 101 continue 102 103 # The argument test. 104 self.assertRaises(RelaxNoneStrError, self.molecule_fns.copy, mol_from='#Old mol', mol_to=data[1])
105 106
108 """Test the proper failure of the molecule.create() user function for the mol_name argument.""" 109 110 # Loop over the data types. 111 for data in DATA_TYPES: 112 # Catch the str arguments, and skip them. 113 if data[0] == 'str': 114 continue 115 116 # The argument test. 117 self.assertRaises(RelaxStrError, self.molecule_fns.create, mol_name=data[1])
118 119
121 """Test the proper failure of the molecule.delete() user function for the mol_id argument.""" 122 123 # Loop over the data types. 124 for data in DATA_TYPES: 125 # Catch the str arguments, and skip them. 126 if data[0] == 'str': 127 continue 128 129 # The argument test. 130 self.assertRaises(RelaxStrError, self.molecule_fns.delete, mol_id=data[1])
131 132
134 """Test the proper failure of the molecule.display() user function for the mol_id argument.""" 135 136 # Loop over the data types. 137 for data in DATA_TYPES: 138 # Catch the None and str arguments, and skip them. 139 if data[0] == 'None' or data[0] == 'str': 140 continue 141 142 # The argument test. 143 self.assertRaises(RelaxNoneStrError, self.molecule_fns.display, mol_id=data[1])
144 145
146 - def test_name_argfail_mol_id(self):
147 """Test the proper failure of the molecule.name() user function for the mol_id argument.""" 148 149 # Loop over the data types. 150 for data in DATA_TYPES: 151 # Catch the None and str arguments, and skip them. 152 if data[0] == 'None' or data[0] == 'str': 153 continue 154 155 # The argument test. 156 self.assertRaises(RelaxNoneStrError, self.molecule_fns.name, mol_id=data[1])
157 158
159 - def test_name_argfail_name(self):
160 """Test the proper failure of the molecule.name() user function for the name argument.""" 161 162 # Loop over the data types. 163 for data in DATA_TYPES: 164 # Catch the str arguments, and skip them. 165 if data[0] == 'str': 166 continue 167 168 # The argument test. 169 self.assertRaises(RelaxStrError, self.molecule_fns.name, name=data[1])
170