Example #1
0
    def testFieldGroupSectionVisibility(self):
        states = QgsVectorLayer("Point?crs=epsg:4326&field=country:string(20)&field=state:string(20)", "points", "memory")

        p = QgsProject()
        r = QgsReport(p)

        # add a child
        child1 = QgsReportSectionFieldGroup()
        child1.setLayer(states)
        child1.setField('country')
        child1_header = QgsLayout(p)
        child1.setHeader(child1_header)
        child1.setHeaderEnabled(True)
        child1_footer = QgsLayout(p)
        child1.setFooter(child1_footer)
        child1.setFooterEnabled(True)
        r.appendChild(child1)

        # check that no header was rendered when no features are found
        self.assertTrue(r.beginRender())
        self.assertFalse(r.next())

        child1.setHeaderVisibility(QgsReportSectionFieldGroup.AlwaysInclude)
        child1.setFooterVisibility(QgsReportSectionFieldGroup.AlwaysInclude)

        # check that the header is included when no features are found
        self.assertTrue(r.beginRender())
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_header)
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_footer)
Example #2
0
    def testFieldGroupSectionVisibility(self):
        states = QgsVectorLayer("Point?crs=epsg:4326&field=country:string(20)&field=state:string(20)", "points", "memory")

        p = QgsProject()
        r = QgsReport(p)

        # add a child
        child1 = QgsReportSectionFieldGroup()
        child1.setLayer(states)
        child1.setField('country')
        child1_header = QgsLayout(p)
        child1.setHeader(child1_header)
        child1.setHeaderEnabled(True)
        child1_footer = QgsLayout(p)
        child1.setFooter(child1_footer)
        child1.setFooterEnabled(True)
        r.appendChild(child1)

        # check that no header was rendered when no features are found
        self.assertTrue(r.beginRender())
        self.assertFalse(r.next())

        child1.setHeaderVisibility(QgsReportSectionFieldGroup.AlwaysInclude)
        child1.setFooterVisibility(QgsReportSectionFieldGroup.AlwaysInclude)

        # check that the header is included when no features are found
        self.assertTrue(r.beginRender())
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_header)
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_footer)
Example #3
0
    def testFieldGroupMultiLayer(self):
        # create a layer
        states = QgsVectorLayer("Point?crs=epsg:4326&field=country:string(20)&field=state:string(20)", "points", "memory")

        attributes = [
            ['Australia', 'QLD'],
            ['NZ', 'state1'],
            ['Australia', 'VIC'],
            ['NZ', 'state2'],
            ['PNG', 'state3'],
            ['Australia', 'NSW']
        ]

        pr = states.dataProvider()
        for a in attributes:
            f = QgsFeature()
            f.initAttributes(2)
            f.setAttribute(0, a[0])
            f.setAttribute(1, a[1])
            self.assertTrue(pr.addFeature(f))

        places = QgsVectorLayer("Point?crs=epsg:4326&field=state:string(20)&field=town:string(20)", "points", "memory")

        attributes = [
            ['QLD', 'Brisbane'],
            ['QLD', 'Emerald'],
            ['state1', 'town1'],
            ['VIC', 'Melbourne'],
            ['state1', 'town2'],
            ['QLD', 'Beerburrum'],
            ['VIC', 'Geelong'],
            ['state3', 'town1']
        ]

        pr = places.dataProvider()
        for a in attributes:
            f = QgsFeature()
            f.initAttributes(2)
            f.setAttribute(0, a[0])
            f.setAttribute(1, a[1])
            self.assertTrue(pr.addFeature(f))

        p = QgsProject()
        r = QgsReport(p)

        # add a child
        child1 = QgsReportSectionFieldGroup()
        child1_body = QgsLayout(p)
        child1.setLayer(states)
        child1.setBody(child1_body)
        child1.setBodyEnabled(True)
        child1.setField('country')
        r.appendChild(child1)
        self.assertTrue(r.beginRender())
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'QLD'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'VIC'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'NSW'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['PNG', 'state3'])
        self.assertFalse(r.next())

        # another group
        # remove body from child1
        child1.setBodyEnabled(False)

        child2 = QgsReportSectionFieldGroup()
        child2_body = QgsLayout(p)
        child2.setLayer(states)
        child2.setBody(child2_body)
        child2.setBodyEnabled(True)
        child2.setField('state')
        child1.appendChild(child2)
        self.assertTrue(r.beginRender())
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'NSW'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'QLD'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'VIC'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['PNG', 'state3'])
        self.assertFalse(r.next())

        # another group

        child3 = QgsReportSectionFieldGroup()
        child3_body = QgsLayout(p)
        child3.setLayer(places)
        child3.setBody(child3_body)
        child3.setBodyEnabled(True)
        child3.setField('town')
        child3.setSortAscending(False)
        child2.appendChild(child3)
        self.assertTrue(r.beginRender())
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'NSW'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'QLD'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Emerald'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Brisbane'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Beerburrum'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'VIC'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Melbourne'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Geelong'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['PNG', 'state3'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state3', 'town1'])
        self.assertFalse(r.next())

        # add headers/footers
        child3_header = QgsLayout(p)
        child3.setHeader(child3_header)
        child3.setHeaderEnabled(True)
        child3_footer = QgsLayout(p)
        child3.setFooter(child3_footer)
        child3.setFooterEnabled(True)

        self.assertTrue(r.beginRender())
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'NSW'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'QLD'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_header)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Emerald'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Emerald'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Brisbane'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Beerburrum'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_footer)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Beerburrum'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'VIC'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_header)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Melbourne'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Melbourne'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Geelong'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_footer)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Geelong'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_header)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_footer)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['PNG', 'state3'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_header)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state3', 'town1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state3', 'town1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_footer)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state3', 'town1'])
        self.assertFalse(r.next())
Example #4
0
    def testFieldGroupMultiLayer(self):
        # create a layer
        states = QgsVectorLayer("Point?crs=epsg:4326&field=country:string(20)&field=state:string(20)", "points", "memory")

        attributes = [
            ['Australia', 'QLD'],
            ['NZ', 'state1'],
            ['Australia', 'VIC'],
            ['NZ', 'state2'],
            ['PNG', 'state3'],
            ['Australia', 'NSW']
        ]

        pr = states.dataProvider()
        for a in attributes:
            f = QgsFeature()
            f.initAttributes(2)
            f.setAttribute(0, a[0])
            f.setAttribute(1, a[1])
            self.assertTrue(pr.addFeature(f))

        places = QgsVectorLayer("Point?crs=epsg:4326&field=state:string(20)&field=town:string(20)", "points", "memory")

        attributes = [
            ['QLD', 'Brisbane'],
            ['QLD', 'Emerald'],
            ['state1', 'town1'],
            ['VIC', 'Melbourne'],
            ['state1', 'town2'],
            ['QLD', 'Beerburrum'],
            ['VIC', 'Geelong'],
            ['state3', 'town1']
        ]

        pr = places.dataProvider()
        for a in attributes:
            f = QgsFeature()
            f.initAttributes(2)
            f.setAttribute(0, a[0])
            f.setAttribute(1, a[1])
            self.assertTrue(pr.addFeature(f))

        p = QgsProject()
        r = QgsReport(p)

        # add a child
        child1 = QgsReportSectionFieldGroup()
        child1_body = QgsLayout(p)
        child1.setLayer(states)
        child1.setBody(child1_body)
        child1.setBodyEnabled(True)
        child1.setField('country')
        r.appendChild(child1)
        self.assertTrue(r.beginRender())
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'QLD'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'VIC'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'NSW'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child1_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['PNG', 'state3'])
        self.assertFalse(r.next())

        # another group
        # remove body from child1
        child1.setBodyEnabled(False)

        child2 = QgsReportSectionFieldGroup()
        child2_body = QgsLayout(p)
        child2.setLayer(states)
        child2.setBody(child2_body)
        child2.setBodyEnabled(True)
        child2.setField('state')
        child1.appendChild(child2)
        self.assertTrue(r.beginRender())
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'NSW'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'QLD'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'VIC'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['PNG', 'state3'])
        self.assertFalse(r.next())

        # another group

        child3 = QgsReportSectionFieldGroup()
        child3_body = QgsLayout(p)
        child3.setLayer(places)
        child3.setBody(child3_body)
        child3.setBodyEnabled(True)
        child3.setField('town')
        child3.setSortAscending(False)
        child2.appendChild(child3)
        self.assertTrue(r.beginRender())
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'NSW'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'QLD'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Emerald'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Brisbane'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Beerburrum'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'VIC'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Melbourne'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Geelong'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['PNG', 'state3'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state3', 'town1'])
        self.assertFalse(r.next())

        # add headers/footers
        child3_header = QgsLayout(p)
        child3.setHeader(child3_header)
        child3.setHeaderEnabled(True)
        child3_footer = QgsLayout(p)
        child3.setFooter(child3_footer)
        child3.setFooterEnabled(True)

        self.assertTrue(r.beginRender())
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'NSW'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'QLD'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_header)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Emerald'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Emerald'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Brisbane'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Beerburrum'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_footer)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['QLD', 'Beerburrum'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['Australia', 'VIC'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_header)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Melbourne'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Melbourne'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Geelong'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_footer)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['VIC', 'Geelong'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_header)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_footer)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state1', 'town1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['NZ', 'state2'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child2_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['PNG', 'state3'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_header)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state3', 'town1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_body)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state3', 'town1'])
        self.assertTrue(r.next())
        self.assertEqual(r.layout(), child3_footer)
        self.assertEqual(r.layout().reportContext().feature().attributes(), ['state3', 'town1'])
        self.assertFalse(r.next())