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

Source Code for Module test_suite.unit_tests._data_store.test_mol_res_spin

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