bito-code-review[bot] commented on code in PR #44337:
URL: https://github.com/apache/superset/pull/44337#discussion_r4037407300


##########
tests/unit_tests/mcp_service/dataset/tool/test_delete_dataset.py:
##########
@@ -0,0 +1,336 @@
+# 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 the delete_dataset MCP tool.
+
+Run through the async MCP Client (not direct calls); auth is mocked via the
+autouse mock_auth fixture, matching the other dataset tool test files.
+"""
+
+from collections.abc import Iterator
+from unittest.mock import Mock, patch
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+
+_RESOLVE = "superset.mcp_service.dataset.tool.delete_dataset.resolve_dataset"
+_COUNT = 
"superset.mcp_service.dataset.tool.delete_dataset._count_affected_objects"
+_RUN = "superset.commands.dataset.delete.DeleteDatasetCommand.run"
+_VALIDATE = "superset.commands.dataset.delete.DeleteDatasetCommand.validate"
+_FLAG = "superset.mcp_service.dataset.tool.delete_dataset.is_feature_enabled"
+
+
[email protected]
+def mcp_server() -> object:
+    """Provide the FastMCP app instance under test."""
+    return mcp
+
+
[email protected](autouse=True)
+def mock_auth() -> Iterator[Mock]:
+    """Authenticate every tool call as a mock admin user."""
+    with patch("superset.mcp_service.auth.get_user_from_request") as 
mock_get_user:
+        # The tool validates the command (lookup + editorship) before counting
+        # dependents; default it to a pass so tests that patch run() alone keep
+        # working. The permission test re-patches it to raise.
+        with patch(_VALIDATE):
+            mock_user = Mock()

Review Comment:
   <!-- Bito Reply -->
   The suggestion to add `: Mock` annotations to the `mock_auth` and 
`_mock_dataset` fixtures is valid and improves code clarity by explicitly 
defining the types of the mock objects, which aligns with the repository's 
coding standards for local variables.
   
   **tests/unit_tests/mcp_service/dataset/tool/test_delete_dataset.py**
   ```
   with patch(_VALIDATE):
               mock_user: Mock = Mock()
   ```



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