async def test_multiple_games(games_cache_mock, authenticated_plugin): games_cache_mock.get_owned_games = MagicMock(return_value=async_gen([ App(appid="281990", title="Stellaris", type="game", parent=None), App(appid="236850", title="Europa Universalis IV", type="game", parent=None), ])) result = await authenticated_plugin.get_owned_games() assert result == [ Game("281990", "Stellaris", [], LicenseInfo(LicenseType.SinglePurchase, None)), Game("236850", "Europa Universalis IV", [], LicenseInfo(LicenseType.SinglePurchase, None)) ]
def test_cache_dump(cache): cache_map = LicensesCache() cache_map.licenses = [License(package_id="39661", shared=False, app_ids={"286000"})] cache_map.apps = {"286000": App(appid="286000", title="Tooth and Tail", type="game", parent=None)} cache._storing_map = cache_map exp_result = r"""{"licenses": "{\"licenses\": [{\"package_id\": \"39661\", \"shared\": false, \"app_ids\": [\"286000\"]}], \"apps\": {\"286000\": {\"appid\": \"286000\", \"title\": \"Tooth and Tail\", \"type\": \"game\", \"parent\": null}}}", "version": "%s"}""" % __version__ assert cache.dump() == exp_result
def test_cache_load_ok(cache): cache_to_load = r"""{"licenses": "{\"licenses\": [{\"package_id\": \"39661\", \"shared\": false, \"app_ids\": [\"286000\"]}], \"apps\":{\"286000\": {\"appid\": \"286000\", \"title\": \"Tooth and Tail\", \"type\": \"game\", \"parent\": null}}}", "version": "%s"}""" % __version__ cache.loads(cache_to_load) exp_result_licenses = [License(package_id="39661", shared=False, app_ids={"286000"})] exp_result_apps = {"286000": App(appid="286000", title="Tooth and Tail", type="game", parent=None)} assert cache._storing_map.licenses == exp_result_licenses assert cache._storing_map.apps == exp_result_apps
async def test_multiple_games(authenticated_plugin, backend_client, miniprofile): # only fields important for the logic backend_client.get_owned_ids.return_value = [ 281990, 236850, ] authenticated_plugin._games_cache = MagicMock() authenticated_plugin._games_cache.get_owned_games.return_value = [ App(appid="281990", title="Stellaris", type="game"), App(appid="236850", title="Europa Universalis IV", type="game") ] authenticated_plugin._games_cache.wait_ready = AsyncMock() result = await authenticated_plugin.get_owned_games() assert result == [ Game("281990", "Stellaris", [], LicenseInfo(LicenseType.SinglePurchase, None)), Game("236850", "Europa Universalis IV", [], LicenseInfo(LicenseType.SinglePurchase, None)) ]