def test1_get_gamesdb_info(self): api = Api() api._Api__request_gamesdb = MagicMock() api._Api__request_gamesdb.side_effect = [{}] test_game = Game("Test Game") exp = {"cover": "", "vertical_cover": "", "background": "", "genre": {}, "summary": {}} obs = api.get_gamesdb_info(test_game) self.assertEqual(exp, obs)
def test2_get_gamesdb_info(self): api = Api() api._Api__request_gamesdb = MagicMock() api._Api__request_gamesdb.side_effect = API_GET_INFO_STELLARIS test_game = Game("Stellaris") exp = GAMESDB_INFO_STELLARIS obs = api.get_gamesdb_info(test_game) self.assertEqual(exp, obs)
def test2_get_gamesdb_info(self): api = Api() api._Api__request_gamesdb = MagicMock() api._Api__request_gamesdb.side_effect = [{'id': '51622789000874509', 'game_id': '51154268886064420', 'platform_id': 'gog', 'external_id': '1508702879', 'game': {'genres': [{'id': '51071904337940794', 'name': {'*': 'Strategy', 'en-US': 'Strategy'}, 'slug': 'strategy'}], 'summary': {'*': 'Stellaris description'}, 'visible_in_library': True, 'aggregated_rating': 78.5455, 'game_modes': [{'id': '53051895165351137', 'name': 'Single player', 'slug': 'single-player'}, {'id': '53051908711988230', 'name': 'Multiplayer', 'slug': 'multiplayer'}], 'horizontal_artwork': {'url_format': 'https://images.gog.com/742acfb77ec51ca48c9f96947bf1fc0ad8f0551c9c9f338021e8baa4f08e449f{formatter}.{ext}?namespace=gamesdb'}, 'background': {'url_format': 'https://images.gog.com/742acfb77ec51ca48c9f96947bf1fc0ad8f0551c9c9f338021e8baa4f08e449f{formatter}.{ext}?namespace=gamesdb'}, 'vertical_cover': {'url_format': 'https://images.gog.com/8d822a05746670fb2540e9c136f0efaed6a2d5ab698a9f8bd7f899d21f2022d2{formatter}.{ext}?namespace=gamesdb'}, 'cover': {'url_format': 'https://images.gog.com/8d822a05746670fb2540e9c136f0efaed6a2d5ab698a9f8bd7f899d21f2022d2{formatter}.{ext}?namespace=gamesdb'}, 'logo': {'url_format': 'https://images.gog.com/c50a5d26c42d84b4b884976fb89d10bb3e97ebda0c0450285d92b8c50844d788{formatter}.{ext}?namespace=gamesdb'}, 'icon': {'url_format': 'https://images.gog.com/c85cf82e6019dd52fcdf1c81d17687dd52807835f16aa938abd2a34e5d9b99d0{formatter}.{ext}?namespace=gamesdb'}, 'square_icon': {'url_format': 'https://images.gog.com/c3adc81bf37f1dd89c9da74c13967a08b9fd031af4331750dbc65ab0243493c8{formatter}.{ext}?namespace=gamesdb'}}}] test_game = Game("Stellaris") exp = {'cover': 'https://images.gog.com/8d822a05746670fb2540e9c136f0efaed6a2d5ab698a9f8bd7f899d21f2022d2.png?namespace=gamesdb', 'vertical_cover': 'https://images.gog.com/8d822a05746670fb2540e9c136f0efaed6a2d5ab698a9f8bd7f899d21f2022d2.png?namespace=gamesdb', 'background': 'https://images.gog.com/742acfb77ec51ca48c9f96947bf1fc0ad8f0551c9c9f338021e8baa4f08e449f.png?namespace=gamesdb', 'summary': {'*': 'Stellaris description'}, 'genre': {'*': 'Strategy', 'en-US': 'Strategy'}} obs = api.get_gamesdb_info(test_game) self.assertEqual(exp, obs)
def test3_get_gamesdb_info_no_genre(self): api_info = copy.deepcopy(API_GET_INFO_STELLARIS) api_info[0]["game"]["genres"] = [] api_info[0]["game"]["genres_ids"] = [] api = Api() api._Api__request_gamesdb = MagicMock() api._Api__request_gamesdb.side_effect = api_info test_game = Game("Stellaris") exp = copy.deepcopy(GAMESDB_INFO_STELLARIS) exp['genre'] = {} obs = api.get_gamesdb_info(test_game) self.assertEqual(exp, obs)