def test_split_multigame_key(): tpks = { "machine_name": "sega", "human_name": "Alpha Protocol, Company of Heroes, Rome: Total War, Hell Yeah! Wrath of the Dead Rabbit", } key = Key(tpks) assert LibraryResolver._split_multigame_key(key) == [ KeyGame(key, "sega_0", "Alpha Protocol"), KeyGame(key, "sega_1", "Company of Heroes"), KeyGame(key, "sega_2", "Rome: Total War"), KeyGame(key, "sega_3", "Hell Yeah! Wrath of the Dead Rabbit") ]
def test_key_split_key_games(): tpks = { "machine_name": "sega", "human_name": "Alpha Protocol, Company of Heroes, Rome: Total War, Hell Yeah! Wrath of the Dead Rabbit", } key = Key(tpks) assert key.key_games == [ KeyGame(key, "sega_0", "Alpha Protocol"), KeyGame(key, "sega_1", "Company of Heroes"), KeyGame(key, "sega_2", "Rome: Total War"), KeyGame(key, "sega_3", "Hell Yeah! Wrath of the Dead Rabbit") ]
def test_key_game_human_name_not_changed(): tpks = { 'machine_name': 'tor', 'human_name': 'Tor Steam', 'key_type_human_name': 'Steam' } assert KeyGame(Key(tpks), 'tor', 'Tor Steam').human_name == 'Tor Steam'
def test_key_key_games_one_game(): """Most common case where 1 key == 1 game""" key = Key({ "machine_name": "ww", "human_name": "The Witcher", "key_type_human_name": "Steam Key" }) assert key.key_games == [KeyGame(key, "ww", "The Witcher (Steam Key)")]
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]) key_game = KeyGame(key, key.machine_name, key.human_name) return torchlight_order, drm_free, key_game
def _split_multigame_key(key: Key) -> List[KeyGame]: """Extract list of KeyGame objects from single Key""" logger.info(f'Spliting {key}') names = key.human_name.split(', ') return [ KeyGame(key, f'{key.machine_name}_{i}', name) for i, name in enumerate(names) ]
def _get_key_games(self, orders: list, show_revealed_keys: bool) -> List[KeyGame]: key_games = [] key_infos = self._get_key_infos(orders) for key, product_category in key_infos: if key.key_val is None or show_revealed_keys: if self._is_multigame_key(key, product_category, blacklist=COMMA_SPLIT_BLACKLIST): key_games.extend(self._split_multigame_key(key)) else: key_games.append(KeyGame(key, key.machine_name, key.human_name)) return key_games
def test_key_key_game_data(): tpks = {"machine_name": "ww", "human_name": "The Witcher, The Witcher 2"} key = Key(tpks) assert tpks == KeyGame(key, 'ww', 'sth')._data