betodealmeida commented on code in PR #35481:
URL: https://github.com/apache/superset/pull/35481#discussion_r2402811948


##########
tests/unit_tests/charts/test_client_processing.py:
##########
@@ -2653,3 +2653,172 @@ def test_pivot_multi_level_index():
 | ('Total (Sum)', '', '')           |            210 |            105 |        
      0 |
     """.strip()
     )
+
+
+def test_apply_client_processing_csv_format_preserves_na_strings():
+    """
+    Test that apply_client_processing preserves "NA" strings
+    when REPORTS_CSV_NA_NAMES is set to empty list.
+    This ensures that scheduled reports can be configured to
+    preserve strings like "NA" as literal values.
+    """
+    from unittest.mock import patch
+
+    # CSV data with "NA" string that should be preserved
+    csv_data = "first_name,last_name\nJeff,Smith\nAlice,NA"
+
+    result = {
+        "queries": [
+            {
+                "result_format": ChartDataResultFormat.CSV,
+                "data": csv_data,
+            }
+        ]
+    }
+
+    form_data = {
+        "datasource": "1__table",
+        "viz_type": "table",
+        "slice_id": 1,
+        "url_params": {},
+        "metrics": [],
+        "groupby": [],
+        "columns": ["first_name", "last_name"],
+        "extra_form_data": {},
+        "force": False,
+        "result_format": "csv",
+        "result_type": "results",
+    }
+
+    # Test with REPORTS_CSV_NA_NAMES set to empty list (disable NA conversion)
+    with patch(
+        "superset.charts.client_processing.current_app.config.get"
+    ) as mock_config:
+        # Only mock the specific config key we're testing
+        def mock_get(key, default=None):
+            if key == "REPORTS_CSV_NA_NAMES":
+                return []  # Empty list disables NA conversion
+            return default

Review Comment:
   You can use the `with_config` decorator here and other tests, eg:
   
   ```python
   @with_config({"REPORTS_CSV_NA_NAMES": []})
   def test_something(...):
       ...
   ```



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