1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23  from copy import deepcopy 
 24  from os import sep 
 25  from tempfile import mktemp 
 26   
 27   
 28  from data_store import Relax_data_store; ds = Relax_data_store() 
 29  import dep_check 
 30  from pipe_control.interatomic import interatomic_loop 
 31  from pipe_control.pipes import VALID_TYPES, get_pipe 
 32  from pipe_control.reset import reset 
 33  from status import Status; status = Status() 
 34  from test_suite.system_tests.base_classes import SystemTestCase 
 35   
 36   
 37 -class State(SystemTestCase): 
  38      """Class for testing the state saving and loading user functions.""" 
 39   
 40 -    def __init__(self, methodName='runTest'): 
  41          """Skip the tests if the C modules are non-functional. 
 42   
 43          @keyword methodName:    The name of the test. 
 44          @type methodName:       str 
 45          """ 
 46   
 47           
 48          super(State, self).__init__(methodName) 
 49   
 50           
 51          if not dep_check.C_module_exp_fn and methodName in ['test_write_read_pipes']: 
 52               
 53              status.skipped_tests.append([methodName, 'Relax curve-fitting C module', self._skip_type]) 
  54   
 55   
 57          """Common set up for these system tests.""" 
 58   
 59           
 60          self.tmpfile = mktemp() 
  61   
 62   
 64          """Test the loading of a relax state with an alignment tensor with MC simulation structures.""" 
 65   
 66           
 67          path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'+sep+'align_tensor_mc.bz2' 
 68   
 69           
 70          self.interpreter.state.load(path) 
 71   
 72           
 73          domains = ['Dy N-dom', 'Dy C-dom'] 
 74          rdc = { 
 75              "Dy N-dom" : [-6.41, -21.55], 
 76              "Dy C-dom" : [-21.55] 
 77          } 
 78          rdc_bc = { 
 79              "Dy N-dom" : [None, -20.87317257368743], 
 80              "Dy C-dom" : [None] 
 81          } 
 82   
 83          rdc_err = { 
 84              "Dy N-dom" : [1.0, 1.0], 
 85              "Dy C-dom" : [1.0] 
 86          } 
 87   
 88           
 89          for domain in domains: 
 90               
 91              self.interpreter.pipe.switch(domain) 
 92   
 93               
 94              i = 0 
 95              for interatom in interatomic_loop(): 
 96                   
 97                  self.assertEqual(interatom.rdc[domain], rdc[domain][i]) 
 98                  if rdc_bc[domain][i]: 
 99                      self.assertEqual(interatom.rdc_bc[domain], rdc_bc[domain][i]) 
100                  if rdc_err[domain][i]: 
101                      self.assertEqual(interatom.rdc_err[domain], rdc_err[domain][i]) 
102   
103                   
104                  i += 1 
 105   
106   
119   
120   
138   
139   
141          """Test the writing out, and re-reading of data pipes from the state file.""" 
142   
143           
144          self.interpreter.pipe.create('test', 'mf') 
145   
146           
147          reset() 
148   
149           
150          pipe_types = deepcopy(VALID_TYPES) 
151          pipe_types.pop(pipe_types.index("frame order")) 
152   
153           
154          for i in range(len(pipe_types)): 
155              self.interpreter.pipe.create('test' + repr(i), pipe_types[i]) 
156   
157           
158          self.interpreter.state.save(self.tmpfile) 
159   
160           
161          reset() 
162   
163           
164          self.interpreter.state.load(self.tmpfile) 
165   
166           
167          for i in range(len(pipe_types)): 
168               
169              name = 'test' + repr(i) 
170              self.assert_(name in ds) 
171   
172               
173              pipe = get_pipe(name) 
174              self.assertEqual(pipe.pipe_type, pipe_types[i]) 
  175