innovark37 commented on code in PR #40885:
URL: https://github.com/apache/superset/pull/40885#discussion_r3601583175
##########
tests/unit_tests/commands/report/execute_test.py:
##########
@@ -1326,6 +1327,197 @@ def
test_get_csv_data_keeps_screenshot_fallback_without_query_context(
post_chart_data.assert_not_called()
+def test_get_url_for_xlsx_report(mocker: MockerFixture) -> None:
+ """XLSX reports should request post-processed chart data."""
+ report_schedule = create_report_schedule(mocker)
+ report_schedule.chart_id = 1
+ report_schedule.force_screenshot = False
+ report_state = BaseReportState(
+ report_schedule, "January 1, 2021", "execution_id_example"
+ )
+ get_url_path = mocker.patch(
+ "superset.commands.report.execute.get_url_path",
+ return_value="/api/v1/chart/1/data/xlsx",
+ )
+
+ url = report_state._get_url(result_format=ChartDataResultFormat.XLSX)
+
+ assert url == "/api/v1/chart/1/data/xlsx"
+ get_url_path.assert_called_once_with(
+ "ChartDataRestApi.get_data",
+ pk=1,
+ format=ChartDataResultFormat.XLSX.value,
+ type=ChartDataResultType.POST_PROCESSED.value,
+ force="false",
+ )
+
+
+def test_get_chart_data_rejects_non_table_format(mocker: MockerFixture) ->
None:
+ """Chart data retrieval should reject formats it cannot download."""
+ report_state = BaseReportState(
+ create_report_schedule(mocker),
+ "January 1, 2021",
+ "execution_id_example",
+ )
+ get_url = mocker.patch.object(report_state, "_get_url")
+
+ with pytest.raises(
+ ReportScheduleExecuteUnexpectedError,
+ match="Unsupported chart data result format: json",
+ ):
+ report_state._get_chart_data(ChartDataResultFormat.JSON)
Review Comment:
Good catch. `_get_chart_data` no longer exists after the merge, so I updated
the test to call `_get_data(...)`. I also restored the table-like format guard
in `_get_data`, so unsupported formats like JSON still raise
`ReportScheduleExecuteUnexpectedError` as intended.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]