Пример #1
0
    def test_getNode(self):
        self.populateTree()
        rootnode = self.session.query(Check).filter_by(parent_id=None).first()
        model = GenericTreeModel(rootnode, treenode=Check)

        index = model.index(0, 0, QtCore.QModelIndex())
        node = model.getNode(index)

        self.assertEqual(node.name, 'Authorization')

        index = model.index(99, 2, QtCore.QModelIndex())
        node = model.getNode(index)

        self.assertEqual(node.name, 'RootNode')
Пример #2
0
    def test_getNode(self):
        self.populateTree()
        rootnode = self.session.query(GenericSystemTreeNode).filter_by(
            parent_id=None).one()
        model = GenericTreeModel(rootnode, treenode=GenericSystemTreeNode)

        index = model.index(0, 0, QtCore.QModelIndex())
        node = model.getNode(index)

        self.assertEqual(node.name, 'DEV')

        index = model.index(99, 2, QtCore.QModelIndex())
        node = model.getNode(index)

        self.assertEqual(node.name, 'RootNode')
    def test_insertRow(self):
        rootnode = get_or_create(self.session, Check, parent_id=None, name='RootNode')
        model = GenericTreeModel(rootnode, treenode=Check)
        proxymodel = PolyMorphicFilterProxyModel()
        proxymodel.setSourceModel(model)

        index = QtCore.QModelIndex()

        check=CheckAbapCountTableEntries(name = 'Clients 001 and 066 removed',
                                         description = 'If client 001 is not actively used, it can be deleted. Client 066 is no longer required in any case',
                                         )


        param001 = CheckAbapCountTableEntries__params(
                                         table_name = 'T000',
                                         table_fields = 'MANDT',
                                         expected_count = 0,
                                         operator = 'NE',
                                         where_clause = "MANDT EQ '001'"
                                         )
        param066 = CheckAbapCountTableEntries__params(
                                         table_name = 'T000',
                                         table_fields = 'MANDT',
                                         expected_count = 0,
                                         operator = 'NE',
                                         where_clause = "MANDT EQ '066'"
                                         )
        check.params.append(param001)
        check.params.append(param066)

        print('\nroot node: ')
        print(rootnode._dump())
        print('\ncheck node: ')
        print(check._dump())

        proxymodel.insertRow(position=0, parent=QtCore.QModelIndex(), nodeObject=check)

        print('\nroot node after insertRow: ')
        print(rootnode._dump())

        #proxymodel=PolyMorphicFilterProxyModel()
        #proxymodel.setSourceModel(model)
        proxyRowcount=proxymodel.rowCount(QtCore.QModelIndex())

        sourceRowcount=model.rowCount(QtCore.QModelIndex())

        for count in range(proxyRowcount):
            index = proxymodel.index(count, 0, QtCore.QModelIndex())
            sourceIndex = proxymodel.mapToSource(index)
            node = model.getNode(sourceIndex)
            print('Node {}'.format(count))
            print(node._dump())


#        self.assertTrue(proxymodel.hasChildren(index))  #Another test
        self.assertEqual(proxyRowcount, sourceRowcount)