"""Unit test suite for the docx.parts.hdrftr module.""" import pytest from docx.opc.constants import CONTENT_TYPE as CT from docx.opc.constants import RELATIONSHIP_TYPE as RT from docx.opc.part import PartFactory from docx.package import Package from docx.parts.hdrftr import FooterPart, HeaderPart from ..unitutil.cxml import element from ..unitutil.mock import function_mock, initializer_mock, instance_mock, method_mock class DescribeFooterPart: def it_is_used_by_loader_to_construct_footer_part( self, package_, FooterPart_load_, footer_part_ ): partname = "footer1.xml" content_type = CT.WML_FOOTER reltype = RT.FOOTER blob = "" FooterPart_load_.return_value = footer_part_ part = PartFactory(partname, content_type, reltype, blob, package_) FooterPart_load_.assert_called_once_with(partname, content_type, blob, package_) assert part is footer_part_ def it_can_create_a_new_footer_part(self, package_, _default_footer_xml_, parse_xml_, _init_): ftr = element("w:ftr") package_.next_partname.return_value = "/word/footer24.xml" _default_footer_xml_.return_value = "" parse_xml_.return_value = ftr footer_part = FooterPart.new(package_) package_.next_partname.assert_called_once_with("/word/footer%d.xml") _default_footer_xml_.assert_called_once_with() parse_xml_.assert_called_once_with("") _init_.assert_called_once_with( footer_part, "/word/footer24.xml", CT.WML_FOOTER, ftr, package_ ) def it_loads_default_footer_XML_from_a_template_to_help(self): # ---tests integration with OS--- xml_bytes = FooterPart._default_footer_xml() assert xml_bytes.startswith( b"\n") _init_.assert_called_once_with( header_part, "/word/header42.xml", CT.WML_HEADER, hdr, package_ ) def it_loads_default_header_XML_from_a_template_to_help(self): # ---tests integration with OS--- xml_bytes = HeaderPart._default_header_xml() assert xml_bytes.startswith( b"\n