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 F_OK, access, sep 
 24  import wx 
 25   
 26  # relax module imports. 
 27  from data import Relax_data_store; ds = Relax_data_store() 
 28  from generic_fns.mol_res_spin import spin_loop 
 29  from generic_fns.pipes import cdp_name 
 30  from status import Status; status = Status() 
 31  from test_suite.gui_tests.base_classes import GuiTestCase 
 32   
 33  # relax GUI imports. 
 34  from gui.string_conv import int_to_gui, str_to_gui 
 35  from gui.wizard import Wiz_window 
 36   
 37   
38 -class State(GuiTestCase):
39 """Class for testing various aspects specific to saved states.""" 40
41 - def __init__(self, methodName='runTest'):
42 """Skip certain tests due to wxPython bugs. 43 44 @keyword methodName: The name of the test. 45 @type methodName: str 46 """ 47 48 # Execute the base class method. 49 super(State, self).__init__(methodName) 50 51 # Skip tests for wxPython 2.9.4.1 bugs. 52 skip = ['test_load_state_no_gui'] 53 if wx.version() == '2.9.4.1 gtk2 (classic)' and methodName in skip: 54 # Store in the status object. 55 status.skipped_tests.append([methodName, 'wxPython 2.9.4.1 gtk2 bugs', self._skip_type])
56 57
58 - def test_bug_20480(self):
59 """Catch U{bug #20480<https://web.archive.org/web/https://gna.org/bugs/?20480>}, the failure to load a relax state in the GUI. 60 61 This was reported by U{Stanislava Panova<https://web.archive.org/web/https://gna.org/users/stacy>}. 62 """ 63 64 # Simulate the 'Open relax state' menu entry. 65 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'saved_states' + sep + 'bug_20480.bz2' 66 self.app.gui.state_load(file_name=file) 67 68 # Check that the data has been loaded. 69 self.assertEqual(cdp_name(), "aic - mf (Mon Feb 4 13:30:01 2013)") 70 self.assertEqual(cdp.frq['NOE_800'], 800000031.0) 71 self.assertEqual(cdp.frq['R1_800'], 800000031.0) 72 self.assertEqual(cdp.frq['R2_800'], 800000031.0) 73 self.assertEqual(cdp.frq['R2_600'], 599999000.0)
74 75
76 - def test_old_state_loading(self):
77 """Test the loading of an old relax 1.3 save state with GUI information.""" 78 79 # Simulate the 'Open relax state' menu entry. 80 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'saved_states' + sep + 'gui_analyses_1.3.bz2' 81 self.app.gui.state_load(file_name=file) 82 83 # Check the analysis structures. 84 names = ['Steady-state NOE', 'R1 relaxation', 'Model-free'] 85 types = ['NOE', 'R1', 'model-free'] 86 frq = ['600', '300', None] 87 grid_inc = [None, None, 3] 88 mc_sim_num = [None, None, 50] 89 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)'] 90 save_dirs = ['/data/relax/gui/gui_testing/noe', '/data/relax/gui/gui_testing/r1', '/data/relax/gui/gui_testing/mf'] 91 for i in range(len(ds.relax_gui.analyses)): 92 self.assertEqual(ds.relax_gui.analyses[i].analysis_name, names[i]) 93 self.assertEqual(ds.relax_gui.analyses[i].analysis_type, types[i]) 94 self.assertEqual(ds.relax_gui.analyses[i].pipe_name, pipe_names[i]) 95 self.assertEqual(ds.relax_gui.analyses[i].save_dir, save_dirs[i]) 96 if frq[i] != None: 97 self.assertEqual(ds.relax_gui.analyses[i].frq, frq[i]) 98 if grid_inc[i] != None: 99 self.assertEqual(ds.relax_gui.analyses[i].grid_inc, grid_inc[i]) 100 if mc_sim_num[i] != None: 101 self.assertEqual(ds.relax_gui.analyses[i].mc_sim_num, mc_sim_num[i]) 102 103 # Data checks. 104 self.assertEqual(len(ds), 9) 105 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"] 106 for pipe in pipe_names: 107 # Loop over the residues. 108 for i in range(len(ds[pipe].mol[0].res)): 109 # Alias. 110 res = ds[pipe].mol[0].res[i] 111 112 # Check the 15N spin data. 113 self.assertEqual(res.spin[0].name, 'N') 114 115 # Skip the 1H checks for the NOE and R1 pipes, as no 1H data is recreated. 116 if pipe in ["noe (Wed May 30 20:33:21 2012)", "r1 (Wed May 30 20:55:02 2012)"]: 117 continue 118 119 # Check the 1H spin data. 120 self.assertEqual(res.spin[1].name, 'H')
121 122
123 - def test_load_state_no_gui(self):
124 """Test the loading of a relax save state with no GUI data.""" 125 126 # Simulate the 'Open relax state' menu entry. 127 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'model_free' + sep + 'OMP' + sep + 'final_results_trunc_1.3_v2' 128 self.app.gui.state_load(file_name=file) 129 130 # Create a data pipe bundle. 131 self._execute_uf(uf_name='pipe.bundle', pipe='a', bundle='test bundle') 132 133 # Show the pipe editor. 134 self.app.gui.show_pipe_editor(None) 135 136 # The menu (this is used to set the selected pipe). 137 self.app.gui.pipe_editor.menu(Fake_grid_cell_right_click()) 138 139 # Associated an auto-analysis with the data pipe. 140 self.app.gui.pipe_editor.associate_auto(None) 141 142 # The index. 143 index = 0 144 145 # Test that the model-free analysis tab is loaded. 146 self.assert_(not self.app.gui.analysis.init_state) 147 self.assertEqual(self.app.gui.analysis._num_analyses, 1) 148 self.assertEqual(len(self.app.gui.analysis._analyses), 1) 149 self.assertEqual(self.app.gui.analysis.notebook.GetPageCount(), 1) 150 self.assert_(self.app.gui.analysis._analyses[index].init_flag) 151 152 # Test the relax data store. 153 self.assert_(hasattr(ds, 'relax_gui')) 154 self.assertEqual(ds.relax_gui.analyses[index].analysis_name, 'Model-free') 155 self.assertEqual(ds.relax_gui.analyses[index].pipe_name, 'a')
156 157 158
159 -class Fake_grid_cell_right_click:
160 """Simulate a grid_cell_right_click event .""" 161
162 - def GetRow(self):
163 """Overwrite the GetRow() method.""" 164 165 # Return the first row. 166 return 0
167