コード例 #1
0
 def test_paragraph_default_portion_format(self):
     BaseTest.slides_api.copy_file(
         "TempTests/" + constant.FILE_NAME,
         constant.FOLDER_NAME + "/" + constant.FILE_NAME)
     dto = Paragraph()
     portion_format = PortionFormat()
     portion_format.font_height = 20
     portion_format.latin_font = "Arial"
     portion1 = Portion()
     portion1.text = "Portion1"
     portion2 = Portion()
     portion2.text = "Portion2"
     dto.portion_list = [portion1, portion2]
     dto.default_portion_format = portion_format
     slide_index = 6
     shape_index = 2
     response = BaseTest.slides_api.create_paragraph(
         constant.FILE_NAME, slide_index, shape_index, dto, None,
         constant.PASSWORD, constant.FOLDER_NAME)
     self.assertEqual(2, len(response.portion_list))
     self.assertIsNotNone(response.default_portion_format)
     self.assertEqual(response.default_portion_format.latin_font,
                      dto.default_portion_format.latin_font)
     self.assertEqual(response.default_portion_format.font_height,
                      dto.default_portion_format.font_height)
    def test_layout_slide_portions(self):
        folder_name = "TempSlidesSDK"
        file_name = "test.pptx"
        password = "******"
        slide_index = 1
        shape_index = 2
        paragraph_index = 1
        portion_count = 1
        BaseTest.slides_api.copy_file("TempTests/" + file_name,
                                      folder_name + "/" + file_name)

        portions = BaseTest.slides_api.get_special_slide_portions(
            file_name, slide_index, 'layoutSlide', shape_index,
            paragraph_index, password, folder_name)
        self.assertEqual(portion_count, len(portions.items))

        dto = Portion()
        dto.text = "New portion"
        dto.font_bold = "True"
        portion = BaseTest.slides_api.create_special_slide_portion(
            file_name, slide_index, 'layoutSlide', shape_index,
            paragraph_index, dto, None, password, folder_name)
        self.assertEqual(dto.font_bold, portion.font_bold)
        self.assertEqual(dto.text, portion.text)
        portions = BaseTest.slides_api.get_special_slide_portions(
            file_name, slide_index, 'layoutSlide', shape_index,
            paragraph_index, password, folder_name)
        self.assertEqual(portion_count + 1, len(portions.items))

        dto2 = Portion()
        dto2.text = "Updated portion"
        dto2.font_height = 22
        portion = BaseTest.slides_api.update_special_slide_portion(
            file_name, slide_index, 'layoutSlide', shape_index,
            paragraph_index, portion_count + 1, dto2, password, folder_name)
        self.assertEqual(dto.font_bold, portion.font_bold)
        self.assertEqual(dto2.font_height, portion.font_height)
        self.assertEqual(dto2.text, portion.text)
        portions = BaseTest.slides_api.get_special_slide_portions(
            file_name, slide_index, 'layoutSlide', shape_index,
            paragraph_index, password, folder_name)
        self.assertEqual(portion_count + 1, len(portions.items))

        BaseTest.slides_api.delete_special_slide_portion(
            file_name, slide_index, 'layoutSlide', shape_index,
            paragraph_index, portion_count + 1, password, folder_name)
        portions = BaseTest.slides_api.get_special_slide_portions(
            file_name, slide_index, 'layoutSlide', shape_index,
            paragraph_index, password, folder_name)
        self.assertEqual(portion_count, len(portions.items))
コード例 #3
0
 def test_create_paragraph_with_portions(self):
     BaseTest.slides_api.copy_file(
         "TempTests/" + constant.FILE_NAME,
         constant.FOLDER_NAME + "/" + constant.FILE_NAME)
     portion1 = Portion()
     portion1.text = "Portion1"
     portion2 = Portion()
     portion2.text = "Portion2"
     dto = Paragraph()
     dto.portion_list = [portion1, portion2]
     slide_index = 6
     shape_index = 2
     response = BaseTest.slides_api.create_paragraph(
         constant.FILE_NAME, slide_index, shape_index, dto, None,
         constant.PASSWORD, constant.FOLDER_NAME)
     self.assertEqual(2, len(response.portion_list))
コード例 #4
0
    def test_create_sub_shape_portion(self):
        dto = Portion()
        dto.text = constant.PORTION_TEXT
        dto.font_bold = "True"
        dto.font_height = 20
        dto.latin_font = constant.FONT_NAME
        fill_format = SolidFill()
        fill_format.color = constant.COLOR
        dto.fill_format = fill_format

        BaseTest.slides_api.copy_file(
            "TempTests/" + constant.FILE_NAME,
            constant.FOLDER_NAME + "/" + constant.FILE_NAME)
        slide_index = 6
        shape_index = 1
        paragraph_index = 1
        shape_path = "3/shapes"
        response = BaseTest.slides_api.create_subshape_portion(
            constant.FILE_NAME, slide_index, shape_path, shape_index,
            paragraph_index, dto, None, constant.PASSWORD,
            constant.FOLDER_NAME)
        self.assertEqual(dto.text, response.text)
        self.assertEqual(dto.font_bold, response.font_bold)
        self.assertEqual(dto.font_height, response.font_height)
        self.assertEqual(dto.latin_font, response.latin_font)
        self.assertEqual("Solid", response.fill_format.type)
コード例 #5
0
    def test_hyperlink_create_portion(self):
        folder_name = "TempSlidesSDK"
        file_name = "test.pptx"
        BaseTest.slides_api.copy_file("TempTests/" + file_name,
                                      folder_name + "/" + file_name)

        dto = Portion()
        dto.text = "Link text"
        hyperlink = Hyperlink()
        hyperlink.action_type = "JumpLastSlide"
        dto.hyperlink_mouse_over = hyperlink
        updated_portion = BaseTest.slides_api.create_portion(
            file_name, 1, 1, 1, dto, None, "password", folder_name)
        self.assertIsNotNone(updated_portion.hyperlink_mouse_over)
        self.assertEqual(dto.hyperlink_mouse_over.action_type,
                         updated_portion.hyperlink_mouse_over.action_type)
    def test_layout_slide_paragraphs(self):
        folder_name = "TempSlidesSDK"
        file_name = "test.pptx"
        password = "******"
        slide_index = 1
        shape_index = 2
        paragraph_count = 1
        BaseTest.slides_api.copy_file("TempTests/" + file_name,
                                      folder_name + "/" + file_name)

        paragraphs = BaseTest.slides_api.get_special_slide_paragraphs(
            file_name, slide_index, 'layoutSlide', shape_index, password,
            folder_name)
        self.assertEqual(paragraph_count, len(paragraphs.paragraph_links))

        portion = Portion()
        portion.text = "New Paragraph"
        dto = Paragraph()
        dto.alignment = "Right"
        dto.portion_list = [portion]
        paragraph = BaseTest.slides_api.create_special_slide_paragraph(
            file_name, slide_index, 'layoutSlide', shape_index, dto, None,
            password, folder_name)
        self.assertEqual(dto.alignment, paragraph.alignment)
        paragraphs = BaseTest.slides_api.get_special_slide_paragraphs(
            file_name, slide_index, 'layoutSlide', shape_index, password,
            folder_name)
        self.assertEqual(paragraph_count + 1, len(paragraphs.paragraph_links))

        dto = Paragraph()
        dto.alignment = "Center"
        paragraph = BaseTest.slides_api.update_special_slide_paragraph(
            file_name, slide_index, 'layoutSlide', shape_index,
            paragraph_count + 1, dto, password, folder_name)
        self.assertEqual(dto.alignment, paragraph.alignment)
        paragraphs = BaseTest.slides_api.get_special_slide_paragraphs(
            file_name, slide_index, 'layoutSlide', shape_index, password,
            folder_name)
        self.assertEqual(paragraph_count + 1, len(paragraphs.paragraph_links))

        BaseTest.slides_api.delete_special_slide_paragraph(
            file_name, slide_index, 'layoutSlide', shape_index,
            paragraph_count + 1, password, folder_name)
        paragraphs = BaseTest.slides_api.get_special_slide_paragraphs(
            file_name, slide_index, 'layoutSlide', shape_index, password,
            folder_name)
        self.assertEqual(paragraph_count, len(paragraphs.paragraph_links))
コード例 #7
0
    def test_smart_art_text_formatting(self):
        BaseTest.slides_api.copy_file(
            "TempTests/" + constant.FILE_NAME,
            constant.FOLDER_NAME + "/" + constant.FILE_NAME)
        portion = Portion()
        portion.text = "New text"
        portion.font_height = 24
        portion.font_bold = "True"
        portion.spacing = 3
        fill_format = SolidFill()
        fill_format.color = "#FFFFFF00"
        portion.fill_format = fill_format

        target_node_path = "1/nodes/1/nodes"
        slide_index = 7
        response = BaseTest.slides_api.update_subshape_portion(
            constant.FILE_NAME, slide_index, target_node_path, 2, 1, 1,
            portion, constant.PASSWORD, constant.FOLDER_NAME)
        self.assertIsNotNone(response)
        self.assertEqual(response.text, portion.text)
        self.assertEqual(response.font_height, portion.font_height)
        self.assertEqual(response.font_bold, portion.font_bold)
        self.assertEqual(response.spacing, portion.spacing)
        self.assertEqual(response.fill_format.color, portion.fill_format.color)