From f5b9adfbd59573abf580d1d396dee9db1cd160ad Mon Sep 17 00:00:00 2001 From: Romuald Bierbasz Date: Fri, 2 Aug 2019 15:11:05 +0200 Subject: [PATCH] Add achievements_import_complete and game_times_import_complete --- src/galaxy/api/plugin.py | 12 ++++++++++++ tests/conftest.py | 2 ++ tests/test_achievements.py | 2 ++ tests/test_game_times.py | 2 ++ 4 files changed, 18 insertions(+) diff --git a/src/galaxy/api/plugin.py b/src/galaxy/api/plugin.py index f8cdc61..a23130a 100644 --- a/src/galaxy/api/plugin.py +++ b/src/galaxy/api/plugin.py @@ -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. diff --git a/tests/conftest.py b/tests/conftest.py index 23283a9..9fa89ab 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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" diff --git a/tests/test_achievements.py b/tests/test_achievements.py index 6bf05ee..1d7abda 100644 --- a/tests/test_achievements.py +++ b/tests/test_achievements.py @@ -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) == [ { diff --git a/tests/test_game_times.py b/tests/test_game_times.py index 334d01a..877bcc1 100644 --- a/tests/test_game_times.py +++ b/tests/test_game_times.py @@ -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) == [ {