def test_parent(self): self.populateTree() rootnode = self.session.query(GenericSystemTreeNode).filter_by( parent_id=None).one() model = GenericTreeModel(rootnode, treenode=GenericSystemTreeNode) node1index = model.index(0, 0, QtCore.QModelIndex()) node2index = model.index(0, 0, node1index) self.assertEqual(model.data(node1index, QtCore.Qt.DisplayRole), 'DEV') self.assertEqual(model.data(node2index, QtCore.Qt.DisplayRole), 'E1D') data_node1 = model.data(node1index, QtCore.Qt.DisplayRole) node1_node = node1index.internalPointer() self.assertEqual(node1_node.name, 'DEV') node2_node = node2index.internalPointer() self.assertEqual(node2_node.name, 'E1D') node2_parent_index = model.parent(node2index) node2_parent_node = node2_parent_index.internalPointer() self.assertEqual(node2_parent_node.name, 'DEV')
def test_parent(self): self.populateTree() rootnode = self.session.query(Check).filter_by(parent_id=None).first() model = GenericTreeModel(rootnode, treenode=Check) node1index = model.index(1, 0, QtCore.QModelIndex()) node2index = model.index(0, 0, node1index) self.assertEqual(model.data(node1index, QtCore.Qt.DisplayRole), 'Basis') self.assertEqual(model.data(node2index, QtCore.Qt.DisplayRole), 'Post Install') data_node1 = model.data(node1index, QtCore.Qt.DisplayRole) node1_node = node1index.internalPointer() self.assertEqual(node1_node.name, 'Basis') node2_node = node2index.internalPointer() self.assertEqual(node2_node.name, 'Post Install') node2_parent_index = model.parent(node2index) node2_parent_node = node2_parent_index.internalPointer() self.assertEqual(node2_parent_node.name, 'Basis')