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

Source Code for Module test_suite.gui_tests.test_user_functions

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 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  """Module for testing the special features of the user function GUI windows.""" 
 23   
 24  # Python module imports. 
 25  from os import sep 
 26   
 27  # relax module imports. 
 28  from status import Status; status = Status() 
 29  from test_suite.gui_tests.base_classes import GuiTestCase 
 30   
 31  # relax GUI imports. 
 32  from gui.interpreter import Interpreter; interpreter = Interpreter() 
 33  from gui.string_conv import float_to_gui, int_to_gui, str_to_gui 
 34  from gui.uf_objects import Uf_storage; uf_store = Uf_storage() 
 35   
 36   
37 -class User_functions(GuiTestCase):
38 """Class for testing special features of the user function GUI windows.""" 39
40 - def test_structure_pdb_read(self):
41 """Test the full operation of the structure.read_pdb user function GUI window.""" 42 43 # Open the pipe.create user function window, set the args and execute. 44 uf = uf_store['pipe.create'] 45 uf._sync = True 46 uf.create_wizard(parent=self.app.gui) 47 uf.page.SetValue('pipe_name', str_to_gui('PDB reading test')) 48 uf.page.SetValue('pipe_type', str_to_gui('mf')) 49 uf.wizard._go_next(None) 50 51 # Open the structure.read_pdb user function window. 52 uf = uf_store['structure.read_pdb'] 53 uf._sync = True 54 uf.create_wizard(parent=self.app.gui) 55 56 # The PDB file to operate on. 57 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'structures' + sep + 'trunc_ubi_pcs.pdb' 58 uf.page.SetValue('file', str_to_gui(file)) 59 60 # Set the models to read. 61 uf.page.SetValue('read_model', str_to_gui('6')) 62 uf.page.uf_args['read_model'].selection_win_show() 63 uf.page.uf_args['read_model'].sel_win.append_row(None) 64 uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(index=0, col=0, label=int_to_gui(2)) 65 uf.page.uf_args['read_model'].sel_win.sequence.SetStringItem(index=1, col=0, label=int_to_gui(4)) 66 uf.page.uf_args['read_model'].selection_win_data() 67 68 # Renumber the models. 69 uf.page.uf_args['set_model_num'].selection_win_show() 70 uf.page.uf_args['set_model_num'].sel_win.append_row(None) 71 uf.page.uf_args['set_model_num'].sel_win.append_row(None) 72 uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(index=0, col=0, label=int_to_gui(1)) 73 uf.page.uf_args['set_model_num'].sel_win.sequence.SetStringItem(index=1, col=0, label=int_to_gui(3)) 74 uf.page.uf_args['set_model_num'].selection_win_data() 75 76 # GUI data checks. 77 self.assertEqual(uf.page.uf_args['read_model'].GetValue(), [2, 4]) 78 self.assertEqual(uf.page.uf_args['set_model_num'].GetValue(), [1, 3]) 79 80 # Execute the user function. 81 uf.wizard._go_next(None) 82 83 # Check the structural data. 84 self.assert_(hasattr(cdp, 'structure')) 85 self.assert_(hasattr(cdp.structure, 'structural_data')) 86 self.assertEqual(len(cdp.structure.structural_data), 2) 87 self.assertEqual(cdp.structure.structural_data[0].num, 1) 88 self.assertEqual(cdp.structure.structural_data[1].num, 3)
89 90
91 - def test_value_set(self):
92 """Test the full operation of the value.set user function GUI window.""" 93 94 # Open the pipe.create user function window, set the args and execute. 95 uf = uf_store['pipe.create'] 96 uf._sync = True 97 uf.create_wizard(parent=self.app.gui) 98 uf.page.SetValue('pipe_name', str_to_gui('value.set user function test')) 99 uf.page.SetValue('pipe_type', str_to_gui('mf')) 100 uf.wizard._go_next(None) 101 102 # Create a spin to add data to. 103 uf = uf_store['spin.create'] 104 uf._sync = True 105 uf.create_wizard(parent=self.app.gui) 106 uf.page.SetValue('res_num', int_to_gui(1)) 107 uf.page.SetValue('res_name', str_to_gui('Gly')) 108 uf.page.SetValue('spin_name', str_to_gui('N')) 109 uf.wizard._go_next(None) 110 111 # Open the value.set user function window. 112 uf = uf_store['value.set'] 113 uf._sync = True 114 uf.create_wizard(parent=self.app.gui) 115 uf.page.SetValue('val', float_to_gui(-0.000172)) 116 uf.page.SetValue('param', str_to_gui('csa')) 117 uf.wizard._go_next(None)
118