rusackas commented on code in PR #42193:
URL: https://github.com/apache/superset/pull/42193#discussion_r3624113761


##########
tests/unit_tests/charts/test_chart_data_api.py:
##########
@@ -236,3 +236,130 @@ def test_extract_export_filename_preserves_normal_name() 
-> None:
 def test_extract_export_filename_all_special_falls_back_to_none() -> None:
     """A name with no usable characters becomes None (generated downstream)."""
     assert _extract_filename("***") is None
+
+
+def test_send_chart_response_uses_chart_name_for_csv_filename() -> None:
+    """
+    Regression test: the non-streaming CSV export branch of
+    _send_chart_response must include the chart's name in the
+    Content-Disposition header, not just a bare timestamp, mirroring the
+    streaming CSV export path.
+    """
+    from superset.charts.data.api import ChartDataRestApi
+    from superset.common.chart_data import ChartDataResultFormat, 
ChartDataResultType
+
+    query_context = MagicMock()
+    query_context.result_type = ChartDataResultType.FULL
+    query_context.result_format = ChartDataResultFormat.CSV
+
+    result = {
+        "query_context": query_context,
+        "queries": [{"data": "col_a,col_b\n1,2\n"}],
+    }
+
+    api = ChartDataRestApi()
+    with (
+        patch("superset.charts.data.api.security_manager") as 
mock_security_manager,
+        patch("superset.charts.data.api.is_feature_enabled", 
return_value=False),
+    ):

Review Comment:
   These pass as-is... the unit test conftest has an autouse `app_context` 
fixture that wraps every test in `app.app_context()`, so there's always an app 
context here. Just ran the file locally and all 13 pass. Same goes for the 
other three comments below, so resolving those too.



-- 
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]

Reply via email to