Exemplo n.º 1
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
Exemplo n.º 2
0
    def test_insertRow(self):
        rootnode = self.session.query(Check).filter_by(parent_id=None).first()
        model = GenericTreeModel(rootnode, treenode=Check)
        index = model.createIndex(0, 0, rootnode)
        child_count_root = model.rowCount(index)
        self.assertEqual(child_count_root, 0)

        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)
        child_count_root = model.rowCount(index)
        self.assertEqual(child_count_root,
                         1)  #Successfully added one new system
        self.assertTrue(model.hasChildren(index))  #Another test