Skip to content

Commit

Permalink
Merge "IMPR: add access_token.setter to OauthLoginManager"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Dec 6, 2024
2 parents 861a186 + 9cc7889 commit 12b04a9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion pywikibot/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ def __init__(self, password: str | None = None,
if getattr(config, 'password_file', ''):
self.readPassword()

def __repr__(self):
"""Return representation string for LoginManager.
..versionadded:: 10.0
"""
return f'{type(self).__name__}(user={self.username!r})'

def check_user_exists(self) -> None:
"""Check that the username exists on the site.
Expand Down Expand Up @@ -584,12 +591,24 @@ def consumer_token(self) -> tuple[str, str]:

@property
def access_token(self) -> tuple[str, str] | None:
"""Return OAuth access key token and secret token.
"""OAuth access key token and secret token.
.. seealso:: :api:`Tokens`
:getter: Return OAuth access key token and secret token.
:setter: Add OAuth access key token and secret token.
Implemented to discard user interaction token fetching,
usually for tests.
.. versionadded:: 10.0
"""
return self._access_token

@access_token.setter
def access_token(self, token: tuple[str, str]) -> None:
"""Add OAuth access key token and secret token."""
self._access_token = token

@property
def identity(self) -> dict[str, Any] | None:
"""Get identifying information about a user via an authorized token.
Expand Down
2 changes: 1 addition & 1 deletion tests/oauth_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _get_login_manager(self):
site=self.site,
user=self.consumer_token[0])
# Set access token directly, discard user interaction token fetching
login_manager._access_token = self.access_token
login_manager.access_token = self.access_token
return login_manager

def test_login(self):
Expand Down

0 comments on commit 12b04a9

Please sign in to comment.