Lee-W commented on code in PR #38961:
URL: https://github.com/apache/airflow/pull/38961#discussion_r1566799340
##########
tests/providers/google/common/hooks/test_base_google.py:
##########
@@ -98,6 +98,46 @@ def test_raise_exception_on_non_quota_exception(self):
)
+class TestRefreshCredentialsRetry:
+ @pytest.mark.parametrize(
+ "exc, retryable",
+ [
+ (RefreshError("Other error", "test body"), False),
+ (RefreshError("Unable to acquire impersonated credentials", "test
body"), True),
+ (ValueError(), False),
+ ],
+ )
+ def test_is_refresh_credentials_exception(self, exc, retryable):
+ assert is_refresh_credentials_exception(exc) is retryable
+
+ def test_do_nothing_on_non_error(self):
+ @hook.GoogleBaseHook.refresh_credentials_retry()
+ def func():
+ return 42
+
+ assert func(), 42
Review Comment:
Should it be `func() == 42` instead?
##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -454,6 +474,24 @@ def decorator(fun: T):
return decorator
+ @staticmethod
+ def refresh_credentials_retry(*args, **kwargs) -> Callable[[T], T]:
+ """Provide a mechanism to repeat requests in response to a temporary
refresh credential issue."""
+
+ def decorator(fun: T):
Review Comment:
nitpick: `func` seems to be a more commonly used convention in airflow
```suggestion
def decorator(func: T):
```
--
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]