This is an automated email from the ASF dual-hosted git repository. aminghadersohi pushed a commit to branch oss-40340 in repository https://gitbox.apache.org/repos/asf/superset.git
commit 576d40111b82fcee57a20afdef983399c6af2b85 Author: Amin Ghadersohi <[email protected]> AuthorDate: Tue May 26 19:17:05 2026 +0000 test(mcp): fix patch paths in test_create_dataset — CreateDatasetCommand is a lazy import CreateDatasetCommand is imported inside the function body, so patching at superset.mcp_service.dataset.tool.create_dataset.CreateDatasetCommand fails with AttributeError. Patch at the source module instead. Also fix data["schema_name"] assertions: DatasetInfo.model_serializer renames the field to "schema" in the serialized output. --- .../mcp_service/dataset/tool/test_create_dataset.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/unit_tests/mcp_service/dataset/tool/test_create_dataset.py b/tests/unit_tests/mcp_service/dataset/tool/test_create_dataset.py index ae062f92346..ba2898eb660 100644 --- a/tests/unit_tests/mcp_service/dataset/tool/test_create_dataset.py +++ b/tests/unit_tests/mcp_service/dataset/tool/test_create_dataset.py @@ -87,7 +87,7 @@ def mock_auth(): class TestCreateDataset: """Tests for the create_dataset MCP tool.""" - @patch("superset.mcp_service.dataset.tool.create_dataset.CreateDatasetCommand") + @patch("superset.commands.dataset.create.CreateDatasetCommand") @pytest.mark.asyncio async def test_create_dataset_success(self, mock_command_class, mcp_server): """Happy path: tool creates dataset and returns DatasetInfo.""" @@ -112,7 +112,7 @@ class TestCreateDataset: data = json.loads(result.content[0].text) assert data["id"] == 42 assert data["table_name"] == "orders" - assert data["schema_name"] == "public" + assert data["schema"] == "public" # Verify the command was called with the right properties call_kwargs = mock_command_class.call_args[0][0] @@ -121,7 +121,7 @@ class TestCreateDataset: assert call_kwargs["table_name"] == "orders" assert "owners" not in call_kwargs - @patch("superset.mcp_service.dataset.tool.create_dataset.CreateDatasetCommand") + @patch("superset.commands.dataset.create.CreateDatasetCommand") @pytest.mark.asyncio async def test_create_dataset_with_owners(self, mock_command_class, mcp_server): """Owners list is forwarded to the command when supplied.""" @@ -149,7 +149,7 @@ class TestCreateDataset: call_kwargs = mock_command_class.call_args[0][0] assert call_kwargs["owners"] == [5, 10] - @patch("superset.mcp_service.dataset.tool.create_dataset.CreateDatasetCommand") + @patch("superset.commands.dataset.create.CreateDatasetCommand") @pytest.mark.asyncio async def test_create_dataset_already_exists(self, mock_command_class, mcp_server): """Returns DatasetError when a dataset for the table already exists.""" @@ -178,7 +178,7 @@ class TestCreateDataset: assert data["error_type"] == "DatasetExistsError" assert "error" in data - @patch("superset.mcp_service.dataset.tool.create_dataset.CreateDatasetCommand") + @patch("superset.commands.dataset.create.CreateDatasetCommand") @pytest.mark.asyncio async def test_create_dataset_table_not_found(self, mock_command_class, mcp_server): """Returns DatasetError when the physical table does not exist in the DB.""" @@ -206,7 +206,7 @@ class TestCreateDataset: data = json.loads(result.content[0].text) assert data["error_type"] == "TableNotFoundError" - @patch("superset.mcp_service.dataset.tool.create_dataset.CreateDatasetCommand") + @patch("superset.commands.dataset.create.CreateDatasetCommand") @pytest.mark.asyncio async def test_create_dataset_unexpected_error( self, mock_command_class, mcp_server @@ -247,7 +247,7 @@ class TestCreateDataset: }, ) - @patch("superset.mcp_service.dataset.tool.create_dataset.CreateDatasetCommand") + @patch("superset.commands.dataset.create.CreateDatasetCommand") @pytest.mark.asyncio async def test_create_dataset_returns_full_dataset_info( self, mock_command_class, mcp_server @@ -294,7 +294,7 @@ class TestCreateDataset: data = json.loads(result.content[0].text) assert data["id"] == 99 assert data["table_name"] == "sales" - assert data["schema_name"] == "dw" + assert data["schema"] == "dw" assert data["is_virtual"] is False assert len(data["columns"]) == 1 assert data["columns"][0]["column_name"] == "amount"
