codeant-ai-for-open-source[bot] commented on code in PR #41855: URL: https://github.com/apache/superset/pull/41855#discussion_r3575421682
########## tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py: ########## @@ -0,0 +1,176 @@ +# 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. + +"""Unit tests for list_dashboards ``deleted_state`` trash listing. + +Mirrors the list_charts deleted_state tests: DAO custom filter pass-through, +session-scoped visibility bypass around the DAO call, and ``deleted_at`` +forced into loaded columns and the serialized response. +""" + +from collections.abc import Iterator +from datetime import datetime +from unittest.mock import MagicMock, Mock, patch +from uuid import UUID + +import pytest +from fastmcp import Client + +from superset.mcp_service.app import mcp +from superset.utils import json + +_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list" +_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter" + + [email protected] +def mcp_server() -> object: + return mcp + + [email protected](autouse=True) +def mock_auth() -> Iterator[Mock]: + with patch("superset.mcp_service.auth.get_user_from_request") as mock_get_user: + mock_user = Mock() + mock_user.id = 1 + mock_user.username = "admin" + mock_get_user.return_value = mock_user + yield mock_get_user + + +def _trashed_dashboard_row() -> Mock: + row = Mock( + spec=[ + "id", + "dashboard_title", + "slug", + "published", + "changed_on", + "created_on", + "uuid", + "deleted_at", + ] + ) + row.id = 1 + row.dashboard_title = "Trashed Dashboard" + row.slug = None + row.published = False + row.changed_on = datetime(2026, 6, 1) + row.created_on = datetime(2026, 5, 1) + row.uuid = UUID("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + row.deleted_at = datetime(2026, 7, 1) + return row + + +@patch(_DAO_LIST) [email protected] +async def test_list_dashboards_deleted_state_only_passes_custom_filter( + mock_list: Mock, mcp_server: object +) -> None: + mock_list.return_value = ([], 0) + + async with Client(mcp_server) as client: + await client.call_tool( + "list_dashboards", {"request": {"deleted_state": "only"}} + ) + + kwargs = mock_list.call_args.kwargs Review Comment: **Suggestion:** Add a concrete type annotation for this local variable (for example a typed mapping) when extracting call kwargs. [custom_rule] **Severity Level:** Minor ๐งน <details> <summary><b>Why it matters? โญ </b></summary> This is a newly introduced local variable holding call keyword arguments and can be annotated. Because the file adds new Python code and omits a type hint on an annotatable variable, it matches the type-hint rule. </details> <details> <summary><b>Rule source ๐ </b></summary> .cursor/rules/dev-standard.mdc (line 28) </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=07b7c475b1754536ba6d875dbaa23207&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=07b7c475b1754536ba6d875dbaa23207&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent ๐ค </b></summary> ```mdx This is a comment left during a code review. **Path:** tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py **Line:** 91:91 **Comment:** *Custom Rule: Add a concrete type annotation for this local variable (for example a typed mapping) when extracting call kwargs. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=8e2e8a262a3744c374b44271096b13608e8e018254a4414d743aa6a9b9f09a3b&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=8e2e8a262a3744c374b44271096b13608e8e018254a4414d743aa6a9b9f09a3b&reaction=dislike'>๐</a> -- 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]
