forked from sergey-galasov/psn-galaxy
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a769b09
commit 8b05bd2
Showing
3 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
from galaxy.api.types import GameTime | ||
|
||
|
||
@pytest.fixture() | ||
def played_games_backend_response(): | ||
return { | ||
"data": { | ||
"gameLibraryTitlesRetrieve": { | ||
"__typename": "GameList", | ||
"games": [ | ||
{ | ||
"__typename": "GameLibraryTitle", | ||
"lastPlayedDateTime": "2021-03-06T16:29:22.490Z", | ||
"name": "Call of Duty®: Modern Warfare®", | ||
"platform": "PS4", | ||
"titleId": "GAME_ID_1", | ||
}, | ||
{ | ||
"__typename": "GameLibraryTitle", | ||
"lastPlayedDateTime": "1970-01-01T00:00:01.000Z", | ||
"name": "Call of Duty®: Modern Warfare®", | ||
"platform": "PS4", | ||
"titleId": "GAME_ID_2", | ||
}, | ||
], | ||
} | ||
} | ||
} | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_prepare_game_times_context( | ||
http_get, authenticated_plugin, played_games_backend_response | ||
): | ||
http_get.return_value = played_games_backend_response | ||
|
||
result = await authenticated_plugin.prepare_game_times_context(Mock(list)) | ||
for title in played_games_backend_response["data"]["gameLibraryTitlesRetrieve"]["games"]: | ||
game = result[title["titleId"]] | ||
assert game["name"] is not None | ||
assert game["name"] == title["name"] | ||
assert game["titleId"] is not None | ||
assert game["titleId"] == title["titleId"] | ||
assert game["lastPlayedDateTime"] is not None | ||
assert game["lastPlayedDateTime"] == title["lastPlayedDateTime"] | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_getting_game_time( | ||
http_get, authenticated_plugin, played_games_backend_response | ||
): | ||
http_get.return_value = played_games_backend_response | ||
ctx = await authenticated_plugin.prepare_game_times_context(Mock(list)) | ||
assert GameTime("GAME_ID_1", None, 1615048162) == await authenticated_plugin.get_game_time( | ||
"GAME_ID_1", ctx | ||
) | ||
assert GameTime("GAME_ID_2", None, 1) == await authenticated_plugin.get_game_time( | ||
"GAME_ID_2", ctx | ||
) |
8b05bd2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lack the technical ability to review the code, but I figured out how to manually cut/paste to replace two of the files, and add the third to the tests directory. Rebooted GOG and last played time is now accurately reflected for my Playstation games. Thank you VERY much for this.