Exemplo n.º 1
0
    def it_knows_when_its_linked_to_the_previous_header_or_footer(
            self, is_linked_get_fixture, _has_definition_prop_):
        has_definition, expected_value = is_linked_get_fixture
        _has_definition_prop_.return_value = has_definition
        header = _BaseHeaderFooter(None, None, None)

        is_linked = header.is_linked_to_previous

        assert is_linked is expected_value
Exemplo n.º 2
0
    def it_gets_the_definition_when_it_has_one(self, _has_definition_prop_,
                                               _definition_prop_,
                                               header_part_):
        _has_definition_prop_.return_value = True
        _definition_prop_.return_value = header_part_
        header = _BaseHeaderFooter(None, None, None)

        header_part = header._get_or_add_definition()

        assert header_part is header_part_
Exemplo n.º 3
0
    def it_provides_access_to_the_header_or_footer_part_for_BlockItemContainer(
            self, _get_or_add_definition_, header_part_):
        # ---this override fulfills part of the BlockItemContainer subclass interface---
        _get_or_add_definition_.return_value = header_part_
        header = _BaseHeaderFooter(None, None, None)

        header_part = header.part

        _get_or_add_definition_.assert_called_once_with(header)
        assert header_part is header_part_
Exemplo n.º 4
0
    def it_gets_the_definition_when_it_has_one(
        self, _has_definition_prop_, _definition_prop_, header_part_
    ):
        _has_definition_prop_.return_value = True
        _definition_prop_.return_value = header_part_
        header = _BaseHeaderFooter(None, None, None)

        header_part = header._get_or_add_definition()

        assert header_part is header_part_
Exemplo n.º 5
0
    def it_knows_when_its_linked_to_the_previous_header_or_footer(
        self, is_linked_get_fixture, _has_definition_prop_
    ):
        has_definition, expected_value = is_linked_get_fixture
        _has_definition_prop_.return_value = has_definition
        header = _BaseHeaderFooter(None, None, None)

        is_linked = header.is_linked_to_previous

        assert is_linked is expected_value
Exemplo n.º 6
0
    def it_provides_access_to_the_hdr_or_ftr_element_to_help(
            self, _get_or_add_definition_, header_part_):
        hdr = element("w:hdr")
        _get_or_add_definition_.return_value = header_part_
        header_part_.element = hdr
        header = _BaseHeaderFooter(None, None, None)

        hdr_elm = header._element

        _get_or_add_definition_.assert_called_once_with(header)
        assert hdr_elm is hdr
Exemplo n.º 7
0
    def it_provides_access_to_the_header_or_footer_part_for_BlockItemContainer(
        self, _get_or_add_definition_, header_part_
    ):
        # ---this override fulfills part of the BlockItemContainer subclass interface---
        _get_or_add_definition_.return_value = header_part_
        header = _BaseHeaderFooter(None, None, None)

        header_part = header.part

        _get_or_add_definition_.assert_called_once_with(header)
        assert header_part is header_part_
Exemplo n.º 8
0
    def and_it_adds_a_definition_when_it_is_linked_and_the_first_section(
            self, _has_definition_prop_, _prior_headerfooter_prop_,
            _add_definition_, header_part_):
        _has_definition_prop_.return_value = False
        _prior_headerfooter_prop_.return_value = None
        _add_definition_.return_value = header_part_
        header = _BaseHeaderFooter(None, None, None)

        header_part = header._get_or_add_definition()

        _add_definition_.assert_called_once_with(header)
        assert header_part is header_part_
Exemplo n.º 9
0
    def it_provides_access_to_the_hdr_or_ftr_element_to_help(
        self, _get_or_add_definition_, header_part_
    ):
        hdr = element("w:hdr")
        _get_or_add_definition_.return_value = header_part_
        header_part_.element = hdr
        header = _BaseHeaderFooter(None, None, None)

        hdr_elm = header._element

        _get_or_add_definition_.assert_called_once_with(header)
        assert hdr_elm is hdr
Exemplo n.º 10
0
    def it_can_change_whether_it_is_linked_to_previous_header_or_footer(
        self,
        is_linked_set_fixture,
        _has_definition_prop_,
        _drop_definition_,
        _add_definition_,
    ):
        has_definition, new_value, drop_calls, add_calls = is_linked_set_fixture
        _has_definition_prop_.return_value = has_definition
        header = _BaseHeaderFooter(None, None, None)

        header.is_linked_to_previous = new_value

        assert _drop_definition_.call_args_list == [call(header)] * drop_calls
        assert _add_definition_.call_args_list == [call(header)] * add_calls
Exemplo n.º 11
0
    def it_can_change_whether_it_is_linked_to_previous_header_or_footer(
        self,
        is_linked_set_fixture,
        _has_definition_prop_,
        _drop_definition_,
        _add_definition_,
    ):
        has_definition, new_value, drop_calls, add_calls = is_linked_set_fixture
        _has_definition_prop_.return_value = has_definition
        header = _BaseHeaderFooter(None, None, None)

        header.is_linked_to_previous = new_value

        assert _drop_definition_.call_args_list == [call(header)] * drop_calls
        assert _add_definition_.call_args_list == [call(header)] * add_calls
Exemplo n.º 12
0
    def but_it_gets_the_prior_definition_when_it_is_linked(
        self,
        _has_definition_prop_,
        _prior_headerfooter_prop_,
        prior_headerfooter_,
        header_part_,
    ):
        _has_definition_prop_.return_value = False
        _prior_headerfooter_prop_.return_value = prior_headerfooter_
        prior_headerfooter_._get_or_add_definition.return_value = header_part_
        header = _BaseHeaderFooter(None, None, None)

        header_part = header._get_or_add_definition()

        prior_headerfooter_._get_or_add_definition.assert_called_once_with()
        assert header_part is header_part_
Exemplo n.º 13
0
    def and_it_adds_a_definition_when_it_is_linked_and_the_first_section(
        self,
        _has_definition_prop_,
        _prior_headerfooter_prop_,
        _add_definition_,
        header_part_
    ):
        _has_definition_prop_.return_value = False
        _prior_headerfooter_prop_.return_value = None
        _add_definition_.return_value = header_part_
        header = _BaseHeaderFooter(None, None, None)

        header_part = header._get_or_add_definition()

        _add_definition_.assert_called_once_with(header)
        assert header_part is header_part_
Exemplo n.º 14
0
    def but_it_gets_the_prior_definition_when_it_is_linked(
        self,
        _has_definition_prop_,
        _prior_headerfooter_prop_,
        prior_headerfooter_,
        header_part_,
    ):
        _has_definition_prop_.return_value = False
        _prior_headerfooter_prop_.return_value = prior_headerfooter_
        prior_headerfooter_._get_or_add_definition.return_value = header_part_
        header = _BaseHeaderFooter(None, None, None)

        header_part = header._get_or_add_definition()

        prior_headerfooter_._get_or_add_definition.assert_called_once_with()
        assert header_part is header_part_