bito-code-review[bot] commented on PR #43464:
URL: https://github.com/apache/superset/pull/43464#issuecomment-5397372992

   <!-- Bito Reply -->
   The flagged issue is correct. In 
`test_load_chart_data_into_cache_with_query_failed_error_does_not_reraise`, the 
`ChartDataQueryFailedError` is raised by the schema's `load` method, which 
causes the function to exit before reaching the `ChartDataCommand.run()` call. 
To properly test the production logic, the test should mock 
`ChartDataCommand.run` to raise the exception instead, ensuring the error 
handling path is actually exercised.
   
   To resolve this, update the test to mock the command class and set the side 
effect on its `run` method, similar to how 
`test_load_chart_data_into_cache_with_cache_load_error_does_not_reraise` is 
implemented.
   
   **tests/unit_tests/tasks/test_async_queries.py**
   ```
   @mock.patch("superset.tasks.async_queries.security_manager")
   @mock.patch("superset.tasks.async_queries.async_query_manager")
   @mock.patch("superset.commands.chart.data.get_data_command.ChartDataCommand")
   @mock.patch("superset.tasks.async_queries.ChartDataQueryContextSchema")
   def test_load_chart_data_into_cache_with_query_failed_error_does_not_reraise(
       mock_query_context_schema_cls, mock_command_cls, 
mock_async_query_manager, mock_security_manager
   ):
       # ... setup ...
       mock_query_context_schema_cls.return_value.load.return_value = 
mock.MagicMock()
       mock_command_cls.return_value.run.side_effect = 
ChartDataQueryFailedError(_(err_message))
       # ... execution and assertion ...
   ```


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