From b726a8769a665a20ae03a18549b30d805133d841 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sun, 18 Oct 2020 11:20:04 +0530 Subject: [PATCH] test: Fix query report test --- frappe/tests/test_query_report.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frappe/tests/test_query_report.py b/frappe/tests/test_query_report.py index 8e62e03064..eaf4dc7070 100644 --- a/frappe/tests/test_query_report.py +++ b/frappe/tests/test_query_report.py @@ -23,7 +23,11 @@ class TestQueryReport(unittest.TestCase): # Create mock data data = frappe._dict() - data.columns = ["column_a", "column_b", "column_c"] + data.columns = [ + {"label": "Column A", "fieldname": "column_a"}, + {"label": "Column B", "fieldname": "column_b", "width": 150}, + {"label": "Column C", "fieldname": "column_c", "width": 100} + ] data.result = [ [1.0, 3.0, 5.5], {"column_a": 22.1, "column_b": 21.8, "column_c": 30.2}, @@ -35,10 +39,12 @@ class TestQueryReport(unittest.TestCase): visible_idx = [0, 2, 3] # Build the result - xlsx_data = build_xlsx_data(columns, data, visible_idx, include_indentation=0) + xlsx_data, column_widths = build_xlsx_data(columns, data, visible_idx, include_indentation=0) self.assertEqual(type(xlsx_data), list) self.assertEqual(len(xlsx_data), 4) # columns + data + # column widths are divided by 10 to match the scale that is supported by openpyxl + self.assertListEqual(column_widths, [0, 15, 10]) for row in xlsx_data: self.assertEqual(type(row), list)