|
8 | 8 |
|
9 | 9 | from docx.enum.section import WD_ORIENT, WD_SECTION |
10 | 10 | from docx.parts.document import DocumentPart |
11 | | -from docx.parts.hdrftr import HeaderPart |
| 11 | +from docx.parts.hdrftr import FooterPart, HeaderPart |
12 | 12 | from docx.section import _BaseHeaderFooter, _Footer, _Header, Section, Sections |
13 | 13 | from docx.shared import Inches |
14 | 14 |
|
@@ -423,6 +423,19 @@ def _has_definition_prop_(self, request): |
423 | 423 |
|
424 | 424 | class Describe_Footer(object): |
425 | 425 |
|
| 426 | + def it_can_add_a_footer_part_to_help(self, document_part_, footer_part_): |
| 427 | + sectPr = element("w:sectPr{r:a=b}") |
| 428 | + document_part_.add_footer_part.return_value = footer_part_, "rId3" |
| 429 | + footer = _Footer(sectPr, document_part_) |
| 430 | + |
| 431 | + footer_part = footer._add_definition() |
| 432 | + |
| 433 | + document_part_.add_footer_part.assert_called_once_with() |
| 434 | + assert sectPr.xml == xml( |
| 435 | + "w:sectPr{r:a=b}/w:footerReference{w:type=default,r:id=rId3}" |
| 436 | + ) |
| 437 | + assert footer_part is footer_part_ |
| 438 | + |
426 | 439 | def it_can_drop_the_related_footer_part_to_help(self, document_part_): |
427 | 440 | sectPr = element("w:sectPr{r:a=b}/w:footerReference{w:type=default,r:id=rId42}") |
428 | 441 | footer = _Footer(sectPr, document_part_) |
@@ -458,6 +471,10 @@ def has_definition_fixture(self, request): |
458 | 471 | def document_part_(self, request): |
459 | 472 | return instance_mock(request, DocumentPart) |
460 | 473 |
|
| 474 | + @pytest.fixture |
| 475 | + def footer_part_(self, request): |
| 476 | + return instance_mock(request, FooterPart) |
| 477 | + |
461 | 478 |
|
462 | 479 | class Describe_Header(object): |
463 | 480 |
|
|
0 commit comments