def it_can_get_the_id_of_a_style(self, style_, styles_prop_, styles_): styles_prop_.return_value = styles_ styles_.get_style_id.return_value = "BodyCharacter" document_part = DocumentPart(None, None, None, None) style_id = document_part.get_style_id(style_, WD_STYLE_TYPE.CHARACTER) styles_.get_style_id.assert_called_once_with(style_, WD_STYLE_TYPE.CHARACTER) assert style_id == "BodyCharacter"
def it_can_get_a_style_by_id(self, styles_prop_, styles_, style_): styles_prop_.return_value = styles_ styles_.get_by_id.return_value = style_ document_part = DocumentPart(None, None, None, None) style = document_part.get_style("BodyText", WD_STYLE_TYPE.PARAGRAPH) styles_.get_by_id.assert_called_once_with("BodyText", WD_STYLE_TYPE.PARAGRAPH) assert style is style_
def it_provides_access_to_a_header_part_by_rId( self, related_parts_prop_, related_parts_, header_part_ ): related_parts_prop_.return_value = related_parts_ related_parts_.__getitem__.return_value = header_part_ document_part = DocumentPart(None, None, None, None) header_part = document_part.header_part("rId11") related_parts_.__getitem__.assert_called_once_with("rId11") assert header_part is header_part_
def it_provides_access_to_a_footer_part_by_rId( self, related_parts_prop_, related_parts_, footer_part_ ): related_parts_prop_.return_value = related_parts_ related_parts_.__getitem__.return_value = footer_part_ document_part = DocumentPart(None, None, None, None) footer_part = document_part.footer_part("rId9") related_parts_.__getitem__.assert_called_once_with("rId9") assert footer_part is footer_part_
def it_can_add_a_header_part(self, package_, HeaderPart_, header_part_, relate_to_): HeaderPart_.new.return_value = header_part_ relate_to_.return_value = "rId7" document_part = DocumentPart(None, None, None, package_) header_part, rId = document_part.add_header_part() HeaderPart_.new.assert_called_once_with(package_) relate_to_.assert_called_once_with(document_part, header_part_, RT.HEADER) assert header_part is header_part_ assert rId == "rId7"
def it_can_add_a_footer_part(self, package_, FooterPart_, footer_part_, relate_to_): FooterPart_.new.return_value = footer_part_ relate_to_.return_value = "rId12" document_part = DocumentPart(None, None, None, package_) footer_part, rId = document_part.add_footer_part() FooterPart_.new.assert_called_once_with(package_) relate_to_.assert_called_once_with(document_part, footer_part_, RT.FOOTER) assert footer_part is footer_part_ assert rId == "rId12"
def inline_shapes_fixture(self, request, InlineShapes_): document_elm = ( a_document().with_nsdecls().with_child( a_body()) ).element body_elm = document_elm[0] document = DocumentPart(None, None, document_elm, None) return document, InlineShapes_, body_elm
def it_provides_access_to_its_styles_part_to_help( self, part_related_by_, styles_part_ ): part_related_by_.return_value = styles_part_ document_part = DocumentPart(None, None, None, None) styles_part = document_part._styles_part part_related_by_.assert_called_once_with(document_part, RT.STYLES) assert styles_part is styles_part_
def it_provides_access_to_the_numbering_part( self, part_related_by_, numbering_part_ ): part_related_by_.return_value = numbering_part_ document_part = DocumentPart(None, None, None, None) numbering_part = document_part.numbering_part part_related_by_.assert_called_once_with(document_part, RT.NUMBERING) assert numbering_part is numbering_part_
def and_it_creates_a_default_styles_part_if_not_present( self, package_, part_related_by_, StylesPart_, styles_part_, relate_to_ ): part_related_by_.side_effect = KeyError StylesPart_.default.return_value = styles_part_ document_part = DocumentPart(None, None, None, package_) styles_part = document_part._styles_part StylesPart_.default.assert_called_once_with(package_) relate_to_.assert_called_once_with(document_part, styles_part_, RT.STYLES) assert styles_part is styles_part_
def and_it_creates_a_numbering_part_if_not_present( self, part_related_by_, relate_to_, NumberingPart_, numbering_part_ ): part_related_by_.side_effect = KeyError NumberingPart_.new.return_value = numbering_part_ document_part = DocumentPart(None, None, None, None) numbering_part = document_part.numbering_part NumberingPart_.new.assert_called_once_with() relate_to_.assert_called_once_with(document_part, numbering_part_, RT.NUMBERING) assert numbering_part is numbering_part_
def it_can_drop_a_specified_header_part(self, drop_rel_): document_part = DocumentPart(None, None, None, None) document_part.drop_header_part("rId42") drop_rel_.assert_called_once_with(document_part, "rId42")
def styles_fixture(self, _styles_part_prop_, styles_part_, styles_): document_part = DocumentPart(None, None, None, None) _styles_part_prop_.return_value = styles_part_ styles_part_.styles = styles_ return document_part, styles_
def settings_fixture(self, _settings_part_prop_, settings_part_, settings_): document_part = DocumentPart(None, None, None, None) _settings_part_prop_.return_value = settings_part_ settings_part_.settings = settings_ return document_part, settings_
def save_fixture(self, package_): document_part = DocumentPart(None, None, None, package_) file_ = 'foobar.docx' return document_part, file_
def core_props_fixture(self, package_, core_properties_): document_part = DocumentPart(None, None, None, package_) package_.core_properties = core_properties_ return document_part, core_properties_