Copilot commented on code in PR #41920:
URL: https://github.com/apache/superset/pull/41920#discussion_r3556521663
##########
tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py:
##########
@@ -468,6 +468,37 @@ async def test_invalid_css_is_rejected(
assert "css is invalid" in (payload.get("error") or "").lower()
mock_session.commit.assert_not_called()
+ @patch("superset.daos.dashboard.DashboardDAO.get_by_id_or_slug")
+ @patch("superset.extensions.db.session")
+ @pytest.mark.asyncio
+ async def test_ctx_info_is_awaited(
+ self, mock_session: Mock, mock_get: Mock, mcp_server: object
+ ) -> None:
+ """``ctx.info`` calls must be awaited — ``Context.info`` is an
+ async method, so an unawaited call silently drops the log line
+ instead of raising. Assert it was actually invoked (and thus
+ awaited, since ``AsyncMock`` records only real awaits) rather
+ than just checking the response succeeded."""
+ dash = _mock_dashboard(id=42)
+ mock_get.return_value = dash
+
+ with patch.object(Context, "info", new_callable=AsyncMock) as
mock_ctx_info:
+ async with Client(mcp_server) as client:
+ await client.call_tool(
+ "update_dashboard",
+ {
+ "request": {
+ "identifier": 42,
+ "dashboard_title": "Renamed",
+ }
+ },
+ )
+
+ assert mock_ctx_info.await_count == 2
+ first_call, second_call = mock_ctx_info.await_args_list
+ assert "Updating dashboard" in first_call.args[0]
+ assert "updated" in second_call.args[0]
Review Comment:
The new test is overly strict about the exact number/order of `ctx.info`
awaits (`await_count == 2` and unpacking the first two awaits). This will make
the test fail if `update_dashboard` legitimately adds additional
`ctx.info(...)` log lines in the future, even though the core contract (that
the important log lines are awaited) still holds. Consider asserting the
expected messages are present among awaited calls, while allowing extra awaits.
--
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]