def test3_add_games_from_api(self): self_games = [] for game in SELF_GAMES: self_games.append(Game( name=game, game_id=int(SELF_GAMES[game]), )) self_games.append(Game(name="Game without ID", game_id=0)) api_games = [] for game in API_GAMES: api_games.append(Game( name=game, game_id=int(API_GAMES[game]), )) api_gmae_with_id = Game(name="Game without ID", game_id=1234567890) api_games.append(api_gmae_with_id) api_mock = MagicMock() api_mock.get_library.return_value = api_games test_library = Library(MagicMock(), api_mock) test_library.games = self_games test_library._Library__add_games_from_api() exp = True obs = api_gmae_with_id in test_library.games self.assertEqual(exp, obs) exp = len(api_games) obs = len(test_library.games) self.assertEqual(exp, obs)
def test2_add_games_from_api(self): self_games = [] for game in SELF_GAMES: self_games.append(Game( name=game, game_id=int(SELF_GAMES[game]), )) api_games = [] for game in API_GAMES: api_games.append(Game( name=game, game_id=int(API_GAMES[game]), )) err_msg = "" api_mock = MagicMock() api_mock.get_library.return_value = api_games, err_msg test_library = Library(MagicMock(), api_mock) test_library.games = self_games test_library._Library__add_games_from_api() exp = True obs = Game( name="Stellaris (English)", game_id=1508702879, ) in test_library.games self.assertEqual(exp, obs)
def test1_add_games_from_api(self): self_games = [] for game in SELF_GAMES: self_games.append(Game(name=game, game_id=int(SELF_GAMES[game]),)) api_games = [] for game in API_GAMES: api_games.append(Game(name=game, game_id=int(API_GAMES[game]),)) api_mock = MagicMock() api_mock.get_library.return_value = api_games test_library = Library(MagicMock(), api_mock) test_library.games = self_games test_library._Library__add_games_from_api() exp = len(API_GAMES) obs = len(test_library.games) self.assertEqual(exp, obs)
def test6_add_games_from_api(self): self_games = [ Game(name="Torchlight 2", game_id=0, install_dir="/home/user/GoG Games/Torchlight II") ] api_games = [Game(name="Torchlight II", game_id=1958228073)] err_msg = "" api_mock = MagicMock() api_mock.get_library.return_value = api_games, err_msg test_library = Library(MagicMock(), api_mock) test_library.games = self_games test_library._Library__add_games_from_api() exp = 1 obs = len(test_library.games) self.assertEqual(exp, obs)
def test4_add_games_from_api(self): self_games = [] for game in SELF_GAMES: self_games.append(Game(name=game, game_id=int(SELF_GAMES[game]),)) api_games = [] url_nr = 1 for game in API_GAMES: api_games.append(Game(name=game, game_id=int(API_GAMES[game]), url="http://test_url{}".format(str(url_nr)))) url_nr += 1 api_mock = MagicMock() api_mock.get_library.return_value = api_games test_library = Library(MagicMock(), api_mock) test_library.games = self_games test_library._Library__add_games_from_api() exp = "http://test_url1" obs = test_library.games[0].url self.assertEqual(exp, obs)
def test5_add_games_from_api(self): self_games = [] for game in SELF_GAMES: self_games.append( Game( name="{}_diff".format(game), game_id=int(SELF_GAMES[game]), )) api_games = [] for game in API_GAMES: api_games.append(Game(name=game, game_id=int(API_GAMES[game]))) err_msg = "" api_mock = MagicMock() api_mock.get_library.return_value = api_games, err_msg test_library = Library(MagicMock(), api_mock) test_library.games = self_games test_library._Library__add_games_from_api() exp = "Neverwinter Nights: Enhanced Edition" obs = test_library.games[0].name self.assertEqual(exp, obs)