mailr26928 - /branches/nmrglue/test_suite/unit_tests/_pipe_control/test_io.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by tlinnet on December 03, 2014 - 18:38:
Author: tlinnet
Date: Wed Dec  3 18:38:18 2014
New Revision: 26928

URL: http://svn.gna.org/viewcvs/relax?rev=26928&view=rev
Log:
Added unit test of pipe_control io module.

This is a very basic module.

Task #7873 (https://gna.org/task/index.php?7873): Write wrapper function to 
nmrglue, to read .ft2 files and process them.
Homepage: http://www.nmrglue.com/
Link to nmrglue discussion: 
https://groups.google.com/forum/#!forum/nmrglue-discuss
The code is develop at Github: https://github.com/jjhelmus/nmrglue/
Documentation: http://nmrglue.readthedocs.org/en/latest/index.html

Modified:
    branches/nmrglue/test_suite/unit_tests/_pipe_control/test_io.py

Modified: branches/nmrglue/test_suite/unit_tests/_pipe_control/test_io.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/nmrglue/test_suite/unit_tests/_pipe_control/test_io.py?rev=26928&r1=26927&r2=26928&view=diff
==============================================================================
--- branches/nmrglue/test_suite/unit_tests/_pipe_control/test_io.py     
(original)
+++ branches/nmrglue/test_suite/unit_tests/_pipe_control/test_io.py     Wed 
Dec  3 18:38:18 2014
@@ -1,6 +1,7 @@
 
###############################################################################
 #                                                                            
 #
 # Copyright (C) 2007-2014 Edward d'Auvergne                                  
 #
+# Copyright (C) 2014 Troels E. Linnet                                        
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -21,220 +22,30 @@
 
 # relax module imports.
 from data_store import Relax_data_store; ds = Relax_data_store()
-from pipe_control import pipes
-from pipe_control.reset import reset
-from lib.errors import RelaxError, RelaxNoPipeError, RelaxPipeError
+from pipe_control import io
 from test_suite.unit_tests.base_classes import UnitTestCase
 
 
-class Test_pipes(UnitTestCase):
-    """Unit tests for the functions of the 'pipe_control.pipes' module."""
+class Test_io(UnitTestCase):
+    """Unit tests for the functions of the 'pipe_control.io' module."""
 
     def setUp(self):
-        """Set up for all the data pipe unit tests."""
+        """Set up for all the io data pipe unit tests."""
 
         # Add a data pipe to the data store.
         ds.add(pipe_name='orig', pipe_type='mf')
 
-        # Add a single object to the 'orig' data pipe.
-        ds['orig'].x = 1
 
