From e57ecc489c167e92e650468bd9e83279cf843f76 Mon Sep 17 00:00:00 2001 From: Aleksej Pawlowskij Date: Mon, 28 Oct 2019 11:07:54 +0100 Subject: [PATCH] SDK-3110: Deprecate FriendInfo and replace with UserInfo --- src/galaxy/api/plugin.py | 8 ++++---- src/galaxy/api/types.py | 15 ++++++++++++++- tests/test_friends.py | 8 ++++---- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/galaxy/api/plugin.py b/src/galaxy/api/plugin.py index e8ae655..55cfad8 100644 --- a/src/galaxy/api/plugin.py +++ b/src/galaxy/api/plugin.py @@ -11,7 +11,7 @@ from galaxy.api.consts import Feature, OSCompatibility from galaxy.api.errors import ImportInProgress, UnknownError from galaxy.api.jsonrpc import ApplicationError, NotificationClient, Server from galaxy.api.types import ( - Achievement, Authentication, FriendInfo, Game, GameLibrarySettings, GameTime, LocalGame, NextStep, UserPresence + Achievement, Authentication, Game, GameLibrarySettings, GameTime, LocalGame, NextStep, UserInfo, UserPresence ) from galaxy.task_manager import TaskManager @@ -383,10 +383,10 @@ class Plugin: params = {"local_game": local_game} self._notification_client.notify("local_game_status_changed", params) - def add_friend(self, user: FriendInfo) -> None: + def add_friend(self, user: UserInfo) -> None: """Notify the client to add a user to friends list of the currently authenticated user. - :param user: FriendInfo of a user that the client will add to friends list + :param user: UserInfo of a user that the client will add to friends list """ params = {"friend_info": user} self._notification_client.notify("friend_added", params) @@ -747,7 +747,7 @@ class Plugin: This method is called by the GOG Galaxy Client.""" raise NotImplementedError() - async def get_friends(self) -> List[FriendInfo]: + async def get_friends(self) -> List[UserInfo]: """Override this method to return the friends list of the currently authenticated user. This method is called by the GOG Galaxy Client. diff --git a/src/galaxy/api/types.py b/src/galaxy/api/types.py index 6c0a71b..c2c0a1b 100644 --- a/src/galaxy/api/types.py +++ b/src/galaxy/api/types.py @@ -140,7 +140,10 @@ class LocalGame: @dataclass class FriendInfo: - """Information about a friend of the currently authenticated user. + """ + .. deprecated:: 0.56 + Use: :class:`UserInfo`. + Information about a friend of the currently authenticated user. :param user_id: id of the user :param user_name: username of the user @@ -149,6 +152,16 @@ class FriendInfo: user_name: str +@dataclass +class UserInfo: + """Information about a user of related user. + + :param user_id: id of the user + :param user_name: username of the user + """ + user_id: str + user_name: str + @dataclass class GameTime: """Game time of a game, defines the total time spent in the game diff --git a/tests/test_friends.py b/tests/test_friends.py index 8b124e9..4222e38 100644 --- a/tests/test_friends.py +++ b/tests/test_friends.py @@ -1,4 +1,4 @@ -from galaxy.api.types import FriendInfo +from galaxy.api.types import UserInfo from galaxy.api.errors import UnknownError from galaxy.unittest.mock import async_return_value, skip_loop @@ -17,8 +17,8 @@ async def test_get_friends_success(plugin, read, write): read.side_effect = [async_return_value(create_message(request)), async_return_value(b"", 10)] plugin.get_friends.return_value = async_return_value([ - FriendInfo("3", "Jan"), - FriendInfo("5", "Ola") + UserInfo("3", "Jan"), + UserInfo("5", "Ola") ]) await plugin.run() plugin.get_friends.assert_called_with() @@ -64,7 +64,7 @@ async def test_get_friends_failure(plugin, read, write): @pytest.mark.asyncio async def test_add_friend(plugin, write): - friend = FriendInfo("7", "Kuba") + friend = UserInfo("7", "Kuba") plugin.add_friend(friend) await skip_loop()