Compare commits

..

2 Commits
0.45 ... 0.46

Author SHA1 Message Date
Romuald Juchnowicz-Bierbasz
13a3f7577b Increment version 2019-08-02 15:13:11 +02:00
Romuald Bierbasz
f5b9adfbd5 Add achievements_import_complete and game_times_import_complete 2019-08-02 15:11:05 +02:00
5 changed files with 19 additions and 1 deletions

View File

@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name="galaxy.plugin.api",
version="0.45",
version="0.46",
description="GOG Galaxy Integrations Python API",
author='Galaxy team',
author_email='galaxy@gog.com',

View File

@@ -545,6 +545,7 @@ class Plugin:
finally:
self._achievements_import_finished()
self._achievements_import_in_progress = False
self.achievements_import_complete()
self.create_task(import_games_achievements(game_ids, context), "Games unlocked achievements import")
self._achievements_import_in_progress = True
@@ -568,6 +569,11 @@ class Plugin:
"""
raise NotImplementedError()
def achievements_import_complete(self):
"""Override this method to handle operations after achievements import is finished
(like updating cache).
"""
async def get_local_games(self) -> List[LocalGame]:
"""Override this method to return the list of
games present locally on the users pc.
@@ -692,6 +698,7 @@ class Plugin:
finally:
self._game_times_import_finished()
self._game_times_import_in_progress = False
self.game_times_import_complete()
self.create_task(import_game_times(game_ids, context), "Game times import")
self._game_times_import_in_progress = True
@@ -714,6 +721,11 @@ class Plugin:
"""
raise NotImplementedError()
def game_times_import_complete(self):
"""Override this method to handle operations after game times import is finished
(like updating cache).
"""
def create_and_run_plugin(plugin_class, argv):
"""Call this method as an entry point for the implemented integration.

View File

@@ -37,6 +37,7 @@ def plugin(reader, writer):
"get_owned_games",
"prepare_achievements_context",
"get_unlocked_achievements",
"achievements_import_complete",
"get_local_games",
"launch_game",
"install_game",
@@ -44,6 +45,7 @@ def plugin(reader, writer):
"get_friends",
"get_game_time",
"prepare_game_times_context",
"game_times_import_complete",
"shutdown_platform_client",
"shutdown",
"tick"

View File

@@ -40,6 +40,7 @@ async def test_get_unlocked_achievements_success(plugin, read, write):
await plugin.run()
plugin.prepare_achievements_context.assert_called_with(["14"])
plugin.get_unlocked_achievements.assert_called_with("14", 5)
plugin.achievements_import_complete.asert_called_with()
assert get_messages(write) == [
{
@@ -97,6 +98,7 @@ async def test_get_unlocked_achievements_error(exception, code, message, plugin,
plugin.get_unlocked_achievements.side_effect = exception
await plugin.run()
plugin.get_unlocked_achievements.assert_called()
plugin.achievements_import_complete.asert_called_with()
assert get_messages(write) == [
{

View File

@@ -31,6 +31,7 @@ async def test_get_game_time_success(plugin, read, write):
call("5", "abc"),
call("7", "abc"),
])
plugin.game_times_import_complete.assert_called_once_with()
assert get_messages(write) == [
{
@@ -96,6 +97,7 @@ async def test_get_game_time_error(exception, code, message, plugin, read, write
plugin.get_game_time.side_effect = exception
await plugin.run()
plugin.get_game_time.assert_called()
plugin.game_times_import_complete.assert_called_once_with()
assert get_messages(write) == [
{