|
9 | 9 | from docx.opc.constants import CONTENT_TYPE as CT, RELATIONSHIP_TYPE as RT |
10 | 10 | from docx.opc.part import PartFactory |
11 | 11 | from docx.package import Package |
12 | | -from docx.parts.hdrftr import HeaderPart |
| 12 | +from docx.parts.hdrftr import FooterPart, HeaderPart |
13 | 13 |
|
14 | 14 | from ..unitutil.cxml import element |
15 | 15 | from ..unitutil.mock import function_mock, initializer_mock, instance_mock, method_mock |
16 | 16 |
|
17 | 17 |
|
| 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 | + |
18 | 56 | class DescribeHeaderPart(object): |
19 | 57 |
|
20 | 58 | def it_is_used_by_loader_to_construct_header_part( |
@@ -73,7 +111,7 @@ def header_part_(self, request): |
73 | 111 |
|
74 | 112 | @pytest.fixture |
75 | 113 | def _init_(self, request): |
76 | | - return initializer_mock(request, HeaderPart, autospec=True) |
| 114 | + return initializer_mock(request, HeaderPart) |
77 | 115 |
|
78 | 116 | @pytest.fixture |
79 | 117 | def package_(self, request): |
|
0 commit comments