def it_knows_when_it_has_a_definition_to_help(self, has_definition_fixture):
        sectPr, expected_value = has_definition_fixture
        footer = _Footer(sectPr, None, WD_HEADER_FOOTER.PRIMARY)

        has_definition = footer._has_definition

        assert has_definition is expected_value
    def but_it_returns_None_when_its_the_first_footer(self):
        doc_elm = element("w:document/w:sectPr")
        sectPr = doc_elm[0]
        footer = _Footer(sectPr, None, None)

        prior_footer = footer._prior_headerfooter

        assert prior_footer is None
    def it_knows_when_it_has_a_definition_to_help(self,
                                                  has_definition_fixture):
        sectPr, expected_value = has_definition_fixture
        footer = _Footer(sectPr, None, WD_HEADER_FOOTER.PRIMARY)

        has_definition = footer._has_definition

        assert has_definition is expected_value
    def but_it_returns_None_when_its_the_first_footer(self):
        doc_elm = element("w:document/w:sectPr")
        sectPr = doc_elm[0]
        footer = _Footer(sectPr, None, None)

        prior_footer = footer._prior_headerfooter

        assert prior_footer is None
    def it_can_drop_the_related_footer_part_to_help(self, document_part_):
        sectPr = element("w:sectPr{r:a=b}/w:footerReference{w:type=first,r:id=rId42}")
        footer = _Footer(sectPr, document_part_, WD_HEADER_FOOTER.FIRST_PAGE)

        footer._drop_definition()

        assert sectPr.xml == xml("w:sectPr{r:a=b}")
        document_part_.drop_rel.assert_called_once_with("rId42")
    def it_can_drop_the_related_footer_part_to_help(self, document_part_):
        sectPr = element(
            "w:sectPr{r:a=b}/w:footerReference{w:type=first,r:id=rId42}")
        footer = _Footer(sectPr, document_part_, WD_HEADER_FOOTER.FIRST_PAGE)

        footer._drop_definition()

        assert sectPr.xml == xml("w:sectPr{r:a=b}")
        document_part_.drop_rel.assert_called_once_with("rId42")
    def it_provides_access_to_its_footer_part_to_help(self, document_part_,
                                                      footer_part_):
        sectPr = element("w:sectPr/w:footerReference{w:type=even,r:id=rId3}")
        document_part_.footer_part.return_value = footer_part_
        footer = _Footer(sectPr, document_part_, WD_HEADER_FOOTER.EVEN_PAGE)

        footer_part = footer._definition

        document_part_.footer_part.assert_called_once_with("rId3")
        assert footer_part is footer_part_
    def it_can_add_a_footer_part_to_help(self, document_part_, footer_part_):
        sectPr = element("w:sectPr{r:a=b}")
        document_part_.add_footer_part.return_value = footer_part_, "rId3"
        footer = _Footer(sectPr, document_part_, WD_HEADER_FOOTER.PRIMARY)

        footer_part = footer._add_definition()

        document_part_.add_footer_part.assert_called_once_with()
        assert sectPr.xml == xml(
            "w:sectPr{r:a=b}/w:footerReference{w:type=default,r:id=rId3}")
        assert footer_part is footer_part_
    def it_provides_access_to_its_footer_part_to_help(
        self, document_part_, footer_part_
    ):
        sectPr = element("w:sectPr/w:footerReference{w:type=even,r:id=rId3}")
        document_part_.footer_part.return_value = footer_part_
        footer = _Footer(sectPr, document_part_, WD_HEADER_FOOTER.EVEN_PAGE)

        footer_part = footer._definition

        document_part_.footer_part.assert_called_once_with("rId3")
        assert footer_part is footer_part_
    def it_can_add_a_footer_part_to_help(self, document_part_, footer_part_):
        sectPr = element("w:sectPr{r:a=b}")
        document_part_.add_footer_part.return_value = footer_part_, "rId3"
        footer = _Footer(sectPr, document_part_, WD_HEADER_FOOTER.PRIMARY)

        footer_part = footer._add_definition()

        document_part_.add_footer_part.assert_called_once_with()
        assert sectPr.xml == xml(
            "w:sectPr{r:a=b}/w:footerReference{w:type=default,r:id=rId3}"
        )
        assert footer_part is footer_part_
    def it_provides_access_to_the_prior_Footer_to_help(
        self, request, document_part_, footer_
    ):
        doc_elm = element("w:document/(w:sectPr,w:sectPr)")
        prior_sectPr, sectPr = doc_elm[0], doc_elm[1]
        footer = _Footer(sectPr, document_part_, WD_HEADER_FOOTER.EVEN_PAGE)
        # ---mock must occur after construction of "real" footer---
        _Footer_ = class_mock(request, "docx.section._Footer", return_value=footer_)

        prior_footer = footer._prior_headerfooter

        _Footer_.assert_called_once_with(
            prior_sectPr, document_part_, WD_HEADER_FOOTER.EVEN_PAGE
        )
        assert prior_footer is footer_
    def it_provides_access_to_the_prior_Footer_to_help(self, request,
                                                       document_part_,
                                                       footer_):
        doc_elm = element("w:document/(w:sectPr,w:sectPr)")
        prior_sectPr, sectPr = doc_elm[0], doc_elm[1]
        footer = _Footer(sectPr, document_part_, WD_HEADER_FOOTER.EVEN_PAGE)
        # ---mock must occur after construction of "real" footer---
        _Footer_ = class_mock(request,
                              "docx.section._Footer",
                              return_value=footer_)

        prior_footer = footer._prior_headerfooter

        _Footer_.assert_called_once_with(prior_sectPr, document_part_,
                                         WD_HEADER_FOOTER.EVEN_PAGE)
        assert prior_footer is footer_