From 4cc8be8f5d53c35c7e77badb0b7ac8994623269a Mon Sep 17 00:00:00 2001 From: Romuald Juchnowicz-Bierbasz Date: Tue, 13 Aug 2019 15:23:20 +0200 Subject: [PATCH] SDK-2997: Add launch_platform_client method --- src/galaxy/api/consts.py | 1 + src/galaxy/api/plugin.py | 8 ++++++++ tests/conftest.py | 1 + tests/test_features.py | 3 ++- tests/test_launch_platform_client.py | 17 +++++++++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/test_launch_platform_client.py diff --git a/src/galaxy/api/consts.py b/src/galaxy/api/consts.py index 19beba4..2b08f36 100644 --- a/src/galaxy/api/consts.py +++ b/src/galaxy/api/consts.py @@ -99,6 +99,7 @@ class Feature(Enum): VerifyGame = "VerifyGame" ImportFriends = "ImportFriends" ShutdownPlatformClient = "ShutdownPlatformClient" + LaunchPlatformClient = "LaunchPlatformClient" class LicenseType(Enum): diff --git a/src/galaxy/api/plugin.py b/src/galaxy/api/plugin.py index 415a448..2b67fea 100644 --- a/src/galaxy/api/plugin.py +++ b/src/galaxy/api/plugin.py @@ -107,6 +107,9 @@ class Plugin: self._register_notification("shutdown_platform_client", self.shutdown_platform_client) self._detect_feature(Feature.ShutdownPlatformClient, ["shutdown_platform_client"]) + self._register_notification("launch_platform_client", self.launch_platform_client) + self._detect_feature(Feature.LaunchPlatformClient, ["launch_platform_client"]) + self._register_method("import_friends", self.get_friends, result_name="friend_info_list") self._detect_feature(Feature.ImportFriends, ["get_friends"]) @@ -657,6 +660,11 @@ class Plugin: This method is called by the GOG Galaxy Client.""" raise NotImplementedError() + async def launch_platform_client(self) -> None: + """Override this method to launch platform client. + This method is called by the GOG Galaxy Client.""" + raise NotImplementedError() + async def get_friends(self) -> List[FriendInfo]: """Override this method to return the friends list of the currently authenticated user. diff --git a/tests/conftest.py b/tests/conftest.py index 9fa89ab..23bdadc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -40,6 +40,7 @@ def plugin(reader, writer): "achievements_import_complete", "get_local_games", "launch_game", + "launch_platform_client", "install_game", "uninstall_game", "get_friends", diff --git a/tests/test_features.py b/tests/test_features.py index 47e561d..68a6cd0 100644 --- a/tests/test_features.py +++ b/tests/test_features.py @@ -13,7 +13,8 @@ def test_base_class(): Feature.ImportAchievements, Feature.ImportGameTime, Feature.ImportFriends, - Feature.ShutdownPlatformClient + Feature.ShutdownPlatformClient, + Feature.LaunchPlatformClient } diff --git a/tests/test_launch_platform_client.py b/tests/test_launch_platform_client.py new file mode 100644 index 0000000..3536047 --- /dev/null +++ b/tests/test_launch_platform_client.py @@ -0,0 +1,17 @@ +import pytest + +from galaxy.unittest.mock import async_return_value + +from tests import create_message + +@pytest.mark.asyncio +async def test_success(plugin, read): + request = { + "jsonrpc": "2.0", + "method": "launch_platform_client" + } + + read.side_effect = [async_return_value(create_message(request)), async_return_value(b"")] + plugin.launch_platform_client.return_value = async_return_value(None) + await plugin.run() + plugin.launch_platform_client.assert_called_with()