mailr4367 - in /1.3/test_suite/system_tests: __init__.py jw_mapping.py main.py sequence.py


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

Header


Content

Posted by edward on January 05, 2008 - 20:58:
Author: bugman
Date: Sat Jan  5 20:58:57 2008
New Revision: 4367

URL: http://svn.gna.org/viewcvs/relax?rev=4367&view=rev
Log:
Converted all the remaining system/functional tests to the new unittest 
framework.


Modified:
    1.3/test_suite/system_tests/__init__.py
    1.3/test_suite/system_tests/jw_mapping.py
    1.3/test_suite/system_tests/main.py
    1.3/test_suite/system_tests/sequence.py

Modified: 1.3/test_suite/system_tests/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/__init__.py?rev=4367&r1=4366&r2=4367&view=diff
==============================================================================
--- 1.3/test_suite/system_tests/__init__.py (original)
+++ 1.3/test_suite/system_tests/__init__.py Sat Jan  5 20:58:57 2008
@@ -30,6 +30,7 @@
 from angles import Angles
 from diffusion_tensor import Diffusion_tensor
 from generic import Generic
+from jw_mapping import Jw
 from model_free import Mf
 from model_selection import Modsel
 from relax_fit import Relax_fit
@@ -70,6 +71,7 @@
         suite_array.append(TestLoader().loadTestsFromTestCase(Angles))
         
suite_array.append(TestLoader().loadTestsFromTestCase(Diffusion_tensor))
         suite_array.append(TestLoader().loadTestsFromTestCase(Generic))
+        suite_array.append(TestLoader().loadTestsFromTestCase(Jw))
         suite_array.append(TestLoader().loadTestsFromTestCase(Mf))
         suite_array.append(TestLoader().loadTestsFromTestCase(Modsel))
         suite_array.append(TestLoader().loadTestsFromTestCase(Relax_fit))

Modified: 1.3/test_suite/system_tests/jw_mapping.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/jw_mapping.py?rev=4367&r1=4366&r2=4367&view=diff
==============================================================================
--- 1.3/test_suite/system_tests/jw_mapping.py (original)
+++ 1.3/test_suite/system_tests/jw_mapping.py Sat Jan  5 20:58:57 2008
@@ -1,7 +1,7 @@
 
###############################################################################
 #                                                                            
 #
 # Copyright (C) 2006 Chris MacRaild                                          
 #
-# Copyright (C) 2007 Edward d'Auvergne                                       
 #
+# Copyright (C) 2007-2008 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax.                                    
 #
 #                                                                            
 #
@@ -23,108 +23,50 @@
 
 # Python module imports.
 import sys
+from unittest import TestCase
 
 # relax module imports.
 from data import Data as relax_data_store
 from generic_fns.selection import residue_loop
 from physical_constants import N15_CSA, NH_BOND_LENGTH
 
-# The relax data storage object.
+
+class Jw(TestCase):
+    """Class for testing various aspects specific to reduced spectral 
density mapping."""
+
+    def setUp(self):
+        """Set up for all the functional tests."""
+
+        # Create the data pipe.
+        self.relax.interpreter._Pipe.create('jw', 'jw')
 
 
+    def tearDown(self):
+        """Reset the relax data storage object."""
+
+        relax_data_store.__reset__()
 
 
-class Jw:
-    def __init__(self, relax, test_name):
-        """Class for testing various aspects specific to reduced spectral 
density mapping."""
-
-        self.relax = relax
-
-        # Results reading test.
-        if test_name == 'set':
-
-            # The name of the test.
-            self.name = "The user function value.set()"
-
-            # The test.
-            self.test = self.set_value
-
-        # Spectral density calculation test.
-        if test_name == 'calc':
-
-            # The name of the test.
-            self.name = "Spectral density calculation"
-
-            # The test.
-            self.test = self.calc
-
-
-    def calc(self, pipe):
+    def test_calc(self):
         """The spectral density calculation test."""
 
-        # Arguments.
-        self.pipe = pipe
+        # Data directory.
+        dir = sys.path[-1] + '/test_suite/system_tests/data/jw_mapping/'
 
-        # Setup.
-        self.calc_setup()
+        # Data paths.
+        dataPaths = [dir + 'noe.dat',
+                     dir + 'R1.dat',
+                     dir + 'R2.dat']
 
