forked from FriendsOfGalaxy/galaxy-integration-uplay
-
Notifications
You must be signed in to change notification settings - Fork 0
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
c83812e
commit 86fbb57
Showing
17 changed files
with
11,612 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# auto-generated files | ||
**/__pycache__ | ||
.pytest_cache | ||
build/ | ||
output/ | ||
credentials.data | ||
webrtc_event_logs | ||
blob_storage | ||
plugin-uplay.spec | ||
|
||
# developement stuff | ||
venv | ||
.DS_Store | ||
.vscode | ||
.idea | ||
Pipfile | ||
# everyone has its own dev.txt to keep own dependencies | ||
requirements/dev.txt |
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,3 @@ | ||
[pytest] | ||
python_paths = src | ||
addopts = src tests --flakes |
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.28' | ||
__version__ = '0.30' |
Empty file.
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,7 @@ | ||
from unittest.mock import MagicMock | ||
|
||
|
||
class AsyncMock(MagicMock): | ||
async def __call__(self, *args, **kwargs): | ||
# pylint: disable=useless-super-delegation | ||
return super(AsyncMock, self).__call__(*args, **kwargs) |
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,65 @@ | ||
import asyncio | ||
from unittest.mock import patch, MagicMock | ||
import pytest | ||
import plugin | ||
from tests.website_mock import BackendClientMock | ||
|
||
from galaxy.api.consts import LicenseType | ||
from galaxy.api.types import Game, LicenseInfo | ||
|
||
class NewGame(object): | ||
def as_galaxy_game(self): | ||
passed_id = self.space_id if self.space_id else self.launch_id | ||
return Game(passed_id, self.name, [], LicenseInfo(LicenseType.SinglePurchase)) | ||
|
||
space_id: str = "123" | ||
launch_id: str = "321" | ||
third_party_id: str = "" | ||
name: str = "UbiGame" | ||
path: str = "" | ||
type: str = "New" | ||
special_registry_path: str = "" | ||
exe: str = "" | ||
owned: bool = True | ||
considered_for_sending: bool = False | ||
status: str = "NotInstalled" | ||
|
||
@pytest.fixture() | ||
def local_client(): | ||
mock = MagicMock() | ||
mock.is_installed = False | ||
mock.was_user_logged_in = False | ||
mock.configurations_accessible.return_value = False | ||
return mock | ||
|
||
|
||
@pytest.fixture() | ||
def create_plugin(local_client): | ||
def function(): | ||
with patch("plugin.LocalClient", return_value=local_client): | ||
with patch("plugin.BackendClient", new=BackendClientMock): | ||
return plugin.UplayPlugin(MagicMock(), MagicMock(), None) | ||
return function | ||
|
||
|
||
@pytest.fixture() | ||
def create_authenticated_plugin(create_plugin): | ||
|
||
def function(): | ||
loop = asyncio.get_event_loop() | ||
|
||
pg = create_plugin() | ||
pg.user_can_perform_actions = MagicMock() | ||
pg.games_collection.get_local_games = MagicMock() | ||
pg._game_ownership_is_glitched = MagicMock() | ||
pg.add_game = MagicMock() | ||
|
||
credentials = { | ||
"cookie_jar": "COOKIE_JAR", | ||
"access_token": "ACCESS_TOKEN"} | ||
loop.run_until_complete(pg.authenticate(credentials)) | ||
|
||
return pg | ||
|
||
return function | ||
|
Oops, something went wrong.