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-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 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 test_old_state_loading(self):
42 """Test the loading of an old relax 1.3 save state with GUI information.""" 43 44 # Simulate the 'Open relax state' menu entry. 45 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'saved_states' + sep + 'gui_analyses_1.3.bz2' 46 self.app.gui.state_load(file_name=file) 47 48 # Check the analysis structures. 49 names = ['Steady-state NOE', 'R1 relaxation', 'Model-free'] 50 types = ['NOE', 'R1', 'model-free'] 51 frq = ['600', '300', None] 52 grid_inc = [None, None, 3] 53 mc_sim_num = [None, None, 50] 54 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)'] 55 save_dirs = ['/data/relax/gui/gui_testing/noe', '/data/relax/gui/gui_testing/r1', '/data/relax/gui/gui_testing/mf'] 56 for i in range(len(ds.relax_gui.analyses)): 57 self.assertEqual(ds.relax_gui.analyses[i].analysis_name, names[i]) 58 self.assertEqual(ds.relax_gui.analyses[i].analysis_type, types[i]) 59 self.assertEqual(ds.relax_gui.analyses[i].pipe_name, pipe_names[i]) 60 self.assertEqual(ds.relax_gui.analyses[i].save_dir, save_dirs[i]) 61 if frq[i] != None: 62 self.assertEqual(ds.relax_gui.analyses[i].frq, frq[i]) 63 if grid_inc[i] != None: 64 self.assertEqual(ds.relax_gui.analyses[i].grid_inc, grid_inc[i]) 65 if mc_sim_num[i] != None: 66 self.assertEqual(ds.relax_gui.analyses[i].mc_sim_num, mc_sim_num[i]) 67 68 # Data checks. 69 self.assertEqual(len(ds), 9) 70 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"] 71 for pipe in pipe_names: 72 # Loop over the residues. 73 for i in range(len(ds[pipe].mol[0].res)): 74 # Alias. 75 res = ds[pipe].mol[0].res[i] 76 77 # Check the 15N spin data. 78 self.assertEqual(res.spin[0].name, 'N') 79 80 # Skip the 1H checks for the NOE and R1 pipes, as no 1H data is recreated. 81 if pipe in ["noe (Wed May 30 20:33:21 2012)", "r1 (Wed May 30 20:55:02 2012)"]: 82 continue 83 84 # Check the 1H spin data. 85 self.assertEqual(res.spin[1].name, 'H')
86 87
88 - def test_load_state_no_gui(self):
89 """Test the loading of a relax save state with no GUI data.""" 90 91 # Simulate the 'Open relax state' menu entry. 92 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'model_free' + sep + 'OMP' + sep + 'final_results_trunc_1.3_v2' 93 self.app.gui.state_load(file_name=file) 94 95 # Create a data pipe bundle. 96 self._execute_uf(uf_name='pipe.bundle', pipe='a', bundle='test bundle') 97 98 # Show the pipe editor. 99 self.app.gui.show_pipe_editor(None) 100 101 # The menu (this is used to set the selected pipe). 102 self.app.gui.pipe_editor.menu(Fake_grid_cell_right_click()) 103 104 # Associated an auto-analysis with the data pipe. 105 self.app.gui.pipe_editor.associate_auto(None) 106 107 # The index. 108 index = 0 109 110 # Test that the model-free analysis tab is loaded. 111 self.assert_(not self.app.gui.analysis.init_state) 112 self.assertEqual(self.app.gui.analysis._num_analyses, 1) 113 self.assertEqual(len(self.app.gui.analysis._analyses), 1) 114 self.assertEqual(self.app.gui.analysis.notebook.GetPageCount(), 1) 115 self.assert_(self.app.gui.analysis._analyses[index].init_flag) 116 117 # Test the relax data store. 118 self.assert_(hasattr(ds, 'relax_gui')) 119 self.assertEqual(ds.relax_gui.analyses[index].analysis_name, 'Model-free') 120 self.assertEqual(ds.relax_gui.analyses[index].pipe_name, 'a')
121 122 123
124 -class Fake_grid_cell_right_click:
125 """Simulate a grid_cell_right_click event .""" 126
127 - def GetRow(self):
128 """Overwrite the GetRow() method.""" 129 130 # Return the first row. 131 return 0
132