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


##########
tests/unit_tests/mcp_service/chart/tool/test_update_chart_preview.py:
##########
@@ -1410,24 +1627,19 @@ async def test_validation_failure_skips_cache_write(
             mock_create_form_data.assert_not_called()
 
     @patch.object(update_chart_preview_module, "_find_dataset")
-    @patch.object(update_chart_preview_module, "has_dataset_access", 
return_value=False)
-    @patch("superset.daos.dataset.DatasetDAO.find_by_id")
     @patch(
         
"superset.mcp_service.commands.create_form_data.MCPCreateFormDataCommand.run"
     )
     @pytest.mark.asyncio
     async def test_dataset_access_denied_short_circuits(
         self,
         mock_create_form_data,
-        mock_find_by_id,
-        unused_access_mock,
         mock_find_dataset,
         mcp_server,
         mock_auth,
     ):
-        """has_dataset_access=False → DatasetNotAccessible, no cache write."""
-        mock_find_dataset.return_value = _mock_dataset(id=3)
-        mock_find_by_id.return_value = _mock_dataset(id=3)
+        """An inaccessible dataset short-circuits before mapping or cache 
writes."""
+        mock_find_dataset.return_value = None

Review Comment:
   Fixed in 91019555303cd0571a604e2b1688826fcfc84f74. The merge brings back the 
tool's own `has_dataset_access` check in `update_chart_preview`. The test now 
keeps `_find_dataset` real, mocks `DatasetDAO.find_by_id` to return a dataset, 
and patches `has_dataset_access` to False. It asserts `DatasetNotAccessible`, 
that the access check was called with that dataset, and that neither 
`validate_and_compile` nor the cache write ran. If the access check is removed, 
the test fails.



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