Skip to content

Commit

Permalink
version 0.30
Browse files Browse the repository at this point in the history
  • Loading branch information
FriendsOfGalaxy committed Jun 14, 2019
1 parent c83812e commit 86fbb57
Show file tree
Hide file tree
Showing 17 changed files with 11,612 additions and 5 deletions.
18 changes: 18 additions & 0 deletions .gitignore
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
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
python_paths = src
addopts = src tests --flakes
10 changes: 6 additions & 4 deletions src/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,13 @@ def _parse_game(self, game_yaml, launch_id):
if 'third_party_platform' in game_yaml['root']:
if game_yaml['root']['third_party_platform']['name'].lower() == 'steam':
game_type = GameType.Steam
path = game_yaml['root']['start_game']['steam']['game_installation_status_register']
if 'third_party_steam' in game_yaml['root']['start_game']:
path = game_yaml['root']['start_game']['third_party_steam']['game_installation_status_register']
third_party_id = game_yaml['root']['start_game']['third_party_steam']['steam_app_id']
elif 'steam' in game_yaml['root']['start_game']:
path = game_yaml['root']['start_game']['steam']['game_installation_status_register']
third_party_id = game_yaml['root']['start_game']['steam']['steam_app_id']
status = get_steam_game_status(path)
if 'start_game' in game_yaml['root']:
if 'steam' in game_yaml['root']['start_game']:
third_party_id = game_yaml['root']['start_game']['steam']['steam_app_id']
elif game_yaml['root']['third_party_platform']['name'].lower() == 'origin':
game_type = GameType.Origin
path = game_yaml['root']['third_party_platform']['platform_installation_status']['register']
Expand Down
3 changes: 3 additions & 0 deletions src/steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def is_steam_installed():


def get_steam_game_status(path):
if not path:
return GameStatus.NotInstalled

reg_path = path
index = reg_path.lower().find("software")
end = reg_path.lower().find("installed")
Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.28'
__version__ = '0.30'
Empty file added tests/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions tests/async_mock.py
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)
65 changes: 65 additions & 0 deletions tests/conftest.py
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

Loading

0 comments on commit 86fbb57

Please sign in to comment.