aminghadersohi commented on code in PR #41611:
URL: https://github.com/apache/superset/pull/41611#discussion_r3538087285


##########
tests/unit_tests/mcp_service/utils/test_response_utils.py:
##########
@@ -0,0 +1,109 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Unit tests for MCP service response utilities.
+"""
+
+from typing import Any
+
+from superset.mcp_service.utils.response_utils import (
+    format_data_columns,
+    STATS_ROW_CAP,
+)
+
+
+class TestFormatDataColumns:
+    """Test format_data_columns function."""
+
+    def test_infers_numeric_type(self) -> None:
+        """Should infer numeric data_type from sample values."""
+        data: list[dict[str, Any]] = [
+            {"revenue": 100},
+            {"revenue": 200},
+            {"revenue": None},
+        ]
+        columns = format_data_columns(data, ["revenue"])
+
+        assert len(columns) == 1
+        assert columns[0].name == "revenue"
+        assert columns[0].data_type == "numeric"
+        assert columns[0].null_count == 1
+        assert columns[0].unique_count == 2
+
+    def test_infers_boolean_type(self) -> None:
+        """Should infer boolean data_type from sample values."""
+        data = [{"is_active": True}, {"is_active": False}]
+        columns = format_data_columns(data, ["is_active"])
+
+        assert columns[0].data_type == "boolean"
+
+    def test_infers_string_type_by_default(self) -> None:
+        """Should default to string data_type when values aren't 
numeric/boolean."""
+        data = [{"region": "west"}, {"region": "east"}]

Review Comment:
   Fixed in 7e91cf2db9bb35980368241d5061a244127a64d6: added an explicit 
`list[dict[str, Any]]` annotation to the test's `data` variable.



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