Skip to content

Commit

Permalink
test: modify the answer of test case due to the change of ChartLineType
Browse files Browse the repository at this point in the history
  • Loading branch information
Zncl2222 committed Sep 9, 2024
1 parent 8c677d0 commit 773c866
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pyfastexcel/core/chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func TestGetLineStyle(t *testing.T) {
lineData := map[string]interface{}{
"Type": 0.0,
"Type": 1.0,
"Smooth": true,
"Width": 2.0,
}
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestGetSeriesStruct(t *testing.T) {
"Values": "B1:B10",
"Sizes": "C1:C10",
"Fill": map[string]interface{}{"Color": "0000FF"},
"Line": map[string]interface{}{"Type": 0.0, "Width": 1.0},
"Line": map[string]interface{}{"Type": 1.0, "Width": 1.0},
"Marker": map[string]interface{}{"Symbol": "square", "Size": 5.0},
},
}
Expand Down Expand Up @@ -337,7 +337,7 @@ func TestGetChartFill(t *testing.T) {

func TestGetBorderStruct(t *testing.T) {
borderData := map[string]interface{}{
"Type": 0.0,
"Type": 1.0,
"Smooth": true,
"Width": 2.5,
}
Expand Down
24 changes: 22 additions & 2 deletions pyfastexcel/core/pivot_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package core

import (
"fmt"
"math/rand"
"testing"

"github.com/xuri/excelize/v2"
Expand Down Expand Up @@ -45,12 +47,30 @@ func TestGetPivotTableField(t *testing.T) {
func TestCreatePivotTable(t *testing.T) {
// Initialize an excel file
file := excelize.NewFile()
defer func() {
if err := file.Close(); err != nil {
fmt.Println(err)
}
}()
month := []string{"Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
year := []int{2017, 2018, 2019}
types := []string{"Meat", "Dairy", "Beverages", "Produce"}
region := []string{"East", "West", "North", "South"}
file.SetSheetRow("Sheet1", "A1", &[]string{"Month", "Year", "Type", "Sales", "Region"})
for row := 2; row < 32; row++ {
file.SetCellValue("Sheet1", fmt.Sprintf("A%d", row), month[rand.Intn(12)])
file.SetCellValue("Sheet1", fmt.Sprintf("B%d", row), year[rand.Intn(3)])
file.SetCellValue("Sheet1", fmt.Sprintf("C%d", row), types[rand.Intn(4)])
file.SetCellValue("Sheet1", fmt.Sprintf("D%d", row), rand.Intn(5000))
file.SetCellValue("Sheet1", fmt.Sprintf("E%d", row), region[rand.Intn(4)])
}

// Mock pivot table data
pivotData := []interface{}{
map[string]interface{}{
"DataRange": "Sheet1!A1:D10",
"PivotTableRange": "Sheet1!F1:G10",
"DataRange": "Sheet1!A1:E31",
"PivotTableRange": "Sheet1!G2:M34",
"Rows": []interface{}{
map[string]interface{}{
"Name": "RowField",
Expand Down
6 changes: 3 additions & 3 deletions tests/chart_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ def test_chart_series_marker_symbol(symbol, expected_type):
('Solid', 0),
('sOlId', 0),
('SoLId', 0),
(ChartLineType.NONE, 1),
(ChartLineType.Solid, 0),
(ChartLineType.Automatic, 2),
(ChartLineType.NONE, 2),
(ChartLineType.Solid, 1),
(ChartLineType.Automatic, 3),
(1, 1),
(0, 0),
(2, 2),
Expand Down

0 comments on commit 773c866

Please sign in to comment.