mirror of
https://github.com/gogcom/galaxy-integrations-python-api.git
synced 2026-04-18 21:26:53 -04:00
SDK-2933: Add shutdown_client notification
This commit is contained in:
@@ -98,6 +98,7 @@ class Feature(Enum):
|
||||
ImportUsers = "ImportUsers"
|
||||
VerifyGame = "VerifyGame"
|
||||
ImportFriends = "ImportFriends"
|
||||
ShutdownPlatformClient = "ShutdownPlatformClient"
|
||||
|
||||
|
||||
class LicenseType(Enum):
|
||||
|
||||
@@ -107,6 +107,11 @@ class Plugin:
|
||||
self.uninstall_game,
|
||||
feature=Feature.UninstallGame
|
||||
)
|
||||
self._register_notification(
|
||||
"shutdown_platform_client",
|
||||
self.shutdown_platform_client,
|
||||
feature=Feature.ShutdownPlatformClient
|
||||
)
|
||||
self._register_method(
|
||||
"import_friends",
|
||||
self.get_friends,
|
||||
@@ -718,6 +723,11 @@ class Plugin:
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
async def shutdown_platform_client(self) -> None:
|
||||
"""Override this method to gracefully terminate 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.
|
||||
|
||||
@@ -48,7 +48,8 @@ def plugin(reader, writer):
|
||||
"get_rooms",
|
||||
"get_room_history_from_message",
|
||||
"get_room_history_from_timestamp",
|
||||
"get_game_times"
|
||||
"get_game_times",
|
||||
"shutdown_platform_client"
|
||||
)
|
||||
|
||||
methods = (
|
||||
|
||||
15
tests/test_shutdown_platform_client.py
Normal file
15
tests/test_shutdown_platform_client.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_success(plugin, read):
|
||||
request = {
|
||||
"jsonrpc": "2.0",
|
||||
"method": "shutdown_platform_client"
|
||||
}
|
||||
|
||||
read.side_effect = [json.dumps(request).encode() + b"\n", b""]
|
||||
plugin.shutdown_platform_client.return_value = None
|
||||
await plugin.run()
|
||||
plugin.shutdown_platform_client.assert_called_with()
|
||||
Reference in New Issue
Block a user