-        # Add a single object to the single spin system of the 'orig' data 
pipe.
-        ds['orig'].mol[0].res[0].spin[0].num = 1
+    def test_add_io_data(self):
+        """Test adding io data to the current pipe.
 
-        # Add an empty data pipe (for the 'eliminate_unused_pipes' test).
-        ds.add(pipe_name='empty', pipe_type='mf')
-
-        # Set the current pipe to the 'orig' data pipe.
-        pipes.switch('orig')
-
-
-    def test_copy(self):
-        """Test the copying of a data pipe.
-
-        The function tested is pipe_control.pipes.copy().
+        The function tested is pipe_control.add_io_data().
         """
 
-        # Copy the 'orig' data pipe to the 'new' data pipe.
-        pipes.copy('orig', 'new')
+        # Add the io data object to the pipe.
+        io_id = 'test_*.ft2'
+        base_name = ['test_0.ft2', 'test_1.ft2']
+        io.add_io_data(object_name='io_basename', io_id=io_id, 
io_data=base_name)
 
-        # Test that the new data pipe exists.
-        self.assert_('new' in ds)
-
-        # Test that the new data pipe has the object 'x' and that its value 
is 1.
-        self.assertEqual(ds['new'].x, 1)
-
-        # Change the value of x.
-        ds['new'].x = 2
-
-        # Test that the two values are different.
-        self.assert_(ds['orig'].x != ds['new'].x)
-
-        # Test that the new data pipe has the object 
'mol[0].res[0].spin[0].num' and that its value is 1.
-        self.assertEqual(ds['new'].mol[0].res[0].spin[0].num, 1)
-
-        # Change the spin system number.
-        ds['new'].mol[0].res[0].spin[0].num = 2
-
-        # Test that the original spin system number hasn't changed.
-        self.assertEqual(ds['orig'].mol[0].res[0].spin[0].num, 1)
-
-
-    def test_copy_current(self):
-        """Test the copying of current data pipe.
-
-        The function tested is pipe_control.pipes.copy().
-        """
-
-        # Copy the 'orig' data pipe to the 'new' data pipe.
-        pipes.copy(pipe_to='new')
-
-        # Test that the new data pipe exists.
-        self.assert_('new' in ds)
-
-        # Test that the new data pipe has the object 'x' and that its value 
is 1.
-        self.assertEqual(ds['new'].x, 1)
-
-        # Change the value of x.
-        ds['new'].x = 2
-
-        # Test that the two values are different.
-        self.assert_(ds['orig'].x != ds['new'].x)
-
-        # Test that the new data pipe has the object 
'mol[0].res[0].spin[0].num' and that its value is 1.
-        self.assertEqual(ds['new'].mol[0].res[0].spin[0].num, 1)
-
-        # Change the spin system number.
-        ds['new'].mol[0].res[0].spin[0].num = 2
-
-        # Test that the original spin system number hasn't changed.
-        self.assertEqual(ds['orig'].mol[0].res[0].spin[0].num, 1)
-
-
-    def test_copy_fail(self):
-        """Test the failure of the copying of data pipes when the data pipe 
to copy to already exists.
-
-        The function tested is pipe_control.pipes.copy()
-        """
-
-        # Assert that a RelaxPipeError occurs when the data pipe to copy 
data to already exists.
-        self.assertRaises(RelaxPipeError, pipes.copy, 'orig', 'empty')
-
-
-    def test_creation(self):
-        """Test the creation of a data pipe.
-
-        The function used is pipe_control.pipes.create().
-        """
-
-        # Create a new model-free data pipe.
-        name = 'new'
-        pipes.create(name, 'mf')
-
-        # Test that the data pipe exists.
-        self.assert_(name in ds)
-
-        # Test that the current pipe is the new pipe.
-        self.assertEqual(pipes.cdp_name(), name)
-
-
-    def test_creation_fail(self):
-        """Test the failure of the creation of a data pipe (by supplying an 
incorrect pipe type).
-
-        The function used is pipe_control.pipes.create().
-        """
-
-        # Assert that a RelaxError occurs when the pipe type is invalid.
-        self.assertRaises(RelaxError, pipes.create, 'new', 'x')
-
-
-    def test_current(self):
-        """Get the current data pipe.
-
-        The function used is pipe_control.pipes.cdp_name().
-        """
-
-        # Test the current pipe.
-        self.assertEqual(pipes.cdp_name(), 'orig')
-
-
-    def test_deletion(self):
-        """Test the deletion of a data pipe.
-
-        The function tested is pipe_control.pipes.delete()
-        """
-
-        # Set the current pipe to the 'orig' data pipe.
-        name = 'orig'
-        pipes.switch(name)
-
-        # Delete the 'orig' data pipe.
-        pipes.delete(name)
-
-        # Test that the data pipe no longer exists.
-        self.assert_(name not in ds)
-
-        # Test that the current pipe is None (as the current pipe was 
deleted).
-        self.assertEqual(pipes.cdp_name(), None)
-
-
-    def test_deletion_fail(self):
-        """Test the failure of the deletion of a data pipe (by suppling a 
non-existant data pipe).
-
-        The function tested is pipe_control.pipes.delete()
-        """
-
-        # Assert that a RelaxNoPipeError occurs when the data pipe does not 
exist.
-        self.assertRaises(RelaxNoPipeError, pipes.delete, 'x')
-
-
-    def test_switch(self):
-        """Test the switching of the current data pipe.
-
-        The function tested is pipe_control.pipes.switch().
-        """
-
-        # Switch to the 'orig' data pipe.
-        pipes.switch('orig')
-
-        # Test the current data pipe.
-        self.assertEqual(pipes.cdp_name(), 'orig')
-
-        # Switch to the 'empty' data pipe.
-        pipes.switch('empty')
-
-        # Test the current data pipe.
-        self.assertEqual(pipes.cdp_name(), 'empty')
-
-
-    def test_switch_fail(self):
-        """Test the failure of switching to a non-existant data pipe.
-
-        The function used is pipe_control.pipes.switch().
-        """
-
-        # Assert that a RelaxNoPipeError occurs when the pipe type is 
invalid.
-        self.assertRaises(RelaxNoPipeError, pipes.switch, 'x')
-
-
-    def test_test(self):
-        """The throwing of RelaxNoPipeError when the pipe does not exist.
-
-        The function tested is pipe_control.pipes.check_pipe().
-        """
-
-        # The following should do nothing as the pipes exist.
-        pipes.check_pipe()
-        pipes.check_pipe('orig')
-        pipes.check_pipe('empty')
-
-        # Assert that a RelaxNoPipeError occurs when the pipe doesn't exist.
-        self.assertRaises(RelaxNoPipeError, pipes.check_pipe, 'x')
-
-        # Reset relax.
-        reset()
-
-        # Now none of the following pipes exist, hence errors should be 
thrown.
-        self.assertRaises(RelaxNoPipeError, pipes.check_pipe)
-        self.assertRaises(RelaxNoPipeError, pipes.check_pipe, 'orig')
-        self.assertRaises(RelaxNoPipeError, pipes.check_pipe, 'empty')
+        # Test data pipe has the object 'io_basename' and that its value is 
the expected list.
+        self.assertEqual(cdp.io_basename[io_id], base_name)




Related Messages


Powered by MHonArc, Updated Wed Dec 03 18:40:02 2014