Package test_suite :: Package unit_tests :: Package _data :: Module test_mol_res_spin
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._data.test_mol_res_spin

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007 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 data.mol_res_spin import MoleculeList 
 28   
 29   
30 -class Test_mol_res_spin(TestCase):
31 """Unit tests for the data.mol_res_spin relax module.""" 32
33 - def setUp(self):
34 """Create a mol-res-spin structure for testing all the object methods.""" 35 36 # The initial empty structure. 37 self.mol = MoleculeList() 38 39 # Add a test object to the first molecule, first residue, first spin. 40 self.mol[0].res[0].spin[0].x = 1
41 42
43 - def test_add_mol(self):
44 """Unit test for the 'add_item()' method of the MolecularList class.""" 45 46 # The name of the new molecule. 47 name = 'Ap4Aase' 48 49 # Add a molecule. 50 self.mol.add_item(mol_name=name) 51 52 # Test that the molecule exists. 53 self.assertEqual(self.mol[1].name, name) 54 55 # Test that the molecule's single spin system container does not have the object 'x'. 56 self.assert_(not hasattr(self.mol[1].res[0].spin[0], 'x'))
57 58
59 - def test_add_res(self):
60 """Unit test for the 'add_item()' method of the ResidueList class.""" 61 62 # The name and number of the new residue. 63 name = 'LEU' 64 num = -5 65 66 # Add the residue. 67 self.mol[0].res.add_item(res_name=name, res_num=num) 68 69 # Test that the residue exists. 70 self.assertEqual(self.mol[0].res[1].name, name) 71 self.assertEqual(self.mol[0].res[1].num, num) 72 73 # Test that the residues' single spin system container does not have the object 'x'. 74 self.assert_(not hasattr(self.mol[0].res[1].spin[0], 'x'))
75 76
77 - def test_add_spin(self):
78 """Unit test for the 'add_item()' method of the SpinList class.""" 79 80 # The name and number of the new spin. 81 name = 'N' 82 num = 1409 83 84 # Add the spin. 85 self.mol[0].res[0].spin.add_item(spin_name=name, spin_num=num, select=0) 86 87 # Test that the spin exists. 88 self.assertEqual(self.mol[0].res[0].spin[1].name, name) 89 self.assertEqual(self.mol[0].res[0].spin[1].num, num) 90 self.assertEqual(self.mol[0].res[0].spin[1].select, 0) 91 92 # Test that the spin system container does not have the object 'x'. 93 self.assert_(not hasattr(self.mol[0].res[0].spin[1], 'x'))
94 95
96 - def test_mol_container_repr(self):
97 """Unit test for the validity of the MoleculeContainer.__repr__() method.""" 98 99 # Test that __repr__() returns a string. 100 self.assert_(type(self.mol[0].__repr__()), str)
101 102
103 - def test_mol_list_repr(self):
104 """Unit test for the validity of the MoleculeList.__repr__() method.""" 105 106 # Test that __repr__() returns a string. 107 self.assert_(type(self.mol.__repr__()), str)
108 109
110 - def test_res_container_repr(self):
111 """Unit test for the validity of the ResidueContainer.__repr__() method.""" 112 113 # Test that __repr__() returns a string. 114 self.assert_(type(self.mol[0].res[0].__repr__()), str)
115 116
117 - def test_res_list_repr(self):
118 """Unit test for the validity of the ResidueList.__repr__() method.""" 119 120 # Test that __repr__() returns a string. 121 self.assert_(type(self.mol[0].res.__repr__()), str)
122 123
124 - def test_spin_container_repr(self):
125 """Unit test for the validity of the SpinContainer.__repr__() method.""" 126 127 # Test that __repr__() returns a string. 128 self.assert_(type(self.mol[0].res[0].spin[0].__repr__()), str)
129 130
131 - def test_spin_list_repr(self):
132 """Unit test for the validity of the SpinList.__repr__() method.""" 133 134 # Test that __repr__() returns a string. 135 self.assert_(type(self.mol[0].res[0].spin.__repr__()), str)
136