Author: bugman Date: Sun Nov 4 17:58:21 2007 New Revision: 3419 URL: http://svn.gna.org/viewcvs/relax?rev=3419&view=rev Log: Added a unit test for the copying of the molecule data between different data pipes. Modified: 1.3/test_suite/unit_tests/generic_fns/test_molecule.py Modified: 1.3/test_suite/unit_tests/generic_fns/test_molecule.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/generic_fns/test_molecule.py?rev=3419&r1=3418&r2=3419&view=diff ============================================================================== --- 1.3/test_suite/unit_tests/generic_fns/test_molecule.py (original) +++ 1.3/test_suite/unit_tests/generic_fns/test_molecule.py Sun Nov 4 17:58:21 2007 @@ -25,7 +25,7 @@ # relax module imports. from data import Data as relax_data_store -from generic_fns import molecule +from generic_fns import molecule, residue from relax_errors import RelaxError @@ -76,6 +76,48 @@ relax_data_store['orig'].mol[0].res[0].spin[0].x = 2 + def test_copy_between_pipes(self): + """Test the copying of the molecule data between different data pipes. + + The function used is generic_fns.molecule.copy(). + """ + + # Create the first molecule and residue and add some data to its spin container. + molecule.create('Old mol') + residue.create(1, 'Ala') + relax_data_store['orig'].mol[0].res[0].spin[0].num = 111 + relax_data_store['orig'].mol[0].res[0].spin[0].x = 1 + + # Copy the molecule to the second data pipe. + molecule.copy(mol_from='#Old mol', pipe_to='test') + molecule.copy(pipe_from='orig', mol_from='#Old mol', pipe_to='test', mol_to='#New mol') + + # Change the first molecule's data. + relax_data_store['orig'].mol[0].res[0].spin[0].num = 222 + relax_data_store['orig'].mol[0].res[0].spin[0].x = 2 + + # Test the original molecule. + self.assertEqual(relax_data_store['orig'].mol[0].name, 'Old mol') + self.assertEqual(relax_data_store['orig'].mol[0].res[0].num, 1) + self.assertEqual(relax_data_store['orig'].mol[0].res[0].name, 'Ala') + self.assertEqual(relax_data_store['orig'].mol[0].res[0].spin[0].num, 222) + self.assertEqual(relax_data_store['orig'].mol[0].res[0].spin[0].x, 2) + + # Test the new molecule. + self.assertEqual(relax_data_store['test'].mol[0].name, 'Old mol') + self.assertEqual(relax_data_store['test'].mol[0].res[0].num, 1) + self.assertEqual(relax_data_store['test'].mol[0].res[0].name, 'Ala') + self.assertEqual(relax_data_store['test'].mol[0].res[0].spin[0].num, 111) + self.assertEqual(relax_data_store['test'].mol[0].res[0].spin[0].x, 1) + + # Test the second new molecule. + self.assertEqual(relax_data_store['test'].mol[1].name, 'New mol') + self.assertEqual(relax_data_store['test'].mol[1].res[0].num, 1) + self.assertEqual(relax_data_store['test'].mol[1].res[0].name, 'Ala') + self.assertEqual(relax_data_store['test'].mol[1].res[0].spin[0].num, 111) + self.assertEqual(relax_data_store['test'].mol[1].res[0].spin[0].x, 1) + + def test_creation(self): """Test the creation of a molecule data structure.