def map_headers_footers_xml(self, relKey, xml): part = self.docx._part._rels[relKey].target_part new_part = XmlPart.load(part.partname, part.content_type, xml, part.package) for rId, rel in part.rels.items(): new_part.load_rel(rel.reltype, rel._target, rel.rId, rel.is_external) self.docx._part._rels[relKey]._target = new_part
def it_can_be_constructed_by_PartFactory(self, partname_, content_type_, blob_, package_, element_, parse_xml_, __init_): part = XmlPart.load(partname_, content_type_, blob_, package_) parse_xml_.assert_called_once_with(blob_) __init_.assert_called_once_with(ANY, partname_, content_type_, element_, package_) assert isinstance(part, XmlPart)
def it_can_be_constructed_by_PartFactory(self, load_fixture): partname_, content_type_, blob_, package_ = load_fixture[:4] element_, parse_xml_, __init_ = load_fixture[4:] # exercise --------------------- part = XmlPart.load(partname_, content_type_, blob_, package_) # verify ----------------------- parse_xml_.assert_called_once_with(blob_) __init_.assert_called_once_with(partname_, content_type_, element_, package_) assert isinstance(part, XmlPart)
def it_can_be_constructed_by_PartFactory( self, partname_, content_type_, blob_, package_, element_, parse_xml_, __init_ ): part = XmlPart.load(partname_, content_type_, blob_, package_) parse_xml_.assert_called_once_with(blob_) __init_.assert_called_once_with( ANY, partname_, content_type_, element_, package_ ) assert isinstance(part, XmlPart)
def it_can_be_constructed_by_PartFactory(self, load_fixture): partname_, content_type_, blob_, package_ = load_fixture[:4] element_, parse_xml_, __init_ = load_fixture[4:] # exercise --------------------- part = XmlPart.load(partname_, content_type_, blob_, package_) # verify ----------------------- parse_xml_.assert_called_once_with(blob_) __init_.assert_called_once_with( partname_, content_type_, element_, package_ ) assert isinstance(part, XmlPart)
def part_fixture(self): return XmlPart(None, None, None, None)
def blob_fixture(self, request, element_, serialize_part_xml_): xml_part = XmlPart(None, None, element_, None) return xml_part, element_, serialize_part_xml_