def test_InitialCondition(self): """Check that the initial condition (if any) is correctly set. """ VTAPP.slotFileCloseAll() # Opening a file automatically selects the root node of that file # in the tree viewer VTAPP.slotFileOpen(self.filepath) VTAPP.otLV.setOpen(VTAPP.otLV.selectedItem(), True) # Select /table_samples/nested_table group = VTAPP.otLV.findItem('table_samples', 0) VTAPP.otLV.setOpen(group, True) table = VTAPP.otLV.findItem('nested_table', 0) VTAPP.otLV.setSelected(table, True) # Get the info dictionary of the table dbdoc = VTAPP.dbManager.getDB(table.getFilepath()) leafdoc = VTAPP.leavesManager.createLeafDoc(dbdoc, table.where) source_table = leafdoc.node info = leaves_manager.setInfoDictionary(source_table) leaves_manager.setSearchableFields(source_table, info) # Set the initial condition initial_cond = leaves_manager.setInitialCondition(\ VTAPP.leavesManager.last_query_info, info) # Compare with the expected initial condition expected_value = '' self.assertEqual(initial_cond, expected_value, """The initial condition should be empty""")
def test_QueryComponents(self): """Check that the query dialog works fine. """ VTAPP.slotFileCloseAll() # Opening a file automatically selects the root node of that file # in the tree viewer VTAPP.slotFileOpen(self.filepath) VTAPP.otLV.setOpen(VTAPP.otLV.selectedItem(), True) # Select /table_samples/nested_table group = VTAPP.otLV.findItem('table_samples', 0) VTAPP.otLV.setOpen(group, True) table = VTAPP.otLV.findItem('nested_table', 0) VTAPP.otLV.setSelected(table, True) # Get the info dictionary of the table dbdoc = VTAPP.dbManager.getDB(table.getFilepath()) leafdoc = VTAPP.leavesManager.createLeafDoc(dbdoc, table.where) source_table = leafdoc.node info = leaves_manager.setInfoDictionary(source_table) leaves_manager.setSearchableFields(source_table, info) # Set the initial condition initial_cond = leaves_manager.setInitialCondition(\ VTAPP.leavesManager.last_query_info, info) # Launch the query dialog VTAPP.leavesManager.query_info = {} qdlg = queryDlg.QueryDlg(VTAPP.leavesManager.query_info, info, [], 0, initial_cond, source_table) # The right thing would be something like # qdlg.query_le.setText('query line edit content') # qdlg.name_le.setText('name line edit content') # qdlg.indices_column.setText('my_indices') # qdlg.rstart.setValue(1) # qdlg.rstop.setValue(10) # qdlg.rstep.setValue(2) # qdlg.slotAccept() # Unfortunately it doesn''t work. I think it is due to the fact that we # do not enter the main execution loop of ViTables. As a consequence we # have to do qdlg.query_info['condition'] = 'query line edit content' qdlg.query_info['ft_name'] = 'name line edit content' qdlg.query_info['indices_field_name'] = 'my_indices' qdlg.query_info['rows_range'] = (0, 10, 2) del qdlg # Compare values expected_info = {} expected_info['condition'] = 'query line edit content' expected_info['ft_name'] = 'name line edit content' expected_info['indices_field_name'] = 'my_indices' expected_info['rows_range'] = (0, 10, 2) recovered_query_info = VTAPP.leavesManager.getQueryInfo() self.assertEqual(VTAPP.leavesManager.query_info, expected_info, """The expected query info is not what expected. %s %s""" % (expected_info, recovered_query_info))