Пример #1
0
 def test_insertRows(self):
     rootnode = self.session.query(GenericSystemTreeNode).filter_by(
         parent_id=None).one()
     model = GenericTreeModel(rootnode, treenode=GenericSystemTreeNode)
     index = model.createIndex(0, 0, rootnode)
     model.insertRows(0, 10, index)
     self.assertEqual(model.rowCount(index), 10)
Пример #2
0
    def test_rowCount(self):
        self.populateTree()
        rootnode = self.session.query(Check).filter_by(parent_id=None).first()
        model = GenericTreeModel(rootnode, treenode=Check)
        rootindex = model.createIndex(0, 0, rootnode)

        self.assertEqual(model.rowCount(rootindex), 2)
Пример #3
0
    def test_insertRow(self):
        rootnode = self.session.query(GenericSystemTreeNode).filter_by(
            parent_id=None).one()
        model = GenericTreeModel(rootnode)
        index = model.createIndex(0, 0, rootnode)
        child_count_root = model.rowCount(index)
        self.assertEqual(child_count_root, 0)
        system_node = SystemAbap(name='New SID', sid='NEW')
        model.insertRow(0, index, nodeObject=system_node)
        child_count_root = model.rowCount(index)
        self.assertEqual(child_count_root,
                         1)  #Successfully added one new system
        self.assertTrue(model.hasChildren(index))  #Another test

        #Testing Inserting a new client
        system_index = model.index(0, 0, index)
        child_count_system = model.rowCount(system_index)
        self.assertEqual(child_count_system, 0)  #No new client exists
        self.assertFalse(model.hasChildren(system_index))  #Another test

        client_node = SystemAbapClient(client='000')
        model.insertRow(position=0,
                        parent=system_index,
                        nodeObject=client_node)
        child_count_system = model.rowCount(system_index)
        self.assertEqual(child_count_system,
                         1)  #Successfully added one new system
        self.assertTrue(model.hasChildren(system_index))  #Another test
Пример #4
0
    def test_removeRow(self):
        rootnode = self.session.query(Check).filter_by(parent_id=None).first()
        model = GenericTreeModel(rootnode, treenode=Check)
        index = model.createIndex(0, 0, rootnode)
        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)

        model.insertRow(0, index, nodeObject=check)
        self.assertEqual(model.rowCount(index), 1)
        model.removeRow(0, index)
        self.assertEqual(model.rowCount(index), 0)
Пример #5
0
 def test_flags(self):
     rootnode = self.session.query(Check).filter_by(parent_id=None).first()
     model = GenericTreeModel(rootnode, treenode=Check)
     index = model.createIndex(0, 0, rootnode)
     flags = model.flags(index)
     self.assertEqual(flags, QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable \
                      | QtCore.Qt.ItemIsUserCheckable)
Пример #6
0
 def test_headerData(self):
     rootnode = self.session.query(Check).filter_by(parent_id=None).first()
     model = GenericTreeModel(rootnode, treenode=Check)
     index = model.createIndex(0, 0, QtCore.QModelIndex())
     headerdata = model.headerData(0, QtCore.Qt.Horizontal,
                                   QtCore.Qt.DisplayRole)
     self.assertEqual(headerdata, 'Folder or Check Name')
Пример #7
0
    def test_rowCount(self):
        self.populateTree()
        rootnode = self.session.query(GenericSystemTreeNode).filter_by(
            parent_id=None).one()
        model = GenericTreeModel(rootnode)
        rootindex = model.createIndex(0, 0, rootnode)

        self.assertEqual(model.rowCount(rootindex), 4)
Пример #8
0
 def test_headerData(self):
     rootnode = self.session.query(GenericSystemTreeNode).filter_by(
         parent_id=None).one()
     model = GenericTreeModel(rootnode)
     index = model.createIndex(0, 0, QtCore.QModelIndex())
     headerdata = model.headerData(0, QtCore.Qt.Horizontal,
                                   QtCore.Qt.DisplayRole)
     self.assertEqual(headerdata, 'Name')
Пример #9
0
 def test_data(self):
     self.populateTree()
     rootnode = self.session.query(Check).filter_by(parent_id=None).first()
     model = GenericTreeModel(rootnode, treenode=Check)
     index = model.createIndex(0, 0, rootnode)
     self.assertTrue(index.isValid())
     name = model.data(index, QtCore.Qt.DisplayRole)
     self.assertEqual(name, 'RootNode')
Пример #10
0
 def test_removeRows(self):
     rootnode = self.session.query(Check).filter_by(parent_id=None).first()
     model = GenericTreeModel(rootnode, treenode=Check)
     index = model.createIndex(0, 0, rootnode)
     model.insertRows(0, 10, index)
     self.assertEqual(model.rowCount(index), 10)
     model.removeRows(1, 5, index)
     self.assertEqual(model.rowCount(index), 5)
Пример #11
0
 def test_columnCount(self):
     rootnode = self.session.query(Check).filter_by(parent_id=None).one()
     model = GenericTreeModel(rootnode, treenode=Check)
     column_count = model.columnCount()
     self.assertEqual(column_count, 2)
     rootindex = model.createIndex(0, 0, rootnode)
     self.assertTrue(rootindex.isValid())
     name = model.data(rootindex, QtCore.Qt.DisplayRole)
     assert name == 'RootNode'
Пример #12
0
 def test_setData(self):
     rootnode = self.session.query(GenericSystemTreeNode).filter_by(
         parent_id=None).one()
     model = GenericTreeModel(rootnode)
     index = model.createIndex(0, 0, rootnode)
     self.assertTrue(index.isValid())
     name = model.data(index, QtCore.Qt.DisplayRole)
     self.assertEqual(name, 'RootNode')
     model.setData(index, 'StillRootNode')
     name = model.data(index, QtCore.Qt.DisplayRole)
     self.assertEqual(name, 'StillRootNode')