def it_can_add_a_heading(self, add_heading_fixture, add_paragraph_, paragraph_):
        level, style = add_heading_fixture
        add_paragraph_.return_value = paragraph_
        document = Document(None, None)

        paragraph = document.add_heading("Spam vs. Bacon", level)

        add_paragraph_.assert_called_once_with(document, "Spam vs. Bacon", style)
        assert paragraph is paragraph_
    def it_can_add_a_page_break(self, add_paragraph_, paragraph_, run_):
        add_paragraph_.return_value = paragraph_
        paragraph_.add_run.return_value = run_
        document = Document(None, None)

        paragraph = document.add_page_break()

        add_paragraph_.assert_called_once_with(document)
        paragraph_.add_run.assert_called_once_with()
        run_.add_break.assert_called_once_with(WD_BREAK.PAGE)
        assert paragraph is paragraph_
    def it_can_add_a_section(
        self, add_section_fixture, Section_, section_, document_part_
    ):
        document_elm, start_type, expected_xml = add_section_fixture
        Section_.return_value = section_
        document = Document(document_elm, document_part_)

        section = document.add_section(start_type)

        assert document.element.xml == expected_xml
        sectPr = document.element.xpath('w:body/w:sectPr')[0]
        Section_.assert_called_once_with(sectPr, document_part_)
        assert section is section_
 def block_width_fixture(self, sections_prop_, section_):
     document = Document(None, None)
     sections_prop_.return_value = [None, section_]
     section_.page_width = 6000
     section_.left_margin = 1500
     section_.right_margin = 1000
     expected_value = 3500
     return document, expected_value
    def it_provides_access_to_its_sections(self, document_part_, Sections_, sections_):
        document_elm = element('w:document')
        Sections_.return_value = sections_
        document = Document(document_elm, document_part_)

        sections = document.sections

        Sections_.assert_called_once_with(document_elm, document_part_)
        assert sections is sections_
 def tables_fixture(self, body_prop_, tables_):
     document = Document(None, None)
     body_prop_.return_value.tables = tables_
     return document, tables_
 def styles_fixture(self, document_part_, styles_):
     document = Document(None, document_part_)
     document_part_.styles = styles_
     return document, styles_
 def settings_fixture(self, document_part_, settings_):
     document = Document(None, document_part_)
     document_part_.settings = settings_
     return document, settings_
 def save_fixture(self, document_part_):
     document = Document(None, document_part_)
     file_ = 'foobar.docx'
     return document, file_
Пример #10
0
 def part_fixture(self, document_part_):
     document = Document(None, document_part_)
     return document, document_part_
Пример #11
0
 def core_props_fixture(self, document_part_, core_properties_):
     document = Document(None, document_part_)
     document_part_.core_properties = core_properties_
     return document, core_properties_
Пример #12
0
 def body_fixture(self, _Body_, body_):
     document_elm = element('w:document/w:body')
     body_elm = document_elm[0]
     document = Document(document_elm, None)
     return document, body_elm, _Body_, body_
Пример #13
0
 def add_table_fixture(self, _block_width_prop_, body_prop_, table_):
     document = Document(None, None)
     rows, cols, style = 4, 2, 'Light Shading Accent 1'
     body_prop_.return_value.add_table.return_value = table_
     _block_width_prop_.return_value = width = 42
     return document, rows, cols, style, width, table_
Пример #14
0
 def add_picture_fixture(self, request, add_paragraph_, run_, picture_):
     document = Document(None, None)
     path, width, height = 'foobar.png', 100, 200
     add_paragraph_.return_value.add_run.return_value = run_
     run_.add_picture.return_value = picture_
     return document, path, width, height, run_, picture_
Пример #15
0
 def add_paragraph_fixture(self, request, body_prop_, paragraph_):
     text, style = request.param
     document = Document(None, None)
     body_prop_.return_value.add_paragraph.return_value = paragraph_
     return document, text, style, paragraph_
Пример #16
0
 def it_raises_on_heading_level_out_of_range(self):
     document = Document(None, None)
     with pytest.raises(ValueError):
         document.add_heading(level=-1)
     with pytest.raises(ValueError):
         document.add_heading(level=10)
Пример #17
0
 def inline_shapes_fixture(self, document_part_, inline_shapes_):
     document = Document(None, document_part_)
     document_part_.inline_shapes = inline_shapes_
     return document, inline_shapes_
Пример #18
0
 def paragraphs_fixture(self, body_prop_, paragraphs_):
     document = Document(None, None)
     body_prop_.return_value.paragraphs = paragraphs_
     return document, paragraphs_
Пример #19
0
 def document(self):
     """
     A |Document| object providing access to the content of this document.
     """
     return Document(self._element, self)