-        # Try the reduced spectral density mapping.
-        self.relax.interpreter._Minimisation.calc()
-
-        # Success.
-        return self.calc_integrity()
-
-
-    def calc_integrity(self):
+        # Data types.
+        dataTypes = [('NOE', '600', 600.0e6),
+                     ('R1', '600', 600.0e6),
+                     ('R2', '600', 600.0e6)]
 
         # Correct jw values:
         j0 = [4.0703318681008998e-09, 3.7739393907014834e-09]
         jwx = [1.8456254300773903e-10, 1.6347516082378241e-10]
         jwh = [1.5598167512718012e-12, 2.9480536599037041e-12]
-
-        # Loop over residues.
-        for res in residue_loop:
-            # Residues -2 and -1 have data.
-            if res.num == -2 or res.num == -1:
-                if not res.spin[0].select:
-                    print 'Residue', res.num, 'unexpectedly not selected'
-                    return
-
-                if abs(res.spin[0].j0 - j0[index]) > j0[index]/1e6:
-                    print 'Error in residue', res.num, 'j0 calculated value'
-                    return
-                if abs(res.spin[0].jwh - jwh[index]) > jwh[index]/1e6:
-                    print 'Error in residue', res.num, 'jwh calculated value'
-                    return
-                if abs(res.spin[0].jwx - jwx[index]) > jwx[index]/1e6:
-                    print 'Error in residue', res.num, 'jwx calculated value'
-                    return
-
-            # Other residues have insufficient data.
-            else:
-                if res.spin[0].select:
-                    print 'Residue', res.num, 'unexpectedly selected'
-                    return
-
-        # Success.
-        return 1
-
-
-    def calc_setup(self):
-        """Setup for the calculation test."""
-
-        dir = sys.path[-1] + '/test_suite/system_tests/data/jw_mapping/'
-
-        dataPaths = [dir + 'noe.dat',
-                     dir + 'R1.dat',
-                     dir + 'R2.dat']
-
-        dataTypes = [('NOE', '600', 600.0e6),
-                     ('R1', '600', 600.0e6),
-                     ('R2', '600', 600.0e6)]
-
-        # Create the data pipe.
-        self.relax.interpreter._Pipe.create(self.pipe, 'jw')
 
         # Read the sequence.
         self.relax.interpreter._Sequence.read(file='test_seq', 
dir=sys.path[-1] + '/test_suite/system_tests/data')
@@ -143,12 +85,25 @@
         # Select the frequency.
         self.relax.interpreter._Jw_mapping.set_frq(frq=600.0 * 1e6)
 
+        # Try the reduced spectral density mapping.
+        self.relax.interpreter._Minimisation.calc()
 
-    def set_value(self, pipe):
-        """The value.set test."""
+        # Loop over residues.
+        for res in residue_loop:
+            # Residues -2 and -1 have data.
+            if res.num == -2 or res.num == -1:
+                self.assert_(res.spin[0].select)
+                self.assertAlmostEqual(res.spin[0].j0, j0[index])
+                self.assertAlmostEqual(res.spin[0].jwh, jwh[index])
+                self.assertAlmostEqual(res.spin[0].jwx, jwx[index])
 
-        # Create the data pipe.
-        self.relax.interpreter._Pipe.create(pipe, 'jw')
+            # Other residues have insufficient data.
+            else:
+                self.assert_(not res.spin[0].select)
+
+
+    def test_set_value(self):
+        """The user function value.set()."""
 
         # Read the sequence.
         self.relax.interpreter._Sequence.read(file='test_seq', 
dir=sys.path[-1] + '/test_suite/system_tests/data')
@@ -159,15 +114,7 @@
         self.relax.interpreter._Value.set(bond_length, 'bond_length')
         self.relax.interpreter._Value.set(csa, 'csa')
 
-        # Test values.
-        for i in xrange(len(relax_data_store[pipe].mol[0].res)):
-            if relax_data_store[pipe].mol[0].res[i].spin[0].r != bond_length:
-                print 'Value of bond_length has not been set correctly'
-                return
-            if relax_data_store[pipe].mol[0].res[i].spin[0].csa != csa:
-                print 'Value of csa has not been set correctly'
-                return
-
-        # Success.
-        return 1
-
+        # Loop over residues.
+        for res in residue_loop:
+            self.assertEqual(res.spin[0].r, NH_BOND_LENGTH)
+            self.assertEqual(res.spin[0].csa, N15_CSA)

Modified: 1.3/test_suite/system_tests/main.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/main.py?rev=4367&r1=4366&r2=4367&view=diff
==============================================================================
--- 1.3/test_suite/system_tests/main.py (original)
+++ 1.3/test_suite/system_tests/main.py Sat Jan  5 20:58:57 2008
@@ -28,8 +28,6 @@
 from test_suite.formatting import *
 
 # Import the tests.
-from jw_mapping import Jw
-from sequence import Sequence
 
 
 class System_tests:
