bito-code-review[bot] commented on code in PR #43176:
URL: https://github.com/apache/superset/pull/43176#discussion_r4178988021
##########
tests/unit_tests/mcp_service/chart/tool/test_get_chart_sql.py:
##########
@@ -228,6 +231,133 @@ def test_null_chart_metadata(self):
assert output.datasource_name is None
+class TestChartSqlJinjaContext:
+ """SQL generation must expose the same Jinja inputs as chart data
execution."""
+
+ def _command_observing_jinja(self, observed: dict[str, bool]) -> type:
+ from tests.unit_tests.charts.data.form_data_test import (
+ assert_request_dependent_jinja_macros,
+ )
+
+ class ChartDataCommand:
+ def __init__(self, query_context: object) -> None:
+ self.query_context = query_context
+
+ def validate(self) -> None:
+ pass
+
+ def run(self) -> dict[str, Any]:
+ assert_request_dependent_jinja_macros()
+ observed["ran"] = True
+ return {"queries": [{"query": "SELECT 1", "language": "sql"}]}
+
+ return ChartDataCommand
+
+ def test_sql_from_form_data_exposes_jinja_context(
+ self,
+ monkeypatch: pytest.MonkeyPatch,
+ ) -> None:
+ """The form_data SQL path publishes filters, time_range, and
url_params."""
+ from flask import current_app
+
+ from superset.common.query_object import QueryObject
+
+ get_data_command_module = importlib.import_module(
+ "superset.commands.chart.data.get_data_command"
+ )
+ query = QueryObject(
+ filters=[{"col": "region", "op": "IN", "val": ["North"]}],
+ time_range="Last week",
+ )
+ query_context = SimpleNamespace(
+ queries=[query],
+ form_data={"url_params": {"tenant": "acme"}},
+ datasource=SimpleNamespace(id=7, type="table"),
+ )
Review Comment:
<!-- Bito Reply -->
The reviewer's suggestion to annotate local variables in the test file is a
valid request to improve code maintainability and adhere to project standards.
You should apply these type annotations to `get_data_command_module`, `query`,
`query_context`, `chart`, and `result` as requested to ensure consistency with
the project's typing requirements.
--
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]