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


##########
tests/unit_tests/commands/dataset/restore_test.py:
##########
@@ -0,0 +1,95 @@
+# 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 RestoreDatasetCommand."""
+
+from __future__ import annotations
+
+from datetime import datetime
+from unittest.mock import MagicMock, patch
+
+import pytest
+
+
+def test_restore_dataset_clears_deleted_at(app_context: None) -> None:
+    """RestoreDatasetCommand.run() restores a soft-deleted dataset."""
+    from superset.commands.dataset.restore import RestoreDatasetCommand
+
+    dataset = MagicMock()
+    dataset.deleted_at = datetime(2026, 1, 1)
+    dataset.id = 1
+
+    with (
+        patch(
+            "superset.daos.dataset.DatasetDAO.find_by_id", return_value=dataset
+        ) as mock_find,
+        patch("superset.commands.restore.security_manager") as mock_sec,
+    ):
+        mock_sec.raise_for_ownership.return_value = None
+
+        cmd = RestoreDatasetCommand("1")
+        cmd.run()

Review Comment:
   **NIT — Use a UUID string, not an integer-like string**
   
   `RestoreDatasetCommand("1")` — `BaseRestoreCommand.__init__` accepts 
`model_uuid: str` for a UUID-column lookup. Passing `"1"` would fail at the DAO 
layer in production (UUID validation). This test passes only because 
`DatasetDAO.find_by_id` is mocked. Use a realistic UUID to document the 
expected argument type:
   
   ```python
   import uuid
   FAKE_UUID = str(uuid.uuid4())
   cmd = RestoreDatasetCommand(FAKE_UUID)
   ```
   
   Same applies at lines 57 (`"999"`), 71, and 94.



##########
tests/integration_tests/datasets/api_tests.py:
##########
@@ -152,8 +151,11 @@ def insert_database(self, name: str, allow_multi_catalog: 
bool = False) -> Datab
         return db_connection
 
     def get_fixture_datasets(self) -> list[SqlaTable]:
+        from superset.constants import SKIP_VISIBILITY_FILTER_CLASSES

Review Comment:
   **NIT — Move `SKIP_VISIBILITY_FILTER_CLASSES` to module-level imports**
   
   This import is inside the `get_fixture_datasets()` method body. The same 
symbol is imported inline again in the `create_datasets` fixture teardown 
(around line 229) and in `test_delete_dataset_item` (around line 1983). Move 
all three to the module-level import block for clarity and to avoid repeated 
import overhead in the test hot path.



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