@@ -53,42 +51,6 @@
 
         # Heading.
         heading("The relax test suite")
-
-
-        # Sequence tests.
-        #################
-
-        # Heading.
-        heading("The sequence tests")
-
-        # Initialise the array containing each test element.
-        self.seq_test_array = []
-
-        # User function sequence.read() test.
-        self.seq_test_array.append(Sequence(self.relax, 'read'))
-
-        # Loading the sequence from a PDB file.
-        self.seq_test_array.append(Sequence(self.relax, 'pdb'))
-
-        # Execute the tests.
-        self.exec_tests(self.seq_test_array)
-
-
-        # Reduced spectral density mapping tests.
-        #########################################
-
-        # Heading.
-        heading("The reduced spectral density mapping tests")
-
-        # Initialise the array containing each test element.
-        self.jw_test_array = []
-
-        # User function value.set() test.
-        self.jw_test_array.append(Jw(self.relax, 'set'))
-        self.jw_test_array.append(Jw(self.relax, 'calc'))
-
-        # Execute the tests.
-        self.exec_tests(self.jw_test_array)
 
 
         # Fin.
@@ -146,36 +108,6 @@
         global_pass = 1
 
 
-        # Sequence tests.
-        #################
-
-        # Heading.
-        sys.stdout.write("\nThe sequence tests:\n")
-
-        # Loop over the tests.
-        for test in self.seq_test_array:
-            # Synopsis.
-            global_pass = global_pass and test.passed
-
-            # Print the summary line.
-            summary_line(test.name, test.passed)
-
-
-        # Reduced spectral density Mapping tests.
-        #########################################
-
-        # Heading.
-        sys.stdout.write("\nThe reduced spectral density tests:\n")
-
-        # Loop over the tests.
-        for test in self.jw_test_array:
-            # Synopsis.
-            global_pass = global_pass and test.passed
-
-            # Print the summary line.
-            summary_line(test.name, test.passed)
-
-
         # Synposis.
         ###########
 

Modified: 1.3/test_suite/system_tests/sequence.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/sequence.py?rev=4367&r1=4366&r2=4367&view=diff
==============================================================================
--- 1.3/test_suite/system_tests/sequence.py (original)
+++ 1.3/test_suite/system_tests/sequence.py Sat Jan  5 20:58:57 2008
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2006-2007 Edward d'Auvergne                                  
 #
+# Copyright (C) 2006-2008 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax.                                    
 #
 #                                                                            
 #
@@ -22,56 +22,37 @@
 
 # Python module imports.
 import sys
+from unittest import TestCase
 
 # relax module imports.
-from prompt.pipe import Pipe
-from prompt.sequence import Sequence
+from data import Data as relax_data_store
 
 
-class Sequence:
-    def __init__(self, relax, test_name):
-        """Class for testing the sequence functions."""
+class Sequence(TestCase):
+    """Class for testing the sequence functions."""
 
-        self.relax = relax
+    def setUp(self):
+        """Set up for all the functional tests."""
 
-        # Sequence reading test.
-        if test_name == 'read':
-            # The name of the test.
-            self.name = "The user function sequence.read()"
-
-            # The test.
-            self.test = self.read
-
-        # Loading the sequence from a PDB file test.
-        if test_name == 'pdb':
-            # The name of the test.
-            self.name = "Loading the sequence from a PDB file"
-
-            # The test.
-            self.test = self.pdb
+        # Create the data pipe.
+        self.relax.interpreter._Pipe.create('mf', 'mf')
 
 
-    def pdb(self, pipe):
-        """The sequence loading from a PDB file test."""
+    def tearDown(self):
+        """Reset the relax data storage object."""
 
-        # Create the data pipe.
-        self.relax.interpreter._Pipe.create(pipe, 'mf')
+        relax_data_store.__reset__()
+
+
+    def test_pdb(self):
+        """Load the sequence from a PDB file."""
 
         # Read the sequence.
         self.relax.interpreter._Structure.read_pdb(file='test.pdb', 
dir=sys.path[-1] + '/test_suite/system_tests/data', model=1, load_seq=1)
 
-        # Success.
-        return 1
 
-
-    def read(self, pipe):
+    def test_read(self):
         """The sequence.read() test."""
-
-        # Create the data pipe.
-        self.relax.interpreter._Pipe.create(pipe, 'mf')
 
         # Read the sequence.
         self.relax.interpreter._Sequence.read(file='test_seq', 
dir=sys.path[-1] + '/test_suite/system_tests/data')
-
-        # Success.
-        return 1




Related Messages


Powered by MHonArc, Updated Sat Jan 05 21:40:17 2008