99from docx .opc .constants import CONTENT_TYPE as CT , RELATIONSHIP_TYPE as RT
1010from docx .opc .part import PartFactory
1111from docx .package import Package
12- from docx .parts .hdrftr import HeaderPart
12+ from docx .parts .hdrftr import FooterPart , HeaderPart
1313
1414from ..unitutil .cxml import element
1515from ..unitutil .mock import function_mock , initializer_mock , instance_mock , method_mock
1616
1717
18+ class DescribeFooterPart (object ):
19+
20+ def it_can_create_a_new_footer_part (
21+ self , package_ , _default_footer_xml_ , parse_xml_ , _init_
22+ ):
23+ ftr = element ("w:ftr" )
24+ package_ .next_partname .return_value = "/word/footer24.xml"
25+ _default_footer_xml_ .return_value = "<w:ftr>"
26+ parse_xml_ .return_value = ftr
27+
28+ footer_part = FooterPart .new (package_ )
29+
30+ package_ .next_partname .assert_called_once_with ("/word/footer%d.xml" )
31+ _default_footer_xml_ .assert_called_once_with ()
32+ parse_xml_ .assert_called_once_with ("<w:ftr>" )
33+ _init_ .assert_called_once_with (
34+ footer_part , "/word/footer24.xml" , CT .WML_FOOTER , ftr , package_
35+ )
36+
37+ # fixture components ---------------------------------------------
38+
39+ @pytest .fixture
40+ def _default_footer_xml_ (self , request ):
41+ return method_mock (request , FooterPart , "_default_footer_xml" , autospec = False )
42+
43+ @pytest .fixture
44+ def _init_ (self , request ):
45+ return initializer_mock (request , FooterPart )
46+
47+ @pytest .fixture
48+ def package_ (self , request ):
49+ return instance_mock (request , Package )
50+
51+ @pytest .fixture
52+ def parse_xml_ (self , request ):
53+ return function_mock (request , "docx.parts.hdrftr.parse_xml" )
54+
55+
1856class DescribeHeaderPart (object ):
1957
2058 def it_is_used_by_loader_to_construct_header_part (
@@ -73,7 +111,7 @@ def header_part_(self, request):
73111
74112 @pytest .fixture
75113 def _init_ (self , request ):
76- return initializer_mock (request , HeaderPart , autospec = True )
114+ return initializer_mock (request , HeaderPart )
77115
78116 @pytest .fixture
79117 def package_ (self , request ):
0 commit comments