async def test_get_os_compatibility(plugin, overgrowth): ovg_id = overgrowth['product']['machine_name'] subproduct = overgrowth['subproducts'][0] game = Subproduct(subproduct) no_downloads_id = 'nodw' no_dw_game = Subproduct({ 'human_name': 'mock', 'machine_name': no_downloads_id, 'downloads': [] }) key_game_id = 'keyg' key_game = Mock(spec=KeyGame) plugin._owned_games = { ovg_id: game, no_downloads_id: no_dw_game, key_game_id: key_game } ctx = await plugin.prepare_os_compatibility_context( plugin._owned_games.keys()) assert await plugin.get_os_compatibility(no_downloads_id, ctx) == None assert await plugin.get_os_compatibility( ovg_id, ctx) == OSC.Windows | OSC.MacOS | OSC.Linux assert await plugin.get_os_compatibility( key_game_id, ctx) == OSC.Windows | OSC.MacOS | OSC.Linux
def _get_subproducts(orders: list) -> List[Subproduct]: subproducts = [] for details in orders: for sub_data in details['subproducts']: sub = Subproduct(sub_data) try: sub.in_galaxy_format() # minimal validation except Exception as e: logger.warning(f"Error while parsing subproduct {repr(e)}: {sub_data}", extra={'data': sub_data}) continue if not set(sub.downloads).isdisjoint(GAME_PLATFORMS): # at least one download exists for supported OS subproducts.append(sub) return subproducts
def get_torchlight(orders_keys): for i in orders_keys: if i['product']['machine_name'] == 'torchlight_storefront': torchlight_order = i drm_free = Subproduct(torchlight_order['subproducts'][0]) key = Key(torchlight_order['tpkd_dict']['all_tpks'][0]) return torchlight_order, drm_free, key
async def test_install_game_drm_free(api_mock, plugin, overgrowth): id_ = overgrowth['product']['machine_name'] subproduct = overgrowth['subproducts'][0] game = Subproduct(subproduct) plugin._owned_games = {id_: game} expected_url = "https://dl.humble.com/wolfiregames/overgrowth-1.4.0_build-5584-win64.zip?gamekey=XrCTukcAFwsh&ttl=1563893021&t=7f2263e7f3360f3beb112e58521145a0" api_mock.sign_url_subproduct.return_value = {"signed_url": expected_url} with patch('webbrowser.open') as browser_open: await plugin.install_game(id_) browser_open.assert_called_once_with(expected_url)
def test_game_properties_overgrowth(overgrowth): for sub_data in overgrowth['subproducts']: sub = Subproduct(sub_data) sub.human_name sub.machine_name sub.license for platform, download in sub.downloads.items(): assert platform in set(HP) for dw_struct in download.download_struct: dw_struct.web dw_struct.bittorrent dw_struct.human_size assert not set(sub.downloads).isdisjoint(GAME_PLATFORMS)
def test_game_properties_access(orders): for order in orders: for sub_data in order['subproducts']: sub = Subproduct(sub_data) sub.human_name sub.machine_name sub.license for platform, download in sub.downloads.items(): assert platform in set(HP) for dw_struct in download.download_struct: dw_struct.web dw_struct.bittorrent dw_struct.human_size
def _get_subproducts(orders: list) -> List[Subproduct]: subproducts = [] for details in orders: for sub_data in details['subproducts']: try: sub = Subproduct(sub_data) if not set(sub.downloads).isdisjoint(GAME_PLATFORMS): # at least one download exists for supported OS subproducts.append(sub) except Exception as e: logging.warning( f"Error while parsing downloads {e}: {details}") continue return subproducts
async def test_install_game(plugin_mock, overgrowth): id_ = overgrowth['product']['machine_name'] subproduct = overgrowth['subproducts'][0] game = Subproduct(subproduct) plugin_mock._owned_games = {id_: game} # Note windows have also download_struct named "Patch". Not supported currently, only one download download_urls = { "linux": "https://dl.humble.com/wolfiregames/overgrowth-1.4.0_build-5584-linux64.zip?gamekey=XrCTukcAFwsh&ttl=1563893021&t=46b9a84ac7c864cf8fe263239a9978ae", "windows": "https://dl.humble.com/wolfiregames/overgrowth-1.4.0_build-5584-win64.zip?gamekey=XrCTukcAFwsh&ttl=1563893021&t=7f2263e7f3360f3beb112e58521145a0", "mac": "https://dl.humble.com/wolfiregames/overgrowth-1.4.0_build-5584-macosx.zip?gamekey=XrCTukcAFwsh&ttl=1563893021&t=5ade7954d8fc63bbe861932be538c07e", } for os in [HP.WINDOWS, HP.MAC]: plugin_mock._download_resolver = HumbleDownloadResolver( target_platform=os) with patch('webbrowser.open') as browser_open: await plugin_mock.install_game(id_) browser_open.assert_called_once_with(download_urls[os.value])