def test_math_update(self): folder_name = "TempSlidesSDK" file_name = "test.pptx" BaseTest.slides_api.copy_file("TempTests/" + file_name, folder_name + "/" + file_name) dto = Portion() math_paragraph = MathParagraph() math_block = BlockElement() function_element = FunctionElement() limit_element = LimitElement() text1 = TextElement() text1.value = "lim" limit_element.base = text1 text2 = TextElement() text2.value = "x->0" limit_element.limit = text2 function_element.name = limit_element fraction_element = FractionElement() sinus_element = FunctionElement() text3 = TextElement() text3.value = "sin" sinus_element.name = text3 text4 = TextElement() text4.value = "x" sinus_element.name = text4 fraction_element.numerator = sinus_element text5 = TextElement() text5.value = "x" fraction_element.denominator = text5 function_element.base = fraction_element math_block.math_element_list = [function_element] math_paragraph.math_block_list = [math_block] dto.math_paragraph = math_paragraph portion = BaseTest.slides_api.update_portion(file_name, 2, 3, 1, 1, dto, "password", folder_name) self.assertIsNotNone(portion.math_paragraph) self.assertIsNotNone(portion.math_paragraph.math_block_list) self.assertEqual(1, len(portion.math_paragraph.math_block_list)) self.assertIsNotNone( portion.math_paragraph.math_block_list[0].math_element_list) self.assertEqual( 1, len(portion.math_paragraph.math_block_list[0].math_element_list)) self.assertTrue( isinstance( portion.math_paragraph.math_block_list[0].math_element_list[0], FunctionElement))
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))
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)
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))
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_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_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)