Author: bugman Date: Mon Dec 17 18:42:13 2012 New Revision: 18153 URL: http://svn.gna.org/viewcvs/relax?rev=18153&view=rev Log: Created the Selection system test class. This currently has the test Selection.test_deselect_all for checking the deselect.all user function. The number of tests will be expanded in the future to cover interatomic data containers and the operation of all the select and deselect user functions. Added: trunk/test_suite/system_tests/selection.py Modified: trunk/test_suite/system_tests/__init__.py Modified: trunk/test_suite/system_tests/__init__.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/system_tests/__init__.py?rev=18153&r1=18152&r2=18153&view=diff ============================================================================== --- trunk/test_suite/system_tests/__init__.py (original) +++ trunk/test_suite/system_tests/__init__.py Mon Dec 17 18:42:13 2012 @@ -59,6 +59,7 @@ from test_suite.system_tests.relax_data import Relax_data from test_suite.system_tests.relax_fit import Relax_fit from test_suite.system_tests.results import Results +from test_suite.system_tests.selection import Selection from test_suite.system_tests.sequence import Sequence from test_suite.system_tests.state import State from test_suite.system_tests.structure import Structure @@ -92,6 +93,7 @@ 'relax_data', 'relax_fit', 'results', + 'selection', 'sequence', 'state', 'structure', @@ -178,6 +180,7 @@ suite_array.append(TestLoader().loadTestsFromTestCase(Relax_data)) suite_array.append(TestLoader().loadTestsFromTestCase(Relax_fit)) suite_array.append(TestLoader().loadTestsFromTestCase(Results)) + suite_array.append(TestLoader().loadTestsFromTestCase(Selection)) suite_array.append(TestLoader().loadTestsFromTestCase(Sequence)) suite_array.append(TestLoader().loadTestsFromTestCase(State)) suite_array.append(TestLoader().loadTestsFromTestCase(Structure)) Added: trunk/test_suite/system_tests/selection.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/system_tests/selection.py?rev=18153&view=auto ============================================================================== --- trunk/test_suite/system_tests/selection.py (added) +++ trunk/test_suite/system_tests/selection.py Mon Dec 17 18:42:13 2012 @@ -1,0 +1,80 @@ +############################################################################### +# # +# Copyright (C) 2012 Edward d'Auvergne # +# # +# This file is part of the program relax (http://www.nmr-relax.com). # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <http://www.gnu.org/licenses/>. # +# # +############################################################################### + +"""System tests for testing the select and deselect user functions.""" + +# relax module imports. +from generic_fns.mol_res_spin import spin_loop +from test_suite.system_tests.base_classes import SystemTestCase + + +class Selection(SystemTestCase): + """Class for testing the select and deselect user functions.""" + + def setUp(self): + """Initialise some molecule, residue and spin data for testing.""" + + # Create a data pipe. + self.interpreter.pipe.create('spin data', 'mf') + + # Add a molecule. + self.interpreter.molecule.create(mol_name='X', mol_type='protein') + + # Add some residues. + self.interpreter.residue.create(1, 'a') + self.interpreter.residue.create(2, 'b') + self.interpreter.residue.create(3, 'c') + + # Add some spins. + for i in range(3): + self.interpreter.spin.create('C', res_num=i+1) + self.interpreter.spin.create('N', res_num=i+1) + self.interpreter.spin.create('H', res_num=i+1) + + + def check_spin_selection(self, selection): + """Check if the given selection matches the spin selections. + + @param selection: The list of spin selections in the spin order created in the setUp() method. + @type selection: list of bool + """ + + # Loop over the spins. + i = 0 + for spin, spin_id in spin_loop(return_id=True): + # Print out. + print("Checking the selection state of spin '%s'." % spin_id) + + # Check. + self.assertEqual(selection[i], spin.select) + + # Increment the counter. + i += 1 + + + def test_deselect_all(self): + """Check the operation of the deselect.all user function.""" + + # The user function. + self.interpreter.deselect.all() + + # Check the data. + self.check_spin_selection([False]*9)