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


##########
tests/unit_tests/mcp_service/chart/test_big_number_chart.py:
##########
@@ -177,6 +177,16 @@ def test_compare_lag_requires_trendline(self) -> None:
                 compare_lag=1,
             )
 
+    def test_aggregation_requires_trendline(self) -> None:

Review Comment:
   Fixed — docstring added.



##########
tests/unit_tests/mcp_service/chart/test_big_number_chart.py:
##########
@@ -188,6 +198,33 @@ def test_with_filters(self) -> None:
         assert config.filters is not None
         assert len(config.filters) == 1
 
+    def test_with_aggregation_sum(self) -> None:

Review Comment:
   Fixed — docstring added.



##########
tests/unit_tests/mcp_service/chart/test_big_number_chart.py:
##########
@@ -188,6 +198,33 @@ def test_with_filters(self) -> None:
         assert config.filters is not None
         assert len(config.filters) == 1
 
+    def test_with_aggregation_sum(self) -> None:
+        config = BigNumberChartConfig(
+            chart_type="big_number",
+            metric=ColumnRef(name="revenue", aggregate="SUM"),
+            temporal_column="ds",
+            show_trendline=True,
+            aggregation="sum",
+        )
+        assert config.aggregation == "sum"
+
+    def test_with_aggregation_last_value(self) -> None:

Review Comment:
   Fixed — docstring added.



##########
tests/unit_tests/mcp_service/chart/test_big_number_chart.py:
##########
@@ -188,6 +198,33 @@ def test_with_filters(self) -> None:
         assert config.filters is not None
         assert len(config.filters) == 1
 
+    def test_with_aggregation_sum(self) -> None:
+        config = BigNumberChartConfig(
+            chart_type="big_number",
+            metric=ColumnRef(name="revenue", aggregate="SUM"),
+            temporal_column="ds",
+            show_trendline=True,
+            aggregation="sum",
+        )
+        assert config.aggregation == "sum"
+
+    def test_with_aggregation_last_value(self) -> None:
+        config = BigNumberChartConfig(
+            chart_type="big_number",
+            metric=ColumnRef(name="revenue", aggregate="SUM"),
+            temporal_column="ds",
+            show_trendline=True,
+            aggregation="LAST_VALUE",
+        )
+        assert config.aggregation == "LAST_VALUE"
+
+    def test_aggregation_defaults_to_none(self) -> None:

Review Comment:
   Fixed — docstring added.



##########
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_allowed_for_big_number_total(self) -> None:

Review Comment:
   Fixed — docstring added.



##########
tests/unit_tests/mcp_service/chart/test_big_number_chart.py:
##########
@@ -307,6 +348,49 @@ 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"

Review Comment:
   Fixed — docstring added.



##########
tests/unit_tests/mcp_service/chart/test_big_number_chart.py:
##########
@@ -307,6 +348,49 @@ 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"

Review Comment:
   Fixed — docstring added.



##########
tests/unit_tests/mcp_service/chart/test_big_number_chart.py:
##########
@@ -307,6 +348,49 @@ 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

Review Comment:
   Fixed — docstring added.



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