Package test_suite :: Package system_tests :: Module state
[hide private]
[frames] | no frames]

Source Code for Module test_suite.system_tests.state

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2008-2012 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Python module imports. 
 23  from copy import deepcopy 
 24  import sys 
 25  from tempfile import mktemp 
 26   
 27  # relax module imports. 
 28  from data import Relax_data_store; ds = Relax_data_store() 
 29  import dep_check 
 30  from generic_fns.pipes import VALID_TYPES, get_pipe 
 31  from generic_fns.reset import reset 
 32  from status import Status; status = Status() 
 33  from test_suite.system_tests.base_classes import SystemTestCase 
 34   
 35   
36 -class State(SystemTestCase):
37 """Class for testing the state saving and loading user functions.""" 38
39 - def __init__(self, methodName='runTest'):
40 """Skip the tests if the C modules are non-functional. 41 42 @keyword methodName: The name of the test. 43 @type methodName: str 44 """ 45 46 # Execute the base class method. 47 super(State, self).__init__(methodName) 48 49 # Missing module. 50 if not dep_check.C_module_exp_fn and methodName in ['test_write_read_pipes']: 51 # Store in the status object. 52 status.skipped_tests.append([methodName, 'Relax curve-fitting C module', self._skip_type])
53 54
55 - def setUp(self):
56 """Common set up for these system tests.""" 57 58 # Create a temporary file name. 59 self.tmpfile = mktemp()
60 61
62 - def test_state_xml(self):
63 """Test the saving, loading, and second saving and loading of the program state in XML format.""" 64 65 # Create a data pipe. 66 self.interpreter.pipe.create('test', 'mf') 67 68 # Save the state. 69 self.interpreter.state.save(self.tmpfile, force=True) 70 71 # Load the state. 72 self.interpreter.state.load(self.tmpfile, force=True) 73 74 # Save the state. 75 self.interpreter.state.save(self.tmpfile, force=True) 76 77 # Load the state. 78 self.interpreter.state.load(self.tmpfile, force=True)
79 80
81 - def test_write_read_pipes(self):
82 """Test the writing out, and re-reading of data pipes from the state file.""" 83 84 # Create a data pipe. 85 self.interpreter.pipe.create('test', 'mf') 86 87 # Reset relax. 88 reset() 89 90 # The data pipe list. 91 pipe_types = deepcopy(VALID_TYPES) 92 pipe_types.pop(pipe_types.index("frame order")) 93 94 # Create a few data pipes. 95 for i in range(len(pipe_types)): 96 self.interpreter.pipe.create('test' + repr(i), pipe_types[i]) 97 98 # Write the results. 99 self.interpreter.state.save(self.tmpfile) 100 101 # Reset relax. 102 reset() 103 104 # Re-read the results. 105 self.interpreter.state.load(self.tmpfile) 106 107 # Test the pipes. 108 for i in range(len(pipe_types)): 109 # Name. 110 name = 'test' + repr(i) 111 self.assert_(name in ds) 112 113 # Type. 114 pipe = get_pipe(name) 115 self.assertEqual(pipe.pipe_type, pipe_types[i])
116