aminghadersohi commented on code in PR #44765:
URL: https://github.com/apache/superset/pull/44765#discussion_r4154200487
##########
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:
Addressed in ed86e15890 (test(oauth2): assert refresh call arguments) by
asserting the full refresh call signature.
--
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]