bito-code-review[bot] commented on code in PR #43666:
URL: https://github.com/apache/superset/pull/43666#discussion_r4029856331
##########
tests/unit_tests/commands/dashboard/update_test.py:
##########
@@ -166,3 +171,85 @@ def
test_process_native_filter_diff_only_touches_reports_on_the_updated_dashboar
# NATIVE_FILTER-2 is the only one dropped from the new metadata.
report_dao.find_by_native_filter_id.assert_called_once_with("NATIVE_FILTER-2")
report_dao.update.assert_called_once_with(own_report, {"active": False})
+
+
+def _mock_dependencies(mocker: MockerFixture, existing_css: str) -> None:
+ model = mocker.MagicMock(id=1, tags=[], css=existing_css)
+ mocker.patch(
+ "superset.commands.dashboard.update.DashboardDAO.find_by_id",
+ return_value=model,
+ )
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Mock missing managed flag</b></div>
<div id="fix">
The `MagicMock` model's `is_managed_externally` attribute defaults to a
truthy MagicMock, so `raise_if_managed_externally()` (utils.py:96) raises
`DashboardForbiddenError` in `validate()` (update.py:138-142) before the css
check. All four new tests fail. Set `is_managed_externally=False` on the mock,
matching the pattern in `test_update_managed_externally.py`.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
def _mock_dependencies(mocker: MockerFixture, existing_css: str) -> None:
model = mocker.MagicMock(id=1, tags=[], css=existing_css,
is_managed_externally=False)
mocker.patch(
"superset.commands.dashboard.update.DashboardDAO.find_by_id",
return_value=model,
)
````
</div>
</details>
</div>
<small><i>Code Review Run #28bd22</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]