EnxDev commented on code in PR #44218:
URL: https://github.com/apache/superset/pull/44218#discussion_r4013280683
##########
tests/unit_tests/tasks/test_export_dashboard_excel.py:
##########
@@ -839,3 +840,43 @@ def test_inflight_lock_released_on_failure(mocks:
dict[str, Any]) -> None:
"excel_export", {"user_id": 2, "dashboard_id": 1}
)
mocks["ReleaseDistributedLock"].return_value.run.assert_called_once_with()
+
+
[email protected]("query_mode", ["aggregate", "raw"])
+def test_rebuilt_paginated_table_executes_full_limit(
+ mocks: dict[str, Any], query_mode: str
+) -> None:
+ """The real export path sends one full-limit query to ChartDataCommand."""
+ form_data = {
+ "groupby": ["country"],
+ "all_columns": ["country"],
+ "metrics": ["count"],
+ "query_mode": query_mode,
+ "server_pagination": True,
+ "server_page_length": 10,
+ "row_limit": 1000,
+ "result_format": "json",
+ "result_type": "full",
+ }
+ chart = _rebuildable_chart(form_data=form_data)
+ mocks["get_charts_in_layout_order"].return_value = [chart]
+ mocks["ChartDataCommand"].return_value.run.return_value = {
+ "queries": [{"colnames": ["country"], "data": [{"country": "US"}]}]
+ }
+
+ with _builder_hook(None):
+ _run()
+
+ payload =
mocks["ChartDataQueryContextSchema"].return_value.load.call_args.args[0]
+ assert payload["result_format"] == ChartDataResultFormat.JSON
+ assert payload["result_type"] == ChartDataResultType.FULL
+ assert len(payload["queries"]) == 1
+ query = payload["queries"][0]
+ assert query["row_limit"] == 1000
+ assert query.get("row_offset", 0) == 0
Review Comment:
Small test suggestion: could we seed a nonzero `row_offset` in the input
form data, for example `20`? With no offset in the input, this assertion also
passes if a future implementation simply preserves the incoming offset.
Starting with a nonzero value would let this check catch an export that
accidentally skips the first rows.
--
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]