bito-code-review[bot] commented on code in PR #43572:
URL: https://github.com/apache/superset/pull/43572#discussion_r3872804691


##########
tests/unit_tests/mcp_service/chart/test_bubble_chart.py:
##########
@@ -0,0 +1,158 @@
+# 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.
+
+"""Tests for the bubble chart type plugin.
+
+Schema validation, form_data mapping (matching the frontend Bubble buildQuery
+contract for viz_type ``bubble_v2`` — an ``entity`` dimension plus three
+separate metric keys ``x``/``y``/``size`` and an optional ``series``), and
+registry integration.
+"""
+
+import pytest
+from pydantic import TypeAdapter, ValidationError
+
+from superset.mcp_service.chart.chart_utils import map_bubble_config
+from superset.mcp_service.chart.schemas import BubbleChartConfig, ChartConfig
+
+
+def _base(**overrides):
+    cfg = {
+        "chart_type": "bubble_v2",
+        "entity": {"name": "country"},
+        "x": {"name": "gdp", "aggregate": "AVG"},
+        "y": {"name": "life_expectancy", "aggregate": "AVG"},
+        "size": {"name": "population", "aggregate": "SUM"},
+    }
+    cfg.update(overrides)
+    return cfg
+
+
+class TestBubbleChartConfigSchema:
+    """BubbleChartConfig schema validation."""
+
+    def test_basic_bubble_config(self) -> None:
+        config = BubbleChartConfig(**_base())
+        assert config.entity.name == "country"
+        assert config.x.name == "gdp"
+        assert config.series is None  # series grouping is optional
+        assert config.row_limit == 10000  # shared control default
+
+    @pytest.mark.parametrize("missing", ["entity", "x", "y", "size"])
+    def test_bubble_missing_required(self, missing: str) -> None:
+        cfg = _base()
+        del cfg[missing]
+        with pytest.raises(ValidationError):
+            BubbleChartConfig(**cfg)
+
+    def test_bubble_rejects_extra_fields(self) -> None:
+        with pytest.raises(ValidationError):
+            BubbleChartConfig(**_base(bogus=1))

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Extra-field test contradicts ignore policy</b></div>
   <div id="fix">
   
   `BubbleChartConfig` declares `model_config = ConfigDict(extra="ignore")` 
(schemas.py:1057), so passing `bogus=1` is silently dropped instead of raising 
`ValidationError`. This test will fail at runtime. Either remove the test or 
switch the schema to `extra="forbid"`.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #0f8840</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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