示例#1
0
    def it_can_get_a_style_id_by_style_or_name_and_type(
        self, _document_part_prop_, document_part_, style_
    ):
        style_type = WD_STYLE_TYPE.PARAGRAPH
        _document_part_prop_.return_value = document_part_
        document_part_.get_style_id.return_value = "BodyText"
        story_part = BaseStoryPart(None, None, None, None)

        style_id = story_part.get_style_id(style_, style_type)

        document_part_.get_style_id.assert_called_once_with(style_, style_type)
        assert style_id == "BodyText"
示例#2
0
    def it_can_get_or_add_an_image(self, package_, image_part_, image_, relate_to_):
        package_.get_or_add_image_part.return_value = image_part_
        relate_to_.return_value = "rId42"
        image_part_.image = image_
        story_part = BaseStoryPart(None, None, None, package_)

        rId, image = story_part.get_or_add_image("image.png")

        package_.get_or_add_image_part.assert_called_once_with("image.png")
        relate_to_.assert_called_once_with(story_part, image_part_, RT.IMAGE)
        assert rId == "rId42"
        assert image is image_
示例#3
0
    def it_can_create_a_new_pic_inline(self, get_or_add_image_, image_, next_id_prop_):
        get_or_add_image_.return_value = "rId42", image_
        image_.scaled_dimensions.return_value = 444, 888
        image_.filename = "bar.png"
        next_id_prop_.return_value = 24
        expected_xml = snippet_text("inline")
        story_part = BaseStoryPart(None, None, None, None)

        inline = story_part.new_pic_inline("foo/bar.png", width=100, height=200)

        get_or_add_image_.assert_called_once_with(story_part, "foo/bar.png")
        image_.scaled_dimensions.assert_called_once_with(100, 200)
        assert inline.xml == expected_xml
示例#4
0
    def it_knows_the_main_document_part_to_help(self, package_, document_part_):
        package_.main_document_part = document_part_
        story_part = BaseStoryPart(None, None, None, package_)

        document_part = story_part._document_part

        assert document_part is document_part_
示例#5
0
    def it_knows_the_next_available_xml_id(self, next_id_fixture):
        story_element, expected_value = next_id_fixture
        story_part = BaseStoryPart(None, None, story_element, None)

        next_id = story_part.next_id

        assert next_id == expected_value
示例#6
0
    def it_provides_access_to_the_package_bookmarks(
        self, _document_part_prop_, document_part_, bookmarks_
    ):
        document_part_.bookmarks = bookmarks_
        _document_part_prop_.return_value = document_part_
        story_part = BaseStoryPart(None, None, None, None)

        bookmarks = story_part.bookmarks

        assert bookmarks is bookmarks_