Ejemplo n.º 1
0
 def it_knows_how_many_paragraphs_in_each_section(self):
     document_elm = element(
         "w:document/w:body/(w:p,w:p,w:p/w:pPr/w:sectPr,w:p/w:pPr/w:sectPr,w:p,w:sectPr)"
     )
     sections = Sections(document_elm, None)
     expected = [3, 1, 1]
     for i, section in enumerate(sections):
         assert len(section.paragraphs) == expected[i]
Ejemplo n.º 2
0
    def it_can_iterate_over_its_Section_instances(self, Section_, section_,
                                                  document_part_):
        document_elm = element(
            "w:document/w:body/(w:p/w:pPr/w:sectPr, w:sectPr)")
        sectPrs = document_elm.xpath("//w:sectPr")
        Section_.return_value = section_
        sections = Sections(document_elm, document_part_)

        section_lst = [s for s in sections]

        assert Section_.call_args_list == [
            call(sectPrs[0], document_part_),
            call(sectPrs[1], document_part_)
        ]
        assert section_lst == [section_, section_]
Ejemplo n.º 3
0
    def it_can_access_its_Section_instances_by_slice(self, Section_, section_,
                                                     document_part_):
        document_elm = element(
            "w:document/w:body/(w:p/w:pPr/w:sectPr,w:p/w:pPr/w:sectPr,w:sectPr)"
        )
        sectPrs = document_elm.xpath("//w:sectPr")
        Section_.return_value = section_
        sections = Sections(document_elm, document_part_)

        section_lst = sections[1:9]

        assert Section_.call_args_list == [
            call(sectPrs[1], document_part_),
            call(sectPrs[2], document_part_)
        ]
        assert section_lst == [section_, section_]
Ejemplo n.º 4
0
 def it_knows_how_many_sections_it_contains(self):
     sections = Sections(
         element("w:document/w:body/(w:p/w:pPr/w:sectPr, w:sectPr)"), None)
     assert len(sections) == 2
Ejemplo n.º 5
0
 def sections(self):
     """|Sections| object providing access to each section in this document."""
     return Sections(self._element, self._part)
Ejemplo n.º 6
0
 def len_fixture(self, document_elm):
     sections = Sections(document_elm)
     return sections, 2
Ejemplo n.º 7
0
 def index_fixture(self, document_elm):
     sections = Sections(document_elm)
     return sections, [0, 1]
Ejemplo n.º 8
0
 def iter_fixture(self, document_elm):
     sections = Sections(document_elm, None)
     return sections, 2