コード例 #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)
コード例 #2
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))
    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))