Package test_suite :: Package system_tests :: Module selection
[hide private]
[frames] | no frames]

Source Code for Module test_suite.system_tests.selection

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2012 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  """System tests for testing the select and deselect user functions.""" 
23   
24  # relax module imports. 
25  from generic_fns.mol_res_spin import spin_loop 
26  from test_suite.system_tests.base_classes import SystemTestCase 
27   
28   
29 -class Selection(SystemTestCase):
30 """Class for testing the select and deselect user functions.""" 31
32 - def setUp(self):
33 """Initialise some molecule, residue and spin data for testing.""" 34 35 # Create a data pipe. 36 self.interpreter.pipe.create('spin data', 'mf') 37 38 # Add a molecule. 39 self.interpreter.molecule.create(mol_name='X', mol_type='protein') 40 41 # Add some residues. 42 self.interpreter.residue.create(1, 'a') 43 self.interpreter.residue.create(2, 'b') 44 self.interpreter.residue.create(3, 'c') 45 46 # Add some spins. 47 for i in range(3): 48 self.interpreter.spin.create('C', res_num=i+1) 49 self.interpreter.spin.create('N', res_num=i+1) 50 self.interpreter.spin.create('H', res_num=i+1)
51 52
53 - def check_spin_selection(self, selection):
54 """Check if the given selection matches the spin selections. 55 56 @param selection: The list of spin selections in the spin order created in the setUp() method. 57 @type selection: list of bool 58 """ 59 60 # Loop over the spins. 61 i = 0 62 for spin, spin_id in spin_loop(return_id=True): 63 # Print out. 64 print("Checking the selection state of spin '%s'." % spin_id) 65 66 # Check. 67 self.assertEqual(selection[i], spin.select) 68 69 # Increment the counter. 70 i += 1
71 72
73 - def test_deselect_all(self):
74 """Check the operation of the deselect.all user function.""" 75 76 # The user function. 77 self.interpreter.deselect.all() 78 79 # Check the data. 80 self.check_spin_selection([False]*9)
81