bito-code-review[bot] commented on code in PR #44765:
URL: https://github.com/apache/superset/pull/44765#discussion_r4154014391
##########
tests/unit_tests/utils/oauth2_tests.py:
##########
@@ -239,6 +245,50 @@ def test_execute_with_oauth2_retry_forces_refresh_once(
db.session.expire.assert_called_once_with(token)
[email protected]("retry_fails", [False, True])
[email protected]("outer_active", [False, True])
+def test_execute_with_oauth2_retry_guards_both_attempts(
+ mocker: MockerFixture,
+ retry_fails: bool,
+ outer_active: bool,
+) -> None:
+ """Both attempts own connection recovery, and every exit restores the
guard."""
+ mocker.patch(
+ "superset.utils.oauth2._oauth2_retry_active",
+ ContextVar("test_oauth2_retry_active", default=outer_active),
+ )
+ database = mocker.MagicMock(id=1)
+ database.is_oauth2_enabled.return_value = True
+ database.db_engine_spec.needs_oauth2.return_value = True
+ database.get_oauth2_config.return_value = DUMMY_OAUTH2_CONFIG
+ mocker.patch("superset.utils.oauth2.g").user.id = 2
+ db = mocker.patch("superset.utils.oauth2.db")
+ db.session.query().filter_by().one_or_none.return_value = None
+ refresh = mocker.patch(
+ "superset.utils.oauth2.refresh_oauth2_token", return_value="new-token"
+ )
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Weak refresh assertion</b></div>
<div id="fix">
The `refresh` mock is only checked with `assert_called_once()`; unlike
`test_execute_with_oauth2_retry_forces_refresh_once` (lines 237-244), the call
arguments are never verified. If `execute_with_oauth2_retry` passed the wrong
config, user id, or `force` flag, this test would still pass. Assert the full
call signature.
</div>
</div>
<small><i>Code Review Run #22acaa</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]