forked from johnny-moonbeam/galaxy-origin
-
Notifications
You must be signed in to change notification settings - Fork 15
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
89d4428
commit f746eb1
Showing
7 changed files
with
206 additions
and
7 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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.30" | ||
__version__ = "0.31" |
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
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,107 @@ | ||
import pytest | ||
from galaxy.api.errors import AuthenticationRequired | ||
from galaxy.api.types import GameLibrarySettings | ||
from galaxy.unittest.mock import async_return_value | ||
|
||
GAME_IDS = ['DR:119971300', 'OFB-EAST:48217', 'OFB-EAST:109552409', 'Origin.OFR.50.0002694'] | ||
|
||
BACKEND_HIDDEN_RESPONSE = ''' | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<privacySettings> | ||
<privacySetting> | ||
<userId>1008620950926</userId> | ||
<category>HIDDENGAMES</category> | ||
<payload>Origin.OFR.50.0002694;OFB-EAST:109552409</payload> | ||
</privacySetting> | ||
</privacySettings> | ||
''' | ||
|
||
BACKEND_FAVORITES_RESPONSE = ''' | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<privacySettings> | ||
<privacySetting> | ||
<userId>1008620950926</userId> | ||
<category>FAVORITEGAMES</category> | ||
<payload>OFB-EAST:48217;OFB-EAST:109552409;DR:119971300</payload> | ||
</privacySetting> | ||
</privacySettings> | ||
''' | ||
|
||
FAVORITE_GAMES = {'OFB-EAST:48217', 'OFB-EAST:109552409', 'DR:119971300'} | ||
HIDDEN_GAMES = {'Origin.OFR.50.0002694', 'OFB-EAST:109552409'} | ||
|
||
GAME_LIBRARY_CONTEXT = { | ||
'OFB-EAST:48217': { | ||
'hidden': False, | ||
'favorite': True | ||
}, | ||
'OFB-EAST:109552409': { | ||
'hidden': True, | ||
'favorite': True | ||
}, | ||
'DR:119971300': { | ||
'hidden': False, | ||
'favorite': True | ||
}, | ||
'Origin.OFR.50.0002694': { | ||
'hidden': True, | ||
'favorite': False | ||
} | ||
} | ||
|
||
GAME_LIBRARY_SETTINGS = GameLibrarySettings('OFB-EAST:48217', ['favorite'], False) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_not_authenticated(plugin, http_client): | ||
http_client.is_authenticated.return_value = False | ||
with pytest.raises(AuthenticationRequired): | ||
await plugin.prepare_game_library_settings_context([]) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_prepare_library_settings_context( | ||
authenticated_plugin, | ||
backend_client, | ||
user_id, | ||
|
||
): | ||
backend_client.get_favorite_games.return_value = FAVORITE_GAMES | ||
backend_client.get_hidden_games.return_value = HIDDEN_GAMES | ||
|
||
assert GAME_LIBRARY_CONTEXT == await authenticated_plugin.prepare_game_library_settings_context(GAME_IDS) | ||
|
||
backend_client.get_favorite_games.assert_called_once_with(user_id) | ||
backend_client.get_hidden_games.assert_called_once_with(user_id) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_get_favorite_games( | ||
backend_client, | ||
user_id, | ||
http_client, | ||
): | ||
http_client.get.return_value = async_return_value(BACKEND_FAVORITES_RESPONSE) | ||
|
||
assert FAVORITE_GAMES == await backend_client.get_favorite_games(user_id) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_get_hidden_games( | ||
backend_client, | ||
user_id, | ||
http_client, | ||
): | ||
http_client.get.return_value = async_return_value(BACKEND_HIDDEN_RESPONSE) | ||
|
||
assert HIDDEN_GAMES == await backend_client.get_hidden_games(user_id) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_get_game_library_settings( | ||
authenticated_plugin, | ||
): | ||
assert GAME_LIBRARY_SETTINGS == await authenticated_plugin.get_game_library_settings('OFB-EAST:48217', GAME_LIBRARY_CONTEXT) | ||
|
||
|
||
|