mirror of
https://github.com/apache/superset.git
synced 2026-04-13 13:18:25 +00:00
fix: Ensure the reporting framework handles charts with no data (#23585)
This commit is contained in:
@@ -18,9 +18,9 @@
|
||||
import json
|
||||
|
||||
import pandas as pd
|
||||
import pytest
|
||||
from flask_babel import lazy_gettext as _
|
||||
from numpy import True_
|
||||
from pytest import raises
|
||||
from sqlalchemy.orm.session import Session
|
||||
|
||||
from superset.charts.post_processing import apply_post_process, pivot_df, table
|
||||
@@ -1389,7 +1389,7 @@ def test_apply_post_process_without_result_format():
|
||||
result = {"queries": [{"result_format": "foo"}]}
|
||||
form_data = {"viz_type": "pivot_table"}
|
||||
|
||||
with raises(Exception) as ex:
|
||||
with pytest.raises(Exception) as ex:
|
||||
apply_post_process(result, form_data)
|
||||
|
||||
assert ex.match("Result format foo not supported") == True
|
||||
@@ -1659,12 +1659,13 @@ def test_apply_post_process_csv_format_empty_string():
|
||||
}
|
||||
|
||||
|
||||
def test_apply_post_process_csv_format_no_data():
|
||||
@pytest.mark.parametrize("data", [None, "", "\n"])
|
||||
def test_apply_post_process_csv_format_no_data(data):
|
||||
"""
|
||||
It should be able to process csv results with no data
|
||||
"""
|
||||
|
||||
result = {"queries": [{"result_format": ChartDataResultFormat.CSV, "data": None}]}
|
||||
result = {"queries": [{"result_format": ChartDataResultFormat.CSV, "data": data}]}
|
||||
form_data = {
|
||||
"datasource": "19__table",
|
||||
"viz_type": "pivot_table_v2",
|
||||
@@ -1726,7 +1727,7 @@ def test_apply_post_process_csv_format_no_data():
|
||||
}
|
||||
|
||||
assert apply_post_process(result, form_data) == {
|
||||
"queries": [{"result_format": ChartDataResultFormat.CSV, "data": None}]
|
||||
"queries": [{"result_format": ChartDataResultFormat.CSV, "data": data}]
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user