Author: bugman Date: Mon Nov 26 12:21:58 2007 New Revision: 3995 URL: http://svn.gna.org/viewcvs/relax?rev=3995&view=rev Log: Implemented 10 unit tests for fns of the generic_fns.align_tensor and prompt.align_tensor modules. Modified: branches/N_state_model/test_suite/unit_tests/align_tensor_testing_base.py Modified: branches/N_state_model/test_suite/unit_tests/align_tensor_testing_base.py URL: http://svn.gna.org/viewcvs/relax/branches/N_state_model/test_suite/unit_tests/align_tensor_testing_base.py?rev=3995&r1=3994&r2=3995&view=diff ============================================================================== --- branches/N_state_model/test_suite/unit_tests/align_tensor_testing_base.py (original) +++ branches/N_state_model/test_suite/unit_tests/align_tensor_testing_base.py Mon Nov 26 12:21:58 2007 @@ -22,13 +22,189 @@ # relax module imports. from data import Data as relax_data_store +from relax_errors import RelaxError, RelaxNoPipeError, RelaxNoTensorError class Align_tensor_base_class: - """Base class for the tests of both the 'prompt.align_tensor' and 'generic_fns.align_tensor' modules. - + """Base class for the tests of the alignment tensor modules. + + This includes both the 'prompt.align_tensor' and 'generic_fns.align_tensor' modules. This base class also contains many shared unit tests. """ - + def setUp(self): + """Set up for all the alignment tensor unit tests.""" + + # Reset the relax data storage object. + relax_data_store.__reset__() + + # Add a data pipe to the data store. + relax_data_store.add(pipe_name='orig', pipe_type='mf') + + # Add a second data pipe for copying tests. + relax_data_store.add(pipe_name='test', pipe_type='mf') + + # Set the current data pipe to 'orig'. + relax_data_store.current_pipe = 'orig' + + + def tearDown(self): + """Reset the relax data storage object.""" + + relax_data_store.__reset__() + + + def test_copy_pull(self): + """Test the copying of an alignment tensor (pulling the data from another pipe). + + The functions tested are both generic_fns.align_tensor.copy() and + prompt.align_tensor.copy(). + """ + + # Initialise the tensor. + self.align_tensor_fns.init(params=(-16.6278, 6.13037, 7.65639, -1.89157, 19.2561), d_scale=1.0, angle_units='rad', param_types=1) + + # Change the current data pipe. + relax_data_store.current_pipe = 'test' + + # Copy the tensor to the test pipe. + self.align_tensor_fns.copy(pipe_from='orig') + + # Test the alignment tensor. + self.assertEqual(relax_data_store['test'].align_tensor.Axx, -16.6278) + self.assertEqual(relax_data_store['test'].align_tensor.Ayy, 6.13037) + self.assertEqual(relax_data_store['test'].align_tensor.Axy, 7.65639) + self.assertEqual(relax_data_store['test'].align_tensor.Axz, -1.89157) + self.assertEqual(relax_data_store['test'].align_tensor.Ayz, 19.2561) + + + def test_copy_push(self): + """Test the copying of an alignment tensor (pushing the data from another pipe). + + The functions tested are both generic_fns.align_tensor.copy() and + prompt.align_tensor.copy(). + """ + + # Initialise the tensor. + self.align_tensor_fns.init(params=(-16.6278, 6.13037, 7.65639, -1.89157, 19.2561), d_scale=1.0, angle_units='rad', param_types=0) + + # Copy the tensor to the test pipe. + self.align_tensor_fns.copy(pipe_to='test') + + # Test the alignment tensor. + self.assertEqual(relax_data_store['test'].align_tensor.Axx, -16.6278) + self.assertEqual(relax_data_store['test'].align_tensor.Ayy, 6.13037) + self.assertEqual(relax_data_store['test'].align_tensor.Axy, 7.65639) + self.assertEqual(relax_data_store['test'].align_tensor.Axz, -1.89157) + self.assertEqual(relax_data_store['test'].align_tensor.Ayz, 19.2561) + + + def test_delete(self): + """Test the deletion of the alignment tensor data structure. + + The functions tested are both generic_fns.align_tensor.delete() and + prompt.align_tensor.delete(). + """ + + # Set the Axx value. + relax_data_store['orig'].align_tensor.Axx = 0.0 + + # Delete the tensor data. + self.align_tensor_fns.delete() + + # Test that Axx does not exist. + self.failIf(hasattr(relax_data_store['orig'].align_tensor, 'Axx')) + + + def test_delete_fail_no_data(self): + """Failure of deletion of the alignment tensor data structure when there is no data. + + The functions tested are both generic_fns.align_tensor.delete() and + prompt.align_tensor.delete(). + """ + + # Try to delete the tensor data. + self.assertRaises(RelaxNoTensorError, self.align_tensor_fns.delete) + + + def test_delete_fail_no_pipe(self): + """Failure of deletion of the alignment tensor data structure when there is no data pipe. + + The functions tested are both generic_fns.align_tensor.delete() and + prompt.align_tensor.delete(). + """ + + # Reset the relax data store. + relax_data_store.__reset__() + + # Try to delete the tensor data. + self.assertRaises(RelaxNoPipeError, self.align_tensor_fns.delete) + + + def test_display(self): + """Display an alignment tensor. + + The functions tested are both generic_fns.align_tensor.display() and + prompt.align_tensor.display(). + """ + + # Initialise the tensor. + self.align_tensor_fns.init(params=(-16.6278, 6.13037, 7.65639, -1.89157, 19.2561), d_scale=1.0, angle_units='rad', param_types=0) + + # Display the alignment tensor. + self.align_tensor_fns.display() + + + def test_display_fail_no_data(self): + """Failure of the display of the alignment tensor data structure when there is no data. + + The functions tested are both generic_fns.align_tensor.display() and + prompt.align_tensor.display(). + """ + + # Try to display the tensor data. + self.assertRaises(RelaxNoTensorError, self.align_tensor_fns.display) + + + def test_display_fail_no_pipe(self): + """Failure of the display of the alignment tensor data structure when there is no data pipe. + + The functions tested are both generic_fns.align_tensor.display() and + prompt.align_tensor.display(). + """ + + # Reset the relax data store. + relax_data_store.__reset__() + + # Try to display the tensor data. + self.assertRaises(RelaxNoPipeError, self.align_tensor_fns.display) + + + def test_init_bad_angle_units(self): + """Test the failure of setting up a alignment tensor when angle_units is incorrect. + + The functions tested are both generic_fns.align_tensor.init() and + prompt.align_tensor.init(). + """ + + # Initialise the tensor. + self.assertRaises(RelaxError, self.align_tensor_fns.init, params=(-16.6278, 6.13037, 7.65639, -1.89157, 19.2561), angle_units='aaa') + + + def test_init(self): + """Test the setting up of an alignment tensor. + + The functions tested are both generic_fns.align_tensor.init() and + prompt.align_tensor.init(). + """ + + # Initialise the tensor. + self.align_tensor_fns.init(params=(-16.6278, 6.13037, 7.65639, -1.89157, 19.2561), d_scale=1.0, angle_units='rad', param_types=0) + + # Test the alignment tensor. + self.assertEqual(relax_data_store['test'].align_tensor.Axx, -16.6278) + self.assertEqual(relax_data_store['test'].align_tensor.Ayy, 6.13037) + self.assertEqual(relax_data_store['test'].align_tensor.Axy, 7.65639) + self.assertEqual(relax_data_store['test'].align_tensor.Axz, -1.89157) + self.assertEqual(relax_data_store['test'].align_tensor.Ayz, 19.2561)