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

Source Code for Module test_suite.gui_tests.state

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2006-2013 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 os import sep 
 24  import wx 
 25   
 26  # relax module imports. 
 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   
33 -class State(GuiTestCase):
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 # Execute the base class method. 44 super(State, self).__init__(methodName) 45 46 # Skip tests for wxPython 2.9.4.1 bugs. 47 skip = ['test_load_state_no_gui'] 48 if wx.version() == '2.9.4.1 gtk2 (classic)' and methodName in skip: 49 # Store in the status object. 50 status.skipped_tests.append([methodName, 'wxPython 2.9.4.1 gtk2 bugs', self._skip_type])
51 52
53 - def test_bug_20480(self):
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 # Simulate the 'Open relax state' menu entry. 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 # Check that the data has been loaded. 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
71 - def test_old_state_loading(self):
72 """Test the loading of an old relax 1.3 save state with GUI information.""" 73 74 # Simulate the 'Open relax state' menu entry. 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 # Check the analysis structures. 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 # Data checks. 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 # Loop over the residues. 103 for i in range(len(ds[pipe].mol[0].res)): 104 # Alias. 105 res = ds[pipe].mol[0].res[i] 106 107 # Check the 15N spin data. 108 self.assertEqual(res.spin[0].name, 'N') 109 110 # Skip the 1H checks for the NOE and R1 pipes, as no 1H data is recreated. 111 if pipe in ["noe (Wed May 30 20:33:21 2012)", "r1 (Wed May 30 20:55:02 2012)"]: 112 continue 113 114 # Check the 1H spin data. 115 self.assertEqual(res.spin[1].name, 'H')
116 117
118 - def test_load_state_no_gui(self):
119 """Test the loading of a relax save state with no GUI data.""" 120 121 # Simulate the 'Open relax state' menu entry. 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 # Create a data pipe bundle. 126 self._execute_uf(uf_name='pipe.bundle', pipe='a', bundle='test bundle') 127 128 # Show the pipe editor. 129 self.app.gui.show_pipe_editor(None) 130 131 # The menu (this is used to set the selected pipe). 132 self.app.gui.pipe_editor.menu(Fake_grid_cell_right_click()) 133 134 # Associated an auto-analysis with the data pipe. 135 self.app.gui.pipe_editor.associate_auto(None) 136 137 # The index. 138 index = 0 139 140 # Test that the model-free analysis tab is loaded. 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 # Test the relax data store. 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
154 -class Fake_grid_cell_right_click:
155 """Simulate a grid_cell_right_click event .""" 156
157 - def GetRow(self):
158 """Overwrite the GetRow() method.""" 159 160 # Return the first row. 161 return 0
162