def test_chart_sunburst(self): folder_name = "TempSlidesSDK" file_name = "test.pptx" BaseTest.slides_api.copy_file("TempTests/" + file_name, folder_name + "/" + file_name) chart = Chart() chart.chart_type = 'Sunburst' chart.width = 400 chart.height = 300 series1 = OneValueSeries() series1.name = "Series1" point1 = OneValueChartDataPoint() point1.value = 40 point2 = OneValueChartDataPoint() point2.value = 50 point3 = OneValueChartDataPoint() point3.value = 70 point4 = OneValueChartDataPoint() point4.value = 60 series1.data_points = [point1, point2, point3, point4] chart.series = [series1] category1 = ChartCategory() category1.value = "Leaf1" category1.level = 3 category1.parent_categories = ["Branch1", "Stem1"] category2 = ChartCategory() category2.value = "Leaf2" category2.level = 3 category2.parent_categories = ["Branch1", "Stem1"] category3 = ChartCategory() category3.value = "Branch2" category3.level = 2 category3.parent_categories = ["Stem1"] category4 = ChartCategory() category4.value = "Stem2" category4.level = 1 chart.categories = [category1, category2, category3, category4] result = BaseTest.slides_api.create_shape(file_name, 3, chart, None, None, "password", folder_name) self.assertEqual(1, len(result.series)) self.assertEqual(4, len(result.categories))
def test_chart_series_update(self): folder_name = "TempSlidesSDK" file_name = "test.pptx" BaseTest.slides_api.copy_file("TempTests/" + file_name, folder_name + "/" + file_name) series = OneValueSeries() series.name = "Series3" point1 = OneValueChartDataPoint() point1.value = 40 point2 = OneValueChartDataPoint() point2.value = 50 point3 = OneValueChartDataPoint() point3.value = 14 point4 = OneValueChartDataPoint() point4.value = 70 series.data_points = [point1, point2, point3, point4] result = BaseTest.slides_api.update_chart_series( file_name, 3, 1, 2, series, "password", folder_name) self.assertEqual(3, len(result.series)) self.assertEqual(4, len(result.categories))
def test_chart_create(self): folder_name = "TempSlidesSDK" file_name = "test.pptx" BaseTest.slides_api.copy_file("TempTests/" + file_name, folder_name + "/" + file_name) chart = Chart() chart.chart_type = 'ClusteredColumn' chart.width = 400 chart.height = 300 series1 = OneValueSeries() series1.name = "Series1" point11 = OneValueChartDataPoint() point11.value = 40 point12 = OneValueChartDataPoint() point12.value = 50 point13 = OneValueChartDataPoint() point13.value = 70 series1.data_points = [point11, point12, point13] series2 = OneValueSeries() series2.name = "Series2" point21 = OneValueChartDataPoint() point21.value = 55 point22 = OneValueChartDataPoint() point22.value = 35 point23 = OneValueChartDataPoint() point23.value = 90 series2.data_points = [point21, point22, point23] chart.series = [series1, series2] category1 = ChartCategory() category1.value = "Category1" category2 = ChartCategory() category2.value = "Category2" category3 = ChartCategory() category3.value = "Category3" chart.categories = [category1, category2, category3] result = BaseTest.slides_api.create_shape(file_name, 3, chart, None, None, "password", folder_name) self.assertEqual(2, len(result.series)) self.assertEqual(3, len(result.categories))
def test_nullable_properties(self): folder_name = "TempSlidesSDK" file_name = "test.pptx" password = "******" min1 = 44.3 min2 = 12 max1 = 104.3 max2 = 87 self.initialize('no_method', 'no_property', None) BaseTest.slides_api.copy_file("TempTests/" + file_name, folder_name + "/" + file_name) test_dto = Chart() test_dto.chart_type = "Line" test_dto.width = 400 test_dto.height = 300 test_title = ChartTitle() test_title.has_title = True test_title.text = "MyTitle" test_dto.title = test_title test_series = OneValueSeries() test_series.type = "ClusteredColumn" test_series.data_point_type = "OneValue" test_series.name = "Series1" test_point1 = OneValueChartDataPoint() test_point1.value = 40 test_point2 = OneValueChartDataPoint() test_point2.value = 50 test_series.data_points = [test_point1, test_point2] test_dto.series = ([test_series]) test_axes = Axes() test_axis = Axis() test_axis.is_automatic_min_value = False test_axis.min_value = min1 test_axis.is_automatic_max_value = False test_axis.max_value = max1 test_axes.horizontal_axis = test_axis test_dto.axes = test_axes result = BaseTest.slides_api.create_shape(file_name, 1, test_dto, None, None, password, folder_name) result = BaseTest.slides_api.get_shape(file_name, 1, 5, password, folder_name) self.assertEqual(min1, result.axes.horizontal_axis.min_value) self.assertEqual(max1, result.axes.horizontal_axis.max_value) test_dto = Chart() test_axes = Axes() test_axis = Axis() test_axis.min_value = min2 test_axes.horizontal_axis = test_axis test_dto.axes = test_axes result = BaseTest.slides_api.update_shape(file_name, 1, 5, test_dto, password, folder_name) result = BaseTest.slides_api.get_shape(file_name, 1, 5, password, folder_name) self.assertEqual(min2, result.axes.horizontal_axis.min_value) self.assertEqual(max1, result.axes.horizontal_axis.max_value) test_axis = Axis() test_axis.max_value = max2 test_axes.horizontal_axis = test_axis test_dto.axes = test_axes result = BaseTest.slides_api.update_shape(file_name, 1, 5, test_dto, password, folder_name) result = BaseTest.slides_api.get_shape(file_name, 1, 5, password, folder_name) self.assertEqual(min2, result.axes.horizontal_axis.min_value) self.assertEqual(max2, result.axes.horizontal_axis.max_value)
def test_multilevel_category_axis(self): folder_name = "TempSlidesSDK" file_name = "test.pptx" BaseTest.slides_api.copy_file("TempTests/" + file_name, folder_name + "/" + file_name) chart = Chart() chart.chart_type = "ClusteredColumn" chart.x = 100 chart.y = 100 chart.width = 500 chart.height = 400 series = OneValueSeries() series.type = "ClusteredColumn" point1 = OneValueChartDataPoint() point1.value = 1 point2 = OneValueChartDataPoint() point2.value = 2 point3 = OneValueChartDataPoint() point3.value = 3 point4 = OneValueChartDataPoint() point4.value = 4 point5 = OneValueChartDataPoint() point5.value = 5 point6 = OneValueChartDataPoint() point6.value = 6 point7 = OneValueChartDataPoint() point7.value = 7 point8 = OneValueChartDataPoint() point8.value = 8 series.data_points = [ point1, point2, point3, point4, point5, point6, point7, point8 ] category1 = ChartCategory() category1.value = "Category 1" category1.parent_categories = ["Sub-category 1", "Root 1"] category2 = ChartCategory() category2.value = "Category 2" category3 = ChartCategory() category3.parent_categories = ["Sub-category 2"] category4 = ChartCategory() category4.value = "Category 4" category5 = ChartCategory() category5.value = "Category 5" category5.parent_categories = ["Sub-category 3", "Root 2"] category6 = ChartCategory() category6.value = "Category 6" category7 = ChartCategory() category7.value = "Category 7" category7.parent_categories = ["Sub-category 4"] category8 = ChartCategory() category8.value = "Category 8" slide_index = 3 chart.categories = [ category1, category2, category3, category4, category5, category6, category7, category8 ] result = BaseTest.slides_api.create_shape(file_name, slide_index, chart, None, None, "password", folder_name) self.assertEqual("ClusteredColumn", result.chart_type)