|
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 |
|
9 | | -from docx.opc.constants import CONTENT_TYPE as CT |
| 9 | +from docx.opc.constants import CONTENT_TYPE as CT, RELATIONSHIP_TYPE as RT |
| 10 | +from docx.opc.part import PartFactory |
10 | 11 | from docx.package import Package |
11 | 12 | from docx.parts.hdrftr import HeaderPart |
12 | 13 |
|
|
16 | 17 |
|
17 | 18 | class DescribeHeaderPart(object): |
18 | 19 |
|
| 20 | + def it_is_used_by_loader_to_construct_header_part( |
| 21 | + self, package_, HeaderPart_load_, header_part_ |
| 22 | + ): |
| 23 | + partname = "header1.xml" |
| 24 | + content_type = CT.WML_HEADER |
| 25 | + reltype = RT.HEADER |
| 26 | + blob = "<w:hdr/>" |
| 27 | + HeaderPart_load_.return_value = header_part_ |
| 28 | + |
| 29 | + part = PartFactory(partname, content_type, reltype, blob, package_) |
| 30 | + |
| 31 | + HeaderPart_load_.assert_called_once_with(partname, content_type, blob, package_) |
| 32 | + assert part is header_part_ |
| 33 | + |
19 | 34 | def it_can_create_a_new_header_part( |
20 | 35 | self, package_, _default_header_xml_, parse_xml_, _init_ |
21 | 36 | ): |
@@ -48,6 +63,14 @@ def it_loads_default_header_XML_from_a_template_to_help(self): |
48 | 63 | def _default_header_xml_(self, request): |
49 | 64 | return method_mock(request, HeaderPart, "_default_header_xml", autospec=False) |
50 | 65 |
|
| 66 | + @pytest.fixture |
| 67 | + def HeaderPart_load_(self, request): |
| 68 | + return method_mock(request, HeaderPart, "load", autospec=False) |
| 69 | + |
| 70 | + @pytest.fixture |
| 71 | + def header_part_(self, request): |
| 72 | + return instance_mock(request, HeaderPart) |
| 73 | + |
51 | 74 | @pytest.fixture |
52 | 75 | def _init_(self, request): |
53 | 76 | return initializer_mock(request, HeaderPart, autospec=True) |
|
0 commit comments