Exemplo n.º 1
0
 def TreeItemDelete(self, event):
     """ Delete the selected tree item """
     # Find what type of node it is (word or tree root)
     node_type = cf.checkNode(self.current_node)
     # Delete the word or tree
     if node_type == 'word':
         cf.deleteWord(self.current_node)
     elif node_type == 'tree':
         cf.deleteTree(self.current_node)
         self.search_root = self.search_words = None
     # Refresh the tree
     self.DisplayTree(self.search_root, self.search_words)
Exemplo n.º 2
0
 def testDelTree(self):
     """ Test deleting a tree """
     # Search for biology, since it's in two trees
     db = self.getDB()
     # First get references to the words
     num_trees, matched_words = cf.searchDB(db, "biology")
     test_source = matched_words[0][1]
     self.assertEqual(num_trees, 2)
     tree_root = cf.findRoot(test_source)
     # Delete a tree
     cf.deleteTree(tree_root)
     # Confirm it happened
     num_trees, matched_words = cf.searchDB(db, "biology")
     test_source = matched_words[0][1]
     self.assertEqual(num_trees, 1)
     tree_root = cf.findRoot(test_source)
     # Try again
     cf.deleteTree(tree_root)
     # Confirm it happened (again)
     num_trees, matched_words = cf.searchDB(db, "biology")
     self.assertEqual(num_trees, 0)