示例#1
0
    def testIsDescendant(self):
        """ Test checking IsDescendant() """
        # "farho" is a great grand-parent of "farrow"
        # "porcus" is a sibling of "farho"
        db = self.getDB()
        num_trees, matched_words = cf.searchDB(db, "farho")
        test_top = matched_words[0][1]
        num_trees, matched_words = cf.searchDB(db, "farrow")
        test_bottom = matched_words[0][1]
        num_trees, matched_words = cf.searchDB(db, "porcus")
        test_side = matched_words[0][1]

        self.assertEqual(cf.isDescendant(test_top, test_bottom), True)
        self.assertEqual(cf.isDescendant(test_top, test_side), False)
        self.assertEqual(cf.isDescendant(test_bottom, test_top), False)
        self.assertEqual(cf.isDescendant(test_bottom, test_side), False)
示例#2
0
 def DropTreeItem(self, event):
     """ Finish a drop-and-drop for the tree """
     self._drop_node = self.treebox.GetPyData(event.GetItem())
     # Can't drop onto a child of the self._drag_node (infinite loop)
     if cf.isDescendant(self._drag_node, self._drop_node):
         event.Veto()
     else:
         # Okay, move the word
         cf.moveWord(self._drag_node, self._drop_node)
         # Refresh the tree
         self.DisplayTree(self.search_root, self.search_words,
                          select=self._drop_node)