1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23  from os import sep 
 24  import wx 
 25   
 26   
 27  from data_store import Relax_data_store; ds = Relax_data_store() 
 28  from pipe_control.pipes import cdp_name 
 29  from status import Status; status = Status() 
 30  from test_suite.gui_tests.base_classes import GuiTestCase 
 31   
 32   
 34      """Class for testing various aspects specific to saved states.""" 
 35   
 36 -    def __init__(self, methodName='runTest'): 
  37          """Skip certain tests due to wxPython bugs. 
 38   
 39          @keyword methodName:    The name of the test. 
 40          @type methodName:       str 
 41          """ 
 42   
 43           
 44          super(State, self).__init__(methodName) 
 45   
 46           
 47          skip = ['test_load_state_no_gui'] 
 48          if wx.version() == '2.9.4.1 gtk2 (classic)' and methodName in skip: 
 49               
 50              status.skipped_tests.append([methodName, 'wxPython 2.9.4.1 gtk2 bugs', self._skip_type]) 
  51   
 52   
 54          """Catch U{bug #20480<https://web.archive.org/web/https://gna.org/bugs/?20480>}, the failure to load a relax state in the GUI. 
 55   
 56          This was reported by U{Stanislava Panova<https://web.archive.org/web/https://gna.org/users/stacy>}. 
 57          """ 
 58   
 59           
 60          file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'saved_states' + sep + 'bug_20480.bz2' 
 61          self.app.gui.state_load(file_name=file) 
 62   
 63           
 64          self.assertEqual(cdp_name(), "aic - mf (Mon Feb  4 13:30:01 2013)") 
 65          self.assertEqual(cdp.spectrometer_frq['NOE_800'], 800000031.0) 
 66          self.assertEqual(cdp.spectrometer_frq['R1_800'], 800000031.0) 
 67          self.assertEqual(cdp.spectrometer_frq['R2_800'], 800000031.0) 
 68          self.assertEqual(cdp.spectrometer_frq['R2_600'], 599999000.0) 
  69   
 70   
 72          """Test the loading of an old relax 1.3 save state with GUI information.""" 
 73   
 74           
 75          file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'saved_states' + sep + 'gui_analyses_1.3.bz2' 
 76          self.app.gui.state_load(file_name=file) 
 77   
 78           
 79          names = ['Steady-state NOE', 'R1 relaxation', 'Model-free'] 
 80          types = ['NOE', 'R1', 'model-free'] 
 81          frq = ['600', '300', None] 
 82          grid_inc = [None, None, 3] 
 83          mc_sim_num = [None, None, 50] 
 84          pipe_names = ['noe (Wed May 30 20:33:21 2012)', 'r1 (Wed May 30 20:55:02 2012)', 'mf (Wed May 30 21:23:17 2012)'] 
 85          save_dirs = ['/data/relax/gui/gui_testing/noe', '/data/relax/gui/gui_testing/r1', '/data/relax/gui/gui_testing/mf'] 
 86          for i in range(len(ds.relax_gui.analyses)): 
 87              self.assertEqual(ds.relax_gui.analyses[i].analysis_name, names[i]) 
 88              self.assertEqual(ds.relax_gui.analyses[i].analysis_type, types[i]) 
 89              self.assertEqual(ds.relax_gui.analyses[i].pipe_name, pipe_names[i]) 
 90              self.assertEqual(ds.relax_gui.analyses[i].save_dir, save_dirs[i]) 
 91              if frq[i] != None: 
 92                  self.assertEqual(ds.relax_gui.analyses[i].frq, frq[i]) 
 93              if grid_inc[i] != None: 
 94                  self.assertEqual(ds.relax_gui.analyses[i].grid_inc, grid_inc[i]) 
 95              if mc_sim_num[i] != None: 
 96                  self.assertEqual(ds.relax_gui.analyses[i].mc_sim_num, mc_sim_num[i]) 
 97   
 98           
 99          self.assertEqual(len(ds), 9) 
100          pipe_names = ["noe (Wed May 30 20:33:21 2012)", "r1 (Wed May 30 20:55:02 2012)", "mf (Wed May 30 21:23:17 2012)", "local_tm", "sphere", "oblate", "prolate", "ellipsoid", "final"] 
101          for pipe in pipe_names: 
102               
103              for i in range(len(ds[pipe].mol[0].res)): 
104                   
105                  res = ds[pipe].mol[0].res[i] 
106   
107                   
108                  self.assertEqual(res.spin[0].name, 'N') 
109   
110                   
111                  if pipe in ["noe (Wed May 30 20:33:21 2012)", "r1 (Wed May 30 20:55:02 2012)"]: 
112                      continue 
113   
114                   
115                  self.assertEqual(res.spin[1].name, 'H') 
 116   
117   
119          """Test the loading of a relax save state with no GUI data.""" 
120   
121           
122          file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'model_free' + sep + 'OMP' + sep + 'final_results_trunc_1.3_v2' 
123          self.app.gui.state_load(file_name=file) 
124   
125           
126          self._execute_uf(uf_name='pipe.bundle', pipe='a', bundle='test bundle') 
127   
128           
129          self.app.gui.show_pipe_editor(None) 
130   
131           
132          self.app.gui.pipe_editor.menu(Fake_grid_cell_right_click()) 
133   
134           
135          self.app.gui.pipe_editor.associate_auto(None) 
136   
137           
138          index = 0 
139   
140           
141          self.assert_(not self.app.gui.analysis.init_state) 
142          self.assertEqual(self.app.gui.analysis._num_analyses, 1) 
143          self.assertEqual(len(self.app.gui.analysis._analyses), 1) 
144          self.assertEqual(self.app.gui.analysis.notebook.GetPageCount(), 1) 
145          self.assert_(self.app.gui.analysis._analyses[index].init_flag) 
146   
147           
148          self.assert_(hasattr(ds, 'relax_gui')) 
149          self.assertEqual(ds.relax_gui.analyses[index].analysis_name, 'Model-free') 
150          self.assertEqual(ds.relax_gui.analyses[index].pipe_name, 'a') 
  151   
152   
153   
155      """Simulate a grid_cell_right_click event .""" 
156   
158          """Overwrite the GetRow() method.""" 
159   
160           
161          return 0 
  162