diff --git a/tap_github/authenticator.py b/tap_github/authenticator.py index d873b77..9234786 100644 --- a/tap_github/authenticator.py +++ b/tap_github/authenticator.py @@ -227,7 +227,7 @@ def has_calls_remaining(self) -> bool: self.claim_token() if self.token is None: if self.logger: - self.logger.warn("GitHub app token refresh failed.") + self.logger.warning("GitHub app token refresh failed.") return False else: if self.logger: @@ -278,7 +278,7 @@ def prepare_tokens(self) -> list[TokenManager]: if token_manager.is_valid_token(): personal_token_managers.append(token_manager) else: - logging.warn("A token was dismissed.") + logging.warning("A token was dismissed.") # Parse App level private keys and generate tokens # To simplify settings, we use a single env-key formatted as follows: @@ -308,7 +308,7 @@ def prepare_tokens(self) -> list[TokenManager]: if app_token_manager.is_valid_token(): app_token_managers.append(app_token_manager) except ValueError as e: - self.logger.warn( + self.logger.warning( f"An error was thrown while preparing an app token: {e}" ) diff --git a/tap_github/tests/test_authenticator.py b/tap_github/tests/test_authenticator.py index 042e483..0ca38fd 100644 --- a/tap_github/tests/test_authenticator.py +++ b/tap_github/tests/test_authenticator.py @@ -1,6 +1,6 @@ import re from datetime import datetime, timedelta -from unittest.mock import MagicMock, patch +from unittest.mock import MagicMock, call, patch import pytest import requests @@ -215,10 +215,10 @@ def test_has_calls_remaining_logs_warning_if_token_regeneration_fails(self): mock_is_valid.return_value = False assert not token_manager.has_calls_remaining() - token_manager.logger.warn.assert_called_once() - assert ( - "GitHub app token refresh failed." - in token_manager.logger.warn.call_args[0][0] + assert isinstance(token_manager.logger.warning, MagicMock) + token_manager.logger.warning.assert_has_calls( + [call("GitHub app token refresh failed.")], + any_order=True, ) def test_has_calls_remaining_succeeds_if_token_new_and_never_used(self): @@ -537,7 +537,7 @@ def test_handle_error_if_app_key_invalid(self, mock_stream): auth = GitHubTokenAuthenticator(stream=mock_stream) auth.prepare_tokens() - mock_stream.logger.warn.assert_called_with( + mock_stream.logger.warning.assert_called_with( "An error was thrown while preparing an app token: Invalid key format" )