Copilot commented on code in PR #40775:
URL: https://github.com/apache/superset/pull/40775#discussion_r3382623815
##########
tests/unit_tests/mcp_service/chart/test_big_number_chart.py:
##########
@@ -307,6 +344,48 @@ def test_no_trendline_fields_for_total(self) -> None:
assert "time_grain_sqla" not in form_data
assert "start_y_axis_at_zero" not in form_data
+ def test_with_aggregation_sum(self) -> None:
+ config = BigNumberChartConfig(
+ chart_type="big_number",
+ metric=ColumnRef(name="revenue", aggregate="SUM"),
+ temporal_column="order_date",
+ show_trendline=True,
+ aggregation="sum",
+ )
+ form_data = map_big_number_config(config)
+ assert form_data["aggregation"] == "sum"
+
+ def test_with_aggregation_last_value(self) -> None:
+ config = BigNumberChartConfig(
+ chart_type="big_number",
+ metric=ColumnRef(name="revenue", aggregate="SUM"),
+ temporal_column="order_date",
+ show_trendline=True,
+ aggregation="LAST_VALUE",
+ )
+ form_data = map_big_number_config(config)
+ assert form_data["aggregation"] == "LAST_VALUE"
+
+ def test_aggregation_absent_when_not_set(self) -> None:
+ config = BigNumberChartConfig(
+ chart_type="big_number",
+ metric=ColumnRef(name="revenue", aggregate="SUM"),
+ temporal_column="order_date",
+ show_trendline=True,
+ )
+ form_data = map_big_number_config(config)
+ assert "aggregation" not in form_data
+
+ def test_aggregation_not_set_for_big_number_total(self) -> None:
+ config = BigNumberChartConfig(
+ chart_type="big_number",
+ metric=ColumnRef(name="revenue", aggregate="SUM"),
+ aggregation="sum",
+ )
+ form_data = map_big_number_config(config)
+ assert form_data["viz_type"] == "big_number_total"
+ assert "aggregation" not in form_data
+
Review Comment:
This test constructs `BigNumberChartConfig` with `aggregation` but without
`show_trendline=True`. The updated schema validator now raises a
`ValidationError` in that case, so this test will fail before
`map_big_number_config` runs. Adjust the test to assert the validation error
(or remove it if redundant).
--
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]