Ejemplo n.º 1
0
    def testchildSections(self):
        p = QgsProject()
        r = QgsReport(p)
        self.assertEqual(r.childCount(), 0)
        self.assertEqual(r.childSections(), [])
        self.assertIsNone(r.childSection(-1))
        self.assertIsNone(r.childSection(1))
        self.assertIsNone(r.childSection(0))

        # try deleting non-existent childSections
        r.removeChildAt(-1)
        r.removeChildAt(0)
        r.removeChildAt(100)
        r.removeChild(None)

        # append child
        child1 = QgsReportSectionLayout()
        self.assertIsNone(child1.project())
        r.appendChild(child1)
        self.assertEqual(r.childCount(), 1)
        self.assertEqual(r.childSections(), [child1])
        self.assertEqual(r.childSection(0), child1)
        self.assertEqual(child1.parentSection(), r)
        self.assertEqual(child1.row(), 0)
        self.assertEqual(child1.project(), p)
        child2 = QgsReportSectionLayout()
        r.appendChild(child2)
        self.assertEqual(r.childCount(), 2)
        self.assertEqual(r.childSections(), [child1, child2])
        self.assertEqual(r.childSection(1), child2)
        self.assertEqual(child2.parentSection(), r)
        self.assertEqual(child2.row(), 1)
Ejemplo n.º 2
0
    def testchildSections(self):
        p = QgsProject()
        r = QgsReport(p)
        self.assertEqual(r.childCount(), 0)
        self.assertEqual(r.childSections(), [])
        self.assertIsNone(r.childSection(-1))
        self.assertIsNone(r.childSection(1))
        self.assertIsNone(r.childSection(0))

        # try deleting non-existent childSections
        r.removeChildAt(-1)
        r.removeChildAt(0)
        r.removeChildAt(100)
        r.removeChild(None)

        # append child
        child1 = QgsReportSectionLayout()
        self.assertIsNone(child1.project())
        r.appendChild(child1)
        self.assertEqual(r.childCount(), 1)
        self.assertEqual(r.childSections(), [child1])
        self.assertEqual(r.childSection(0), child1)
        self.assertEqual(child1.parentSection(), r)
        self.assertEqual(child1.row(), 0)
        self.assertEqual(child1.project(), p)
        child2 = QgsReportSectionLayout()
        r.appendChild(child2)
        self.assertEqual(r.childCount(), 2)
        self.assertEqual(r.childSections(), [child1, child2])
        self.assertEqual(r.childSection(1), child2)
        self.assertEqual(child2.parentSection(), r)
        self.assertEqual(child2.row(), 1)
Ejemplo n.º 3
0
    def testRemoveChild(self):
        p = QgsProject()
        r = QgsReport(p)

        child1 = QgsReportSectionLayout()
        r.appendChild(child1)
        child2 = QgsReportSectionLayout()
        r.appendChild(child2)

        r.removeChildAt(-1)
        r.removeChildAt(100)
        r.removeChild(None)
        self.assertEqual(r.childCount(), 2)
        self.assertEqual(r.childSections(), [child1, child2])

        r.removeChildAt(1)
        self.assertEqual(r.childCount(), 1)
        self.assertEqual(r.childSections(), [child1])

        r.removeChild(child1)
        self.assertEqual(r.childCount(), 0)
        self.assertEqual(r.childSections(), [])
Ejemplo n.º 4
0
    def testRemoveChild(self):
        p = QgsProject()
        r = QgsReport(p)

        child1 = QgsReportSectionLayout()
        r.appendChild(child1)
        child2 = QgsReportSectionLayout()
        r.appendChild(child2)

        r.removeChildAt(-1)
        r.removeChildAt(100)
        r.removeChild(None)
        self.assertEqual(r.childCount(), 2)
        self.assertEqual(r.childSections(), [child1, child2])

        r.removeChildAt(1)
        self.assertEqual(r.childCount(), 1)
        self.assertEqual(r.childSections(), [child1])

        r.removeChild(child1)
        self.assertEqual(r.childCount(), 0)
        self.assertEqual(r.childSections(), [])