Compare commits

...

1 Commits

Author SHA1 Message Date
Evan Rusackas
11f820b9db fix(tests): patch _validate_update_against_dataset on the module, not the dotted string
`tests/.../test_update_chart.py::test_dataset_id_passed_to_update_command`
fails deterministically on the `unit-tests (previous)` CI leg with:

    AttributeError: <function update_chart ...> does not have the
    attribute '_validate_update_against_dataset'

`superset/mcp_service/chart/tool/__init__.py` re-exports the `update_chart`
*function*, shadowing the `update_chart` submodule attribute on the package.
The string-based `@patch("...tool.update_chart._validate_update_against_dataset")`
resolves the dotted path via `getattr(tool, "update_chart")`, which returns the
function rather than the module, so the attribute lookup fails. (Older
unittest.mock returns the shadowing attribute; newer versions prefer the
submodule, which is why only the previous-Python leg goes red.)

The other three tests in this file already patch via
`patch.object(update_chart_module, "_validate_update_against_dataset", ...)`,
using the `importlib`-resolved module created for exactly this reason. This
makes the last test consistent with them. Verified on Python 3.10: fails
before, passes after.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 20:50:26 -07:00

View File

@@ -1480,8 +1480,9 @@ class TestUpdateChartDatasetIdIntegration:
"superset.commands.chart.update.UpdateChartCommand",
new_callable=Mock,
)
@patch(
"superset.mcp_service.chart.tool.update_chart._validate_update_against_dataset",
@patch.object(
update_chart_module,
"_validate_update_against_dataset",
return_value=None,
)
@patch("superset.daos.chart.ChartDAO.find_by_id", new_callable=Mock)