diff --git a/sportsreference/fb/roster.py b/sportsreference/fb/roster.py index 25037304..59fad99c 100644 --- a/sportsreference/fb/roster.py +++ b/sportsreference/fb/roster.py @@ -173,6 +173,18 @@ def __init__(self, player_data, player_id): self._parse_player_stats(player_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.player_id})' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _parse_nationality(self, player_data): """ Parse the player's nationality. @@ -1518,23 +1530,30 @@ def __call__(self, player): return player_instance raise ValueError('No player found with the requested name or ID') + def __str__(self): + """ + Return the string representation of the class. + """ + players = [f'{x.name} ({x.player_id})'.strip() for x in self._players] + return '\n'.join(players) + def __repr__(self): """ - Returns a ``list`` of all players for the given team. + Return the string representation of the class. """ - return self._players + return self.__str__() def __iter__(self): """ Returns an iterator of all of the players on the given team's roster. """ - return iter(self.__repr__()) + return iter(self._players) def __len__(self): """ Returns the number of player on the given team's roster. """ - return len(self.__repr__()) + return len(self._players) def _player_id(self, player_data): """ diff --git a/sportsreference/fb/schedule.py b/sportsreference/fb/schedule.py index 01a3cea0..02d26d70 100644 --- a/sportsreference/fb/schedule.py +++ b/sportsreference/fb/schedule.py @@ -52,6 +52,18 @@ def __init__(self, game_data): self._parse_game_data(game_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.date} - {self.opponent}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _parse_opponent_id(self, game_data): """ Parse the opponent's squad ID. @@ -532,23 +544,31 @@ def __call__(self, date): return game raise ValueError('No games found for requested date') + def __str__(self): + """ + Return the string representation of the class. + """ + games = [f'{game.date} - {game.opponent}'.strip() + for game in self._games] + return '\n'.join(games) + def __repr__(self): """ - Returns a ``list`` of all games scheduled for the given team. + Return the string representation of the class. """ - return self._games + return self.__str__() def __iter__(self): """ Returns an iterator of all of the games scheduled for the given team. """ - return iter(self.__repr__()) + return iter(self._games) def __len__(self): """ Returns the number of scheduled games for the given team. """ - return len(self.__repr__()) + return len(self._games) def _add_games_to_schedule(self, schedule): """ diff --git a/sportsreference/fb/team.py b/sportsreference/fb/team.py index a14c7c53..304f6e49 100644 --- a/sportsreference/fb/team.py +++ b/sportsreference/fb/team.py @@ -64,6 +64,18 @@ def __init__(self, team_id): self._squad_id = _lookup_team(team_id) self._pull_team_page() + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.squad_id}) - {self.season}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _parse_name(self, doc): """ Parse the team's name and season. diff --git a/sportsreference/mlb/boxscore.py b/sportsreference/mlb/boxscore.py index 872e4993..a3b2f280 100644 --- a/sportsreference/mlb/boxscore.py +++ b/sportsreference/mlb/boxscore.py @@ -433,6 +433,19 @@ def __init__(self, uri): self._parse_game_data(uri) + def __str__(self): + """ + Return the string representation of the class. + """ + return (f'Boxscore for {self._away_name.text()} at ' + f'{self._home_name.text()} ({self.date})') + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_html_page(self, uri): """ Download the requested HTML page. @@ -1629,6 +1642,18 @@ def __init__(self, date, end_date=None): self._find_games(date, end_date) + def __str__(self): + """ + Return the string representation of the class. + """ + return f"MLB games for {', '.join(self._boxscores.keys())}" + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + @property def games(self): """ diff --git a/sportsreference/mlb/roster.py b/sportsreference/mlb/roster.py index 6421f422..a9ec533f 100644 --- a/sportsreference/mlb/roster.py +++ b/sportsreference/mlb/roster.py @@ -203,6 +203,18 @@ def __init__(self, player_id): self._find_initial_index() AbstractPlayer.__init__(self, player_id, self._name, player_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.player_id})' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _build_url(self): """ Create the player's URL to pull stats from. @@ -1445,6 +1457,20 @@ def __init__(self, team, year=None, slim=False): self._find_players(year) + def __str__(self): + """ + Return the string representation of the class. + """ + players = [f'{player.name} ({player.player_id})'.strip() + for player in self._players] + return '\n'.join(players) + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _pull_team_page(self, url): """ Download the team page. diff --git a/sportsreference/mlb/schedule.py b/sportsreference/mlb/schedule.py index cb20c47f..4c216206 100644 --- a/sportsreference/mlb/schedule.py +++ b/sportsreference/mlb/schedule.py @@ -57,6 +57,18 @@ def __init__(self, game_data, year): self._parse_game_data(game_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.date} - {self.opponent_abbr}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _parse_boxscore(self, game_data): """ Parses the boxscore URI for the game. @@ -429,19 +441,29 @@ def __call__(self, date, game_number=1): return game raise ValueError('No games found for requested date') + def __str__(self): + """ + Return the string representation of the class. + """ + games = [f'{game.date} - {game.opponent_abbr}'.strip() + for game in self._games] + return '\n'.join(games) + def __repr__(self): - """Returns a ``list`` of all games scheduled for the given team.""" - return self._games + """ + Return the string representation of the class. + """ + return self.__str__() def __iter__(self): """ Returns an iterator of all of the games scheduled for the given team. """ - return iter(self.__repr__()) + return iter(self._games) def __len__(self): """Returns the number of scheduled games for the given team.""" - return len(self.__repr__()) + return len(self._games) def _pull_schedule(self, abbreviation, year): """ diff --git a/sportsreference/mlb/teams.py b/sportsreference/mlb/teams.py index 23fcae8c..638fb5cf 100644 --- a/sportsreference/mlb/teams.py +++ b/sportsreference/mlb/teams.py @@ -146,6 +146,18 @@ def __init__(self, team_name=None, team_data=None, rank=None, year=None): self._parse_team_data(team_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.abbreviation}) - {self._year}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_team_data(self, year, team_name): """ Pull all stats for a specific team. @@ -1198,6 +1210,20 @@ def __init__(self, year=None): team_data_dict, year = _retrieve_all_teams(year) self._instantiate_teams(team_data_dict, year) + def __str__(self): + """ + Return the string representation of the class. + """ + teams = [f'{team.name} ({team.abbreviation})'.strip() + for team in self._teams] + return '\n'.join(teams) + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def __getitem__(self, abbreviation): """ Return a specified team. @@ -1246,17 +1272,13 @@ def __call__(self, abbreviation): """ return self.__getitem__(abbreviation) - def __repr__(self): - """Returns a ``list`` of all MLB teams for the given season.""" - return self._teams - def __iter__(self): """Returns an iterator of all of the MLB teams for a given season.""" - return iter(self.__repr__()) + return iter(self._teams) def __len__(self): """Returns the number of MLB teams for a given season.""" - return len(self.__repr__()) + return len(self._teams) def _instantiate_teams(self, team_data_dict, year): """ diff --git a/sportsreference/nba/boxscore.py b/sportsreference/nba/boxscore.py index b6f54532..0abf000e 100644 --- a/sportsreference/nba/boxscore.py +++ b/sportsreference/nba/boxscore.py @@ -279,6 +279,19 @@ def __init__(self, uri): self._parse_game_data(uri) + def __str__(self): + """ + Return the string representation of the class. + """ + return (f'Boxscore for {self._away_name.text()} at ' + f'{self._home_name.text()} ({self.date})') + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_html_page(self, uri): """ Download the requested HTML page. @@ -1536,6 +1549,18 @@ def __init__(self, date, end_date=None): self._find_games(date, end_date) + def __str__(self): + """ + Return the string representation of the class. + """ + return f"NBA games for {', '.join(self._boxscores.keys())}" + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + @property def games(self): """ diff --git a/sportsreference/nba/roster.py b/sportsreference/nba/roster.py index 7fdc9121..0fad5584 100644 --- a/sportsreference/nba/roster.py +++ b/sportsreference/nba/roster.py @@ -191,6 +191,18 @@ def __init__(self, player_id): self._find_initial_index() AbstractPlayer.__init__(self, player_id, self._name, player_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.player_id})' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _build_url(self): """ Create the player's URL to pull stats from. @@ -1379,6 +1391,20 @@ def __init__(self, team, year=None, slim=False): self._find_players(year) + def __str__(self): + """ + Return the string representation of the class. + """ + players = [f'{player.name} ({player.player_id})'.strip() + for player in self._players] + return '\n'.join(players) + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _pull_team_page(self, url): """ Download the team page. diff --git a/sportsreference/nba/schedule.py b/sportsreference/nba/schedule.py index d9f2a71a..39e3a02d 100644 --- a/sportsreference/nba/schedule.py +++ b/sportsreference/nba/schedule.py @@ -47,6 +47,18 @@ def __init__(self, game_data, playoffs=False): self._parse_game_data(game_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.date} - {self.opponent_abbr}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _parse_boxscore(self, game_data): """ Parses the boxscore URI for the game. @@ -353,19 +365,29 @@ def __call__(self, date): return game raise ValueError('No games found for requested date') + def __str__(self): + """ + Return the string representation of the class. + """ + games = [f'{game.date} - {game.opponent_abbr}'.strip() + for game in self._games] + return '\n'.join(games) + def __repr__(self): - """Returns a ``list`` of all games scheduled for the given team.""" - return self._games + """ + Return the string representation of the class. + """ + return self.__str__() def __iter__(self): """ Returns an iterator of all of the games scheduled for the given team. """ - return iter(self.__repr__()) + return iter(self._games) def __len__(self): """Returns the number of scheduled games for the given team.""" - return len(self.__repr__()) + return len(self._games) def _add_games_to_schedule(self, schedule, playoff=False): """ diff --git a/sportsreference/nba/teams.py b/sportsreference/nba/teams.py index ac6bbfe9..3d6702e8 100644 --- a/sportsreference/nba/teams.py +++ b/sportsreference/nba/teams.py @@ -88,6 +88,18 @@ def __init__(self, team_name=None, team_data=None, rank=None, year=None): team_data = self._retrieve_team_data(year, team_name) self._parse_team_data(team_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.abbreviation}) - {self._year}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_team_data(self, year, team_name): """ Pull all stats for a specific team. @@ -675,17 +687,27 @@ def __call__(self, abbreviation): """ return self.__getitem__(abbreviation) + def __str__(self): + """ + Return the string representation of the class. + """ + teams = [f'{team.name} ({team.abbreviation})'.strip() + for team in self._teams] + return '\n'.join(teams) + def __repr__(self): - """Returns a ``list`` of all NBA teams for the given season.""" - return self._teams + """ + Return the string representation of the class. + """ + return self.__str__() def __iter__(self): """Returns an iterator of all of the NBA teams for a given season.""" - return iter(self.__repr__()) + return iter(self._teams) def __len__(self): """Returns the number of NBA teams for a given season.""" - return len(self.__repr__()) + return len(self._teams) def _instantiate_teams(self, team_data_dict, year): """ diff --git a/sportsreference/ncaab/boxscore.py b/sportsreference/ncaab/boxscore.py index 36761f85..08921d41 100644 --- a/sportsreference/ncaab/boxscore.py +++ b/sportsreference/ncaab/boxscore.py @@ -224,6 +224,19 @@ def __init__(self, uri): self._parse_game_data(uri) + def __str__(self): + """ + Return the string representation of the class. + """ + return (f'Boxscore for {self._away_name.text()} at ' + f'{self._home_name.text()} ({self.date})') + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_html_page(self, uri): """ Download the requested HTML page. @@ -1590,6 +1603,18 @@ def __init__(self, date, end_date=None): self._find_games(date, end_date) + def __str__(self): + """ + Return the string representation of the class. + """ + return f"NCAAB games for {', '.join(self._boxscores.keys())}" + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + @property def games(self): """ diff --git a/sportsreference/ncaab/roster.py b/sportsreference/ncaab/roster.py index 37857f05..aa8b55a4 100644 --- a/sportsreference/ncaab/roster.py +++ b/sportsreference/ncaab/roster.py @@ -118,6 +118,18 @@ def __init__(self, player_id): self._find_initial_index() AbstractPlayer.__init__(self, player_id, self._name, player_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.player_id})' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_html_page(self): """ Download the requested player's stats page. @@ -651,6 +663,20 @@ def __init__(self, team, year=None, slim=False): self._find_players(year) + def __str__(self): + """ + Return the string representation of the class. + """ + players = [f'{player.name} ({player.player_id})'.strip() + for player in self._players] + return '\n'.join(players) + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _pull_team_page(self, url): """ Download the team page. diff --git a/sportsreference/ncaab/schedule.py b/sportsreference/ncaab/schedule.py index ae528b3d..9890736d 100644 --- a/sportsreference/ncaab/schedule.py +++ b/sportsreference/ncaab/schedule.py @@ -56,6 +56,18 @@ def __init__(self, game_data): self._parse_game_data(game_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.date} - {self.opponent_abbr}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _parse_abbreviation(self, game_data): """ Parses the opponent's abbreviation from their name. @@ -458,19 +470,29 @@ def __call__(self, date): return game raise ValueError('No games found for requested date') + def __str__(self): + """ + Return the string representation of the class. + """ + games = [f'{game.date} - {game.opponent_abbr}'.strip() + for game in self._games] + return '\n'.join(games) + def __repr__(self): - """Returns a ``list`` of all games scheduled for the given team.""" - return self._games + """ + Return the string representation of the class. + """ + return self.__str__() def __iter__(self): """ Returns an iterator of all of the games scheduled for the given team. """ - return iter(self.__repr__()) + return iter(self._games) def __len__(self): """Returns the number of scheduled games for the given team.""" - return len(self.__repr__()) + return len(self._games) def _pull_schedule(self, abbreviation, year): """ diff --git a/sportsreference/ncaab/teams.py b/sportsreference/ncaab/teams.py index fa0576c1..599a8d02 100644 --- a/sportsreference/ncaab/teams.py +++ b/sportsreference/ncaab/teams.py @@ -126,6 +126,18 @@ def __init__(self, team_name=None, team_data=None, team_conference=None, self._team_conference = conferences_dict[team_name.lower()] self._parse_team_data(team_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.abbreviation}) - {self._year}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_team_data(self, year, team_name): """ Pull all stats for a specific team. @@ -1080,17 +1092,27 @@ def __call__(self, abbreviation): """ return self.__getitem__(abbreviation) + def __str__(self): + """ + Return the string representation of the class. + """ + teams = [f'{team.name} ({team.abbreviation})'.strip() + for team in self._teams] + return '\n'.join(teams) + def __repr__(self): - """Returns a ``list`` of all NCAAB teams for the given season.""" - return self._teams + """ + Return the string representation of the class. + """ + return self.__str__() def __iter__(self): """Returns an iterator of all of the NCAAB teams for a given season.""" - return iter(self.__repr__()) + return iter(self._teams) def __len__(self): """Returns the number of NCAAB teams for a given season.""" - return len(self.__repr__()) + return len(self._teams) def _instantiate_teams(self, team_data_dict, year): """ diff --git a/sportsreference/ncaaf/boxscore.py b/sportsreference/ncaaf/boxscore.py index 8f2c3897..363ea67d 100644 --- a/sportsreference/ncaaf/boxscore.py +++ b/sportsreference/ncaaf/boxscore.py @@ -346,6 +346,19 @@ def __init__(self, uri): self._parse_game_data(uri) + def __str__(self): + """ + Return the string representation of the class. + """ + return (f'Boxscore for {self._away_name.text()} at ' + f'{self._home_name.text()} ({self.date})') + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_html_page(self, uri): """ Download the requested HTML page. @@ -1175,6 +1188,18 @@ def __init__(self, date, end_date=None): self._find_games(date, end_date) + def __str__(self): + """ + Return the string representation of the class. + """ + return f"NCAAF games for {', '.join(self._boxscores.keys())}" + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + @property def games(self): """ diff --git a/sportsreference/ncaaf/roster.py b/sportsreference/ncaaf/roster.py index 546339c7..c6a6d40d 100644 --- a/sportsreference/ncaaf/roster.py +++ b/sportsreference/ncaaf/roster.py @@ -128,6 +128,18 @@ def __init__(self, player_id): self._find_initial_index() AbstractPlayer.__init__(self, player_id, self._name, player_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.player_id})' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _build_url(self): """ Create the player's URL to pull stats from. @@ -878,6 +890,20 @@ def __init__(self, team, year=None, slim=False): self._find_players(year) + def __str__(self): + """ + Return the string representation of the class. + """ + players = [f'{player.name} ({player.player_id})'.strip() + for player in self._players] + return '\n'.join(players) + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _pull_team_page(self, url): """ Download the team page. diff --git a/sportsreference/ncaaf/schedule.py b/sportsreference/ncaaf/schedule.py index 182c069e..7e386de2 100644 --- a/sportsreference/ncaaf/schedule.py +++ b/sportsreference/ncaaf/schedule.py @@ -50,6 +50,18 @@ def __init__(self, game_data): self._parse_game_data(game_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.date} - {self.opponent_abbr}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _parse_abbreviation(self, game_data): """ Parses the opponent's abbreviation from their name. @@ -404,19 +416,29 @@ def __call__(self, date): return game raise ValueError('No games found for requested date') + def __str__(self): + """ + Return the string representation of the class. + """ + games = [f'{game.date} - {game.opponent_abbr}'.strip() + for game in self._games] + return '\n'.join(games) + def __repr__(self): - """Returns a ``list`` of all games scheduled for the given team.""" - return self._games + """ + Return the string representation of the class. + """ + return self.__str__() def __iter__(self): """ Returns an iterator of all of the games scheduled for the given team. """ - return iter(self.__repr__()) + return iter(self._games) def __len__(self): """Returns the number of scheduled games for the given team.""" - return len(self.__repr__()) + return len(self._games) def _pull_schedule(self, abbreviation, year): """ diff --git a/sportsreference/ncaaf/teams.py b/sportsreference/ncaaf/teams.py index 348937af..0054a357 100644 --- a/sportsreference/ncaaf/teams.py +++ b/sportsreference/ncaaf/teams.py @@ -99,6 +99,18 @@ def __init__(self, team_name=None, team_data=None, team_conference=None, self._team_conference = conferences_dict[team_name.lower()] self._parse_team_data(team_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.abbreviation}) - {self._year}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_team_data(self, year, team_name): """ Pull all stats for a specific team. @@ -756,17 +768,27 @@ def __call__(self, abbreviation): """ return self.__getitem__(abbreviation) + def __str__(self): + """ + Return the string representation of the class. + """ + teams = [f'{team.name} ({team.abbreviation})'.strip() + for team in self._teams] + return '\n'.join(teams) + def __repr__(self): - """Returns a ``list`` of all NCAAF teams for the given season.""" - return self._teams + """ + Return the string representation of the class. + """ + return self.__str__() def __iter__(self): """Returns an iterator of all of the NCAAF teams for a given season.""" - return iter(self.__repr__()) + return iter(self._teams) def __len__(self): """Returns the number of NCAAF teams for a given season.""" - return len(self.__repr__()) + return len(self._teams) def _instantiate_teams(self, team_data_dict, year): """ diff --git a/sportsreference/nfl/boxscore.py b/sportsreference/nfl/boxscore.py index 81e8ea24..b26d7ad6 100644 --- a/sportsreference/nfl/boxscore.py +++ b/sportsreference/nfl/boxscore.py @@ -289,6 +289,19 @@ def __init__(self, uri): self._parse_game_data(uri) + def __str__(self): + """ + Return the string representation of the class. + """ + return (f'Boxscore for {self._away_name.text()} at ' + f'{self._home_name.text()} ({self.date})') + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_html_page(self, uri): """ Download the requested HTML page. @@ -1308,6 +1321,21 @@ def __init__(self, week, year, end_week=None): self._find_games(week, year, end_week) + def __str__(self): + """ + Return the string representation of the class. + """ + weeks = [week.split('-')[0] for week in sorted(self._boxscores.keys())] + if len(weeks) > 1: + return f"NFL games for weeks {', '.join(weeks)}" + return f"NFL games for week {weeks[0]}" + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + @property def games(self): """ diff --git a/sportsreference/nfl/roster.py b/sportsreference/nfl/roster.py index c348afa0..3253c337 100644 --- a/sportsreference/nfl/roster.py +++ b/sportsreference/nfl/roster.py @@ -229,6 +229,18 @@ def __init__(self, player_id): self._find_initial_index() AbstractPlayer.__init__(self, player_id, self._name, player_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.player_id})' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _build_url(self): """ Create the player's URL to pull stats from. @@ -1703,6 +1715,20 @@ def __init__(self, team, year=None, slim=False): self._find_players(year) + def __str__(self): + """ + Return the string representation of the class. + """ + players = [f'{player.name} ({player.player_id})'.strip() + for player in self._players] + return '\n'.join(players) + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _pull_team_page(self, url): """ Download the team page. diff --git a/sportsreference/nfl/schedule.py b/sportsreference/nfl/schedule.py index 1f6fb4ac..d6217f9a 100644 --- a/sportsreference/nfl/schedule.py +++ b/sportsreference/nfl/schedule.py @@ -85,6 +85,18 @@ def __init__(self, game_data, game_type, year): self._parse_game_data(game_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.date} - {self.opponent_abbr}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _parse_abbreviation(self, game_data): """ Parses the opponent's abbreviation from their name. @@ -619,19 +631,29 @@ def __call__(self, date): return game raise ValueError('No games found for requested date') + def __str__(self): + """ + Return the string representation of the class. + """ + games = [f'{game.date} - {game.opponent_abbr}'.strip() + for game in self._games] + return '\n'.join(games) + def __repr__(self): - """Returns a ``list`` of all games scheduled for the given team.""" - return self._games + """ + Return the string representation of the class. + """ + return self.__str__() def __iter__(self): """ Returns an iterator of all of the games scheduled for the given team. """ - return iter(self.__repr__()) + return iter(self._games) def __len__(self): """Returns the number of scheduled games for the given team.""" - return len(self.__repr__()) + return len(self._games) def _add_games_to_schedule(self, schedule, game_type, year): """ diff --git a/sportsreference/nfl/teams.py b/sportsreference/nfl/teams.py index e862479f..652a13ba 100644 --- a/sportsreference/nfl/teams.py +++ b/sportsreference/nfl/teams.py @@ -89,6 +89,18 @@ def __init__(self, team_name=None, team_data=None, rank=None, year=None): team_data = self._retrieve_team_data(year, team_name) self._parse_team_data(team_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.abbreviation}) - {self._year}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_team_data(self, year, team_name): """ Pull all stats for a specific team. @@ -621,17 +633,27 @@ def __call__(self, abbreviation): """ return self.__getitem__(abbreviation) + def __str__(self): + """ + Return the string representation of the class. + """ + teams = [f'{team.name} ({team.abbreviation})'.strip() + for team in self._teams] + return '\n'.join(teams) + def __repr__(self): - """Returns a ``list`` of all NFL teams for the given season.""" - return self._teams + """ + Return the string representation of the class. + """ + return self.__str__() def __iter__(self): """Returns an iterator of all of the NFL teams for a given season.""" - return iter(self.__repr__()) + return iter(self._teams) def __len__(self): """Returns the number of NFL teams for a given season.""" - return len(self.__repr__()) + return len(self._teams) def _instantiate_teams(self, team_data_dict, year): """ diff --git a/sportsreference/nhl/boxscore.py b/sportsreference/nhl/boxscore.py index cab64208..e4fb2e16 100644 --- a/sportsreference/nhl/boxscore.py +++ b/sportsreference/nhl/boxscore.py @@ -275,6 +275,19 @@ def __init__(self, uri): self._parse_game_data(uri) + def __str__(self): + """ + Return the string representation of the class. + """ + return (f'Boxscore for {self._away_name.text()} at ' + f'{self._home_name.text()} ({self.date})') + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_html_page(self, uri): """ Download the requested HTML page. @@ -1110,6 +1123,18 @@ def __init__(self, date, end_date=None): self._find_games(date, end_date) + def __str__(self): + """ + Return the string representation of the class. + """ + return f"NHL games for {', '.join(self._boxscores.keys())}" + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + @property def games(self): """ diff --git a/sportsreference/nhl/roster.py b/sportsreference/nhl/roster.py index 9c7a4986..36d98446 100644 --- a/sportsreference/nhl/roster.py +++ b/sportsreference/nhl/roster.py @@ -164,6 +164,18 @@ def __init__(self, player_id): self._find_initial_index() AbstractPlayer.__init__(self, player_id, self._name, player_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.player_id})' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _build_url(self): """ Create the player's URL to pull stats from. @@ -1100,6 +1112,20 @@ def __init__(self, team, year=None, slim=False): self._find_players(year) + def __str__(self): + """ + Return the string representation of the class. + """ + players = [f'{player.name} ({player.player_id})'.strip() + for player in self._players] + return '\n'.join(players) + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _pull_team_page(self, url): """ Download the team page. diff --git a/sportsreference/nhl/schedule.py b/sportsreference/nhl/schedule.py index 2e49b07c..e8d6af48 100644 --- a/sportsreference/nhl/schedule.py +++ b/sportsreference/nhl/schedule.py @@ -66,6 +66,18 @@ def __init__(self, game_data, year): self._parse_game_data(game_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.date} - {self.opponent_abbr}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _parse_abbreviation(self, game_data): """ Parses the opponent's abbreviation from their name. @@ -543,19 +555,29 @@ def __call__(self, date): return game raise ValueError('No games found for requested date') + def __str__(self): + """ + Return the string representation of the class. + """ + games = [f'{game.date} - {game.opponent_abbr}'.strip() + for game in self._games] + return '\n'.join(games) + def __repr__(self): - """Returns a ``list`` of all games scheduled for the given team.""" - return self._games + """ + Return the string representation of the class. + """ + return self.__str__() def __iter__(self): """ Returns an iterator of all of the games scheduled for the given team. """ - return iter(self.__repr__()) + return iter(self._games) def __len__(self): """Returns the number of scheduled games for the given team.""" - return len(self.__repr__()) + return len(self._games) def _pull_schedule(self, abbreviation, year): """ diff --git a/sportsreference/nhl/teams.py b/sportsreference/nhl/teams.py index 7b12fe5c..50c45127 100644 --- a/sportsreference/nhl/teams.py +++ b/sportsreference/nhl/teams.py @@ -71,6 +71,18 @@ def __init__(self, team_name=None, team_data=None, rank=None, year=None): team_data = self._retrieve_team_data(year, team_name) self._parse_team_data(team_data) + def __str__(self): + """ + Return the string representation of the class. + """ + return f'{self.name} ({self.abbreviation}) - {self._year}' + + def __repr__(self): + """ + Return the string representation of the class. + """ + return self.__str__() + def _retrieve_team_data(self, year, team_name): """ Pull all stats for a specific team. @@ -481,17 +493,27 @@ def __call__(self, abbreviation): """ return self.__getitem__(abbreviation) + def __str__(self): + """ + Return the string representation of the class. + """ + teams = [f'{team.name} ({team.abbreviation})'.strip() + for team in self._teams] + return '\n'.join(teams) + def __repr__(self): - """Returns a ``list`` of all NHL teams for the given season.""" - return self._teams + """ + Return the string representation of the class. + """ + return self.__str__() def __iter__(self): """Returns an iterator of all of the NHL teams for a given season.""" - return iter(self.__repr__()) + return iter(self._teams) def __len__(self): """Returns the number of NHL teams for a given season.""" - return len(self.__repr__()) + return len(self._teams) def _instantiate_teams(self, teams_list, year): """ diff --git a/tests/integration/boxscore/test_mlb_boxscore.py b/tests/integration/boxscore/test_mlb_boxscore.py index 71a48f0b..c2583096 100644 --- a/tests/integration/boxscore/test_mlb_boxscore.py +++ b/tests/integration/boxscore/test_mlb_boxscore.py @@ -181,6 +181,14 @@ def test_mlb_boxscore_player(self): for player in boxscore.away_players: assert not player.dataframe.empty + def test_mlb_boxscore_string_representation(self): + expected = ('Boxscore for Detroit Tigers at Boston Red Sox (Thursday, ' + 'June 7, 2018)') + + boxscore = Boxscore(BOXSCORE) + + assert boxscore.__repr__() == expected + class TestMLBBoxscores: def setup_method(self): @@ -663,3 +671,9 @@ def test_boxscores_search_multiple_days(self, *args, **kwargs): result = Boxscores(datetime(2017, 7, 17), datetime(2017, 7, 18)).games assert result == expected + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_boxscores_search_string_representation(self, *args, **kwargs): + result = Boxscores(datetime(2017, 7, 17)) + + assert result.__repr__() == 'MLB games for 7-17-2017' diff --git a/tests/integration/boxscore/test_nba_boxscore.py b/tests/integration/boxscore/test_nba_boxscore.py index ede11228..c79cd7af 100644 --- a/tests/integration/boxscore/test_nba_boxscore.py +++ b/tests/integration/boxscore/test_nba_boxscore.py @@ -177,6 +177,14 @@ def test_nba_boxscore_players(self): for player in self.boxscore.away_players: assert not player.dataframe.empty + def test_nba_boxscore_string_representation(self): + expected = ('Boxscore for Detroit Pistons at Los Angeles Lakers ' + '(10:30 PM, October 31, 2017)') + + boxscore = Boxscore(BOXSCORE) + + assert boxscore.__repr__() == expected + class TestNBABoxscores: def setup_method(self): @@ -461,3 +469,9 @@ def test_boxscores_search_multiple_days(self, *args, **kwargs): result = Boxscores(datetime(2017, 2, 4), datetime(2017, 2, 5)).games assert result == expected + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_boxscores_search_string_representation(self, *args, **kwargs): + result = Boxscores(datetime(2017, 2, 4)) + + assert result.__repr__() == 'NBA games for 2-4-2017' diff --git a/tests/integration/boxscore/test_ncaab_boxscore.py b/tests/integration/boxscore/test_ncaab_boxscore.py index 6fc36bb5..0c8ee058 100644 --- a/tests/integration/boxscore/test_ncaab_boxscore.py +++ b/tests/integration/boxscore/test_ncaab_boxscore.py @@ -186,6 +186,13 @@ def test_ncaab_boxscore_players(self): for player in boxscore.away_players: assert not player.dataframe.empty + def test_ncaab_boxscore_string_representation(self): + expected = ('Boxscore for Arizona at Purdue (November 24, 2017)') + + boxscore = Boxscore(BOXSCORE) + + assert boxscore.__repr__() == expected + class TestNCAABBoxscores: def setup_method(self): @@ -2135,3 +2142,9 @@ def test_boxscores_search_multiple_days(self, *args, **kwargs): 'losing_abbr': 'pacific'} ] } + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_boxscores_search_string_representation(self, *args, **kwargs): + result = Boxscores(datetime(2017, 11, 11)) + + assert result.__repr__() == 'NCAAB games for 11-11-2017' diff --git a/tests/integration/boxscore/test_ncaaf_boxscore.py b/tests/integration/boxscore/test_ncaaf_boxscore.py index d5bd2d43..d2ee68a3 100644 --- a/tests/integration/boxscore/test_ncaaf_boxscore.py +++ b/tests/integration/boxscore/test_ncaaf_boxscore.py @@ -137,6 +137,13 @@ def test_ncaaf_boxscore_players(self): for player in boxscore.away_players: assert not player.dataframe.empty + def test_ncaaf_boxscore_string_representation(self): + expected = ('Boxscore for Alabama at Georgia (Monday Jan 8, 2018)') + + boxscore = Boxscore(BOXSCORE) + + assert boxscore.__repr__() == expected + class TestNCAAFBoxscores: def setup_method(self): @@ -4038,3 +4045,9 @@ def test_boxscores_search_multiple_days(self, *args, **kwargs): result = Boxscores(datetime(2017, 8, 30), datetime(2017, 8, 31)).games assert result == expected + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_boxscores_search_string_representation(self, *args, **kwargs): + result = Boxscores(datetime(2017, 8, 30)) + + assert result.__repr__() == 'NCAAF games for 8-30-2017' diff --git a/tests/integration/boxscore/test_nfl_boxscore.py b/tests/integration/boxscore/test_nfl_boxscore.py index d804d018..15fef599 100644 --- a/tests/integration/boxscore/test_nfl_boxscore.py +++ b/tests/integration/boxscore/test_nfl_boxscore.py @@ -156,6 +156,14 @@ def test_nfl_boxscore_players(self): for player in boxscore.away_players: assert not player.dataframe.empty + def test_nfl_boxscore_string_representation(self): + expected = ('Boxscore for Philadelphia Eagles at New England Patriots ' + '(Sunday Feb 4, 2018)') + + boxscore = Boxscore(BOXSCORE) + + assert boxscore.__repr__() == expected + class TestNFLBoxscores: def setup_method(self): @@ -660,3 +668,16 @@ def test_boxscores_search_multiple_weeks(self, *args, **kwargs): result = Boxscores(7, 2017, 8).games assert result == expected + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_boxscores_search_string_representation(self, *args, **kwargs): + result = Boxscores(7, 2017) + + assert result.__repr__() == 'NFL games for week 7' + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_boxscores_search_string_representation_multi_week(self, *args, + **kwargs): + result = Boxscores(7, 2017, 8) + + assert result.__repr__() == 'NFL games for weeks 7, 8' diff --git a/tests/integration/boxscore/test_nhl_boxscore.py b/tests/integration/boxscore/test_nhl_boxscore.py index c74aee58..5ea06bb9 100644 --- a/tests/integration/boxscore/test_nhl_boxscore.py +++ b/tests/integration/boxscore/test_nhl_boxscore.py @@ -136,6 +136,14 @@ def test_nhl_boxscore_player(self): for player in boxscore.away_players: assert not player.dataframe.empty + def test_nhl_boxscore_string_representation(self): + expected = ('Boxscore for Washington Capitals at Vegas Golden Knights ' + '(June 7, 2018)') + + boxscore = Boxscore(BOXSCORE) + + assert boxscore.__repr__() == expected + class TestNHLBoxscores: def setup_method(self): @@ -486,3 +494,9 @@ def test_boxscores_search_multiple_days(self, *args, **kwargs): result = Boxscores(datetime(2017, 2, 4), datetime(2017, 2, 5)).games assert result == expected + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_boxscores_search_string_representation(self, *args, **kwargs): + result = Boxscores(datetime(2017, 2, 4)) + + assert result.__repr__() == 'NHL games for 2-4-2017' diff --git a/tests/integration/roster/test_fb_roster.py b/tests/integration/roster/test_fb_roster.py index fe3b7f48..7ed23113 100644 --- a/tests/integration/roster/test_fb_roster.py +++ b/tests/integration/roster/test_fb_roster.py @@ -342,3 +342,46 @@ def test_fb_roster_dataframe_returns_dataframe(self): df1 = pd.concat(frames).drop_duplicates(keep=False) assert df1.empty + + def test_fb_roster_string_representation(self): + expected = """Toby Alderweireld (f7d50789) +Davinson Sánchez (da7b447d) +Serge Aurier (5c2b4f07) +Dele Alli (cea4ee8f) +Lucas Moura (2b622f01) +Son Heung-min (92e7e919) +Harry Winks (2f7acede) +Paulo Gazzaniga (63d17038) +Harry Kane (21a66f6a) +Jan Vertonghen (ba23a904) +Moussa Sissoko (2acd49b9) +Eric Dier (ac861941) +Christian Eriksen (980522ec) +Hugo Lloris (8f62b6ee) +Giovani Lo Celso (d7553721) +Érik Lamela (abe66106) +Tanguy Ndombele (5cdddffa) +Danny Rose (89d10e53) +Ben Davies (44781702) +Japhet Tanganga (e9971f2d) +Ryan Sessegnon (6aa3e78b) +Steven Bergwijn (a29b1131) +Kyle Walker-Peters (984a5a64) +Oliver Skipp (6250083a) +Gedson Fernandes (e2dde94c) +Juan Foyth (6c7762c3) +Victor Wanyama (e0900238) +Michel Vorm (1bebde9d) +Troy Parrott (4357f557) +Georges-Kévin N'Koudou (76c131da) +Malachi Fagan-Walcott (8263d615) +Brandon Austin (5e253986) +Alfie Whiteman (3f2587ee) +Dennis Cirken (307ea3b6)""" + + assert self.roster.__repr__() == expected + + def test_fb_player_string_representation(self): + player = self.roster('Harry Kane') + + assert player.__repr__() == 'Harry Kane (21a66f6a)' diff --git a/tests/integration/roster/test_mlb_roster.py b/tests/integration/roster/test_mlb_roster.py index ac31a31b..b5515a89 100644 --- a/tests/integration/roster/test_mlb_roster.py +++ b/tests/integration/roster/test_mlb_roster.py @@ -575,6 +575,12 @@ def test_player_contract_returns_contract(self): assert contract == expected + def test_mlb_player_string_representation(self): + # Request the career stats + player = self.player('') + + assert player.__repr__() == 'José Altuve (altuvjo01)' + class TestMLBPitcher: @mock.patch('requests.get', side_effect=mock_pyquery) @@ -1232,3 +1238,16 @@ def test_mlb_invalid_default_year_reverts_to_previous_year(self, for player in roster.players: assert player.name in [u'José Altuve', 'Justin Verlander', 'Charlie Morton'] + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_roster_class_string_representation(self, *args, **kwargs): + expected = """José Altuve (altuvjo01) +Justin Verlander (verlaju01) +José Altuve (mortoch02)""" + + flexmock(utils) \ + .should_receive('_find_year_for_season') \ + .and_return('2018') + roster = Roster('HOU') + + assert roster.__repr__() == expected diff --git a/tests/integration/roster/test_nba_roster.py b/tests/integration/roster/test_nba_roster.py index eb8a9e05..de2a227c 100644 --- a/tests/integration/roster/test_nba_roster.py +++ b/tests/integration/roster/test_nba_roster.py @@ -1225,6 +1225,12 @@ def test_nba_player_with_no_stats_handled_without_error(self): assert player.name == 'Trae Young' + def test_nba_player_string_representation(self): + # Request the career stats + player = self.player('') + + assert player.__repr__() == 'James Harden (hardeja01)' + class TestNBARoster: @mock.patch('requests.get', side_effect=mock_pyquery) @@ -1306,3 +1312,17 @@ def test_empty_rows_are_skipped(self, *args, **kwargs): roster = Roster('HOU') assert len(roster.players) == 0 + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_roster_class_string_representation(self, *args, **kwargs): + expected = """Ryan Anderson (anderry01) +Trevor Ariza (arizatr01) +Tarik Black (blackta01) +James Harden (hardeja01)""" + + flexmock(utils) \ + .should_receive('_find_year_for_season') \ + .and_return('2018') + roster = Roster('HOU') + + assert roster.__repr__() == expected diff --git a/tests/integration/roster/test_ncaab_roster.py b/tests/integration/roster/test_ncaab_roster.py index 16e974c1..7e849838 100644 --- a/tests/integration/roster/test_ncaab_roster.py +++ b/tests/integration/roster/test_ncaab_roster.py @@ -360,6 +360,12 @@ def test_dataframe_returns_dataframe(self): frames = [df, player.dataframe] df1 = pd.concat(frames).drop_duplicates(keep=False) + def test_ncaab_player_string_representation(self): + # Request the career stats + player = self.player('') + + assert player.__repr__() == 'Carsen Edwards (carsen-edwards-1)' + class TestNCAABRoster: @mock.patch('requests.get', side_effect=mock_pyquery) @@ -426,3 +432,16 @@ def test_invalid_default_year_reverts_to_previous_year(self, for player in roster.players: assert player.name in ['Carsen Edwards', 'Isaac Haas', 'Vince Edwards'] + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_roster_class_string_representation(self, *args, **kwargs): + expected = """Carsen Edwards (carsen-edwards-1) +Isaac Haas (isaac-haas-1) +Vince Edwards (vince-edwards-2)""" + + flexmock(utils) \ + .should_receive('_find_year_for_season') \ + .and_return('2018') + roster = Roster('PURDUE') + + assert roster.__repr__() == expected diff --git a/tests/integration/roster/test_ncaaf_roster.py b/tests/integration/roster/test_ncaaf_roster.py index d2171328..dfaddf67 100644 --- a/tests/integration/roster/test_ncaaf_roster.py +++ b/tests/integration/roster/test_ncaaf_roster.py @@ -491,6 +491,12 @@ def test_ncaaf_404_returns_none_for_different_season(self): assert player.name is None assert player.dataframe is None + def test_ncaaf_player_string_representation(self): + # Request the career stats + player = self.player('') + + assert player.__repr__() == 'David Blough (david-blough-1)' + class TestNCAAFRoster: @mock.patch('requests.get', side_effect=mock_pyquery) @@ -552,3 +558,15 @@ def test_invalid_default_year_reverts_to_previous_year(self, assert len(roster.players) == 2 for player in roster.players: assert player.name in ['David Blough', 'Rondale Moore'] + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_roster_class_string_representation(self, *args, **kwargs): + expected = """David Blough (david-blough-1) +David Blough (rondale-moore-1)""" + + flexmock(utils) \ + .should_receive('_find_year_for_season') \ + .and_return('2018') + roster = Roster('PURDUE') + + assert roster.__repr__() == expected diff --git a/tests/integration/roster/test_nfl_roster.py b/tests/integration/roster/test_nfl_roster.py index c900e167..ce931b45 100644 --- a/tests/integration/roster/test_nfl_roster.py +++ b/tests/integration/roster/test_nfl_roster.py @@ -1404,6 +1404,12 @@ def test_nfl_player_with_no_career_stats_handled_properly(self, assert player.name == 'Dominique Hatfield' + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_nfl_player_string_representation(self, *args, **kwargs): + player = Player('BreeDr00') + + assert player.__repr__() == 'Drew Brees (BreeDr00)' + class TestNFLRoster: @mock.patch('requests.get', side_effect=mock_pyquery) @@ -1475,3 +1481,18 @@ def test_invalid_default_year_reverts_to_previous_year(self, assert player.name in ['Drew Brees', 'Demario Davis', 'Tommylee Lewis', 'Wil Lutz', 'Thomas Morstead'] + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_roster_class_string_representation(self, *args, **kwargs): + expected = """Drew Brees (BreeDr00) +Demario Davis (DaviDe00) +Tommylee Lewis (LewiTo00) +Wil Lutz (LutzWi00) +Thomas Morstead (MorsTh00)""" + + flexmock(utils) \ + .should_receive('_find_year_for_season') \ + .and_return('2018') + roster = Roster('NOR') + + assert roster.__repr__() == expected diff --git a/tests/integration/roster/test_nhl_roster.py b/tests/integration/roster/test_nhl_roster.py index 820e0d91..5d02cdff 100644 --- a/tests/integration/roster/test_nhl_roster.py +++ b/tests/integration/roster/test_nhl_roster.py @@ -676,6 +676,12 @@ def test_nhl_404_returns_none_for_different_season(self, *args, **kwargs): assert player.name is None assert player.dataframe is None + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_nhl_player_string_representation(self, *args, **kwargs): + player = Player('zettehe01') + + assert player.__repr__() == 'Henrik Zetterberg (zettehe01)' + class TestNHLRoster: @mock.patch('requests.get', side_effect=mock_pyquery) @@ -738,3 +744,15 @@ def test_invalid_default_year_reverts_to_previous_year(self, for player in roster.players: assert player.name in ['Jimmy Howard', 'Henrik Zetterberg'] + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_roster_class_string_representation(self, *args, **kwargs): + expected = """Jimmy Howard (howarja02) +Henrik Zetterberg (zettehe01)""" + + flexmock(utils) \ + .should_receive('_find_year_for_season') \ + .and_return('2018') + roster = Roster('DET') + + assert roster.__repr__() == expected diff --git a/tests/integration/schedule/test_fb_schedule.py b/tests/integration/schedule/test_fb_schedule.py index c564ab27..90c34cd7 100644 --- a/tests/integration/schedule/test_fb_schedule.py +++ b/tests/integration/schedule/test_fb_schedule.py @@ -110,3 +110,64 @@ def test_fb_schedule_dataframe_returns_dataframe(self): df1 = pd.concat(frames).drop_duplicates(keep=False) assert df1.empty + + def test_fb_schedule_string_representation(self): + expected = """2019-08-10 - Aston Villa +2019-08-17 - Manchester City +2019-08-25 - Newcastle Utd +2019-09-01 - Arsenal +2019-09-14 - Crystal Palace +2019-09-18 - gr Olympiacos +2019-09-21 - Leicester City +2019-09-24 - Colchester Utd +2019-09-28 - Southampton +2019-10-01 - de Bayern Munich +2019-10-05 - Brighton +2019-10-19 - Watford +2019-10-22 - rs Red Star +2019-10-27 - Liverpool +2019-11-03 - Everton +2019-11-06 - rs Red Star +2019-11-09 - Sheffield Utd +2019-11-23 - West Ham +2019-11-26 - gr Olympiacos +2019-11-30 - Bournemouth +2019-12-04 - Manchester Utd +2019-12-07 - Burnley +2019-12-11 - de Bayern Munich +2019-12-15 - Wolves +2019-12-22 - Chelsea +2019-12-26 - Brighton +2019-12-28 - Norwich City +2020-01-01 - Southampton +2020-01-05 - Middlesbrough +2020-01-11 - Liverpool +2020-01-14 - Middlesbrough +2020-01-18 - Watford +2020-01-22 - Norwich City +2020-01-25 - Southampton +2020-02-02 - Manchester City +2020-02-05 - Southampton +2020-02-16 - Aston Villa +2020-02-19 - de RB Leipzig +2020-02-22 - Chelsea +2020-03-01 - Wolves +2020-03-04 - Norwich City +2020-03-07 - Burnley +2020-03-10 - de RB Leipzig +2020-03-15 - Manchester Utd +2020-03-20 - West Ham +2020-04-04 - Sheffield Utd +2020-04-11 - Everton +2020-04-18 - Bournemouth +2020-04-26 - Arsenal +2020-05-02 - Newcastle Utd +2020-05-09 - Leicester City +2020-05-17 - Crystal Palace""" + + assert self.schedule.__repr__() == expected + + def test_fb_game_string_representation(self): + game = self.schedule[0] + + assert game.__repr__() == '2019-08-10 - Aston Villa' diff --git a/tests/integration/schedule/test_mlb_schedule.py b/tests/integration/schedule/test_mlb_schedule.py index eaa466f8..a1ee04de 100644 --- a/tests/integration/schedule/test_mlb_schedule.py +++ b/tests/integration/schedule/test_mlb_schedule.py @@ -188,6 +188,177 @@ def test_empty_page_return_no_games(self): assert len(schedule) == 0 + def test_game_string_representation(self): + game = self.schedule[0] + + assert game.__repr__() == 'Sunday, Apr 2 - TBR' + + def test_schedule_string_representation(self): + expected = """Sunday, Apr 2 - TBR +Tuesday, Apr 4 - TBR +Wednesday, Apr 5 - TBR +Friday, Apr 7 - BAL +Saturday, Apr 8 - BAL +Sunday, Apr 9 - BAL +Monday, Apr 10 - TBR +Wednesday, Apr 12 - TBR +Thursday, Apr 13 - TBR +Friday, Apr 14 - STL +Saturday, Apr 15 - STL +Sunday, Apr 16 - STL +Monday, Apr 17 - CHW +Tuesday, Apr 18 - CHW +Wednesday, Apr 19 - CHW +Friday, Apr 21 - PIT +Saturday, Apr 22 - PIT +Sunday, Apr 23 - PIT +Wednesday, Apr 26 - BOS +Thursday, Apr 27 - BOS +Friday, Apr 28 - BAL +Saturday, Apr 29 - BAL +Sunday, Apr 30 - BAL +Monday, May 1 - TOR +Tuesday, May 2 - TOR +Wednesday, May 3 - TOR +Friday, May 5 - CHC +Saturday, May 6 - CHC +Sunday, May 7 - CHC +Monday, May 8 - CIN +Tuesday, May 9 - CIN +Thursday, May 11 - HOU +Friday, May 12 - HOU +Sunday, May 14 (1) - HOU +Sunday, May 14 (2) - HOU +Tuesday, May 16 - KCR +Wednesday, May 17 - KCR +Thursday, May 18 - KCR +Friday, May 19 - TBR +Saturday, May 20 - TBR +Sunday, May 21 - TBR +Monday, May 22 - KCR +Tuesday, May 23 - KCR +Wednesday, May 24 - KCR +Friday, May 26 - OAK +Saturday, May 27 - OAK +Sunday, May 28 - OAK +Monday, May 29 - BAL +Tuesday, May 30 - BAL +Wednesday, May 31 - BAL +Thursday, Jun 1 - TOR +Friday, Jun 2 - TOR +Saturday, Jun 3 - TOR +Sunday, Jun 4 - TOR +Tuesday, Jun 6 - BOS +Wednesday, Jun 7 - BOS +Thursday, Jun 8 - BOS +Friday, Jun 9 - BAL +Saturday, Jun 10 - BAL +Sunday, Jun 11 - BAL +Monday, Jun 12 - LAA +Tuesday, Jun 13 - LAA +Wednesday, Jun 14 - LAA +Thursday, Jun 15 - OAK +Friday, Jun 16 - OAK +Saturday, Jun 17 - OAK +Sunday, Jun 18 - OAK +Tuesday, Jun 20 - LAA +Wednesday, Jun 21 - LAA +Thursday, Jun 22 - LAA +Friday, Jun 23 - TEX +Saturday, Jun 24 - TEX +Sunday, Jun 25 - TEX +Monday, Jun 26 - CHW +Tuesday, Jun 27 - CHW +Wednesday, Jun 28 - CHW +Thursday, Jun 29 - CHW +Friday, Jun 30 - HOU +Saturday, Jul 1 - HOU +Sunday, Jul 2 - HOU +Monday, Jul 3 - TOR +Tuesday, Jul 4 - TOR +Wednesday, Jul 5 - TOR +Friday, Jul 7 - MIL +Saturday, Jul 8 - MIL +Sunday, Jul 9 - MIL +Friday, Jul 14 - BOS +Saturday, Jul 15 - BOS +Sunday, Jul 16 (1) - BOS +Sunday, Jul 16 (2) - BOS +Monday, Jul 17 - MIN +Tuesday, Jul 18 - MIN +Wednesday, Jul 19 - MIN +Thursday, Jul 20 - SEA +Friday, Jul 21 - SEA +Saturday, Jul 22 - SEA +Sunday, Jul 23 - SEA +Tuesday, Jul 25 - CIN +Wednesday, Jul 26 - CIN +Thursday, Jul 27 - TBR +Friday, Jul 28 - TBR +Saturday, Jul 29 - TBR +Sunday, Jul 30 - TBR +Monday, Jul 31 - DET +Tuesday, Aug 1 - DET +Wednesday, Aug 2 - DET +Thursday, Aug 3 - CLE +Friday, Aug 4 - CLE +Saturday, Aug 5 - CLE +Sunday, Aug 6 - CLE +Tuesday, Aug 8 - TOR +Wednesday, Aug 9 - TOR +Thursday, Aug 10 - TOR +Friday, Aug 11 - BOS +Saturday, Aug 12 - BOS +Sunday, Aug 13 - BOS +Monday, Aug 14 - NYM +Tuesday, Aug 15 - NYM +Wednesday, Aug 16 - NYM +Thursday, Aug 17 - NYM +Friday, Aug 18 - BOS +Saturday, Aug 19 - BOS +Sunday, Aug 20 - BOS +Tuesday, Aug 22 - DET +Wednesday, Aug 23 - DET +Thursday, Aug 24 - DET +Friday, Aug 25 - SEA +Saturday, Aug 26 - SEA +Sunday, Aug 27 - SEA +Monday, Aug 28 - CLE +Wednesday, Aug 30 (1) - CLE +Wednesday, Aug 30 (2) - CLE +Thursday, Aug 31 - BOS +Friday, Sep 1 - BOS +Saturday, Sep 2 - BOS +Sunday, Sep 3 - BOS +Monday, Sep 4 - BAL +Tuesday, Sep 5 - BAL +Thursday, Sep 7 - BAL +Friday, Sep 8 - TEX +Saturday, Sep 9 - TEX +Sunday, Sep 10 - TEX +Monday, Sep 11 - TBR +Tuesday, Sep 12 - TBR +Wednesday, Sep 13 - TBR +Thursday, Sep 14 - BAL +Friday, Sep 15 - BAL +Saturday, Sep 16 - BAL +Sunday, Sep 17 - BAL +Monday, Sep 18 - MIN +Tuesday, Sep 19 - MIN +Wednesday, Sep 20 - MIN +Friday, Sep 22 - TOR +Saturday, Sep 23 - TOR +Sunday, Sep 24 - TOR +Monday, Sep 25 - KCR +Tuesday, Sep 26 - TBR +Wednesday, Sep 27 - TBR +Thursday, Sep 28 - TBR +Friday, Sep 29 - TOR +Saturday, Sep 30 - TOR +Sunday, Oct 1 - TOR""" + + assert self.schedule.__repr__() == expected + class TestMLBScheduleInvalidYear: @mock.patch('requests.get', side_effect=mock_pyquery) diff --git a/tests/integration/schedule/test_nba_schedule.py b/tests/integration/schedule/test_nba_schedule.py index 5c4b4e6d..7903d93d 100644 --- a/tests/integration/schedule/test_nba_schedule.py +++ b/tests/integration/schedule/test_nba_schedule.py @@ -156,6 +156,114 @@ def test_empty_page_return_no_games(self): assert len(schedule) == 0 + def test_game_string_representation(self): + game = self.schedule[0] + + assert game.__repr__() == 'Tue, Oct 25, 2016 - SAS' + + def test_schedule_string_representation(self): + expected = """Tue, Oct 25, 2016 - SAS +Fri, Oct 28, 2016 - NOP +Sun, Oct 30, 2016 - PHO +Tue, Nov 1, 2016 - POR +Thu, Nov 3, 2016 - OKC +Fri, Nov 4, 2016 - LAL +Mon, Nov 7, 2016 - NOP +Wed, Nov 9, 2016 - DAL +Thu, Nov 10, 2016 - DEN +Sun, Nov 13, 2016 - PHO +Wed, Nov 16, 2016 - TOR +Fri, Nov 18, 2016 - BOS +Sat, Nov 19, 2016 - MIL +Mon, Nov 21, 2016 - IND +Wed, Nov 23, 2016 - LAL +Fri, Nov 25, 2016 - LAL +Sat, Nov 26, 2016 - MIN +Mon, Nov 28, 2016 - ATL +Thu, Dec 1, 2016 - HOU +Sat, Dec 3, 2016 - PHO +Mon, Dec 5, 2016 - IND +Wed, Dec 7, 2016 - LAC +Thu, Dec 8, 2016 - UTA +Sat, Dec 10, 2016 - MEM +Sun, Dec 11, 2016 - MIN +Tue, Dec 13, 2016 - NOP +Thu, Dec 15, 2016 - NYK +Sat, Dec 17, 2016 - POR +Tue, Dec 20, 2016 - UTA +Thu, Dec 22, 2016 - BRK +Fri, Dec 23, 2016 - DET +Sun, Dec 25, 2016 - CLE +Wed, Dec 28, 2016 - TOR +Fri, Dec 30, 2016 - DAL +Mon, Jan 2, 2017 - DEN +Wed, Jan 4, 2017 - POR +Fri, Jan 6, 2017 - MEM +Sun, Jan 8, 2017 - SAC +Tue, Jan 10, 2017 - MIA +Thu, Jan 12, 2017 - DET +Mon, Jan 16, 2017 - CLE +Wed, Jan 18, 2017 - OKC +Fri, Jan 20, 2017 - HOU +Sun, Jan 22, 2017 - ORL +Mon, Jan 23, 2017 - MIA +Wed, Jan 25, 2017 - CHO +Sat, Jan 28, 2017 - LAC +Sun, Jan 29, 2017 - POR +Wed, Feb 1, 2017 - CHO +Thu, Feb 2, 2017 - LAC +Sat, Feb 4, 2017 - SAC +Wed, Feb 8, 2017 - CHI +Fri, Feb 10, 2017 - MEM +Sat, Feb 11, 2017 - OKC +Mon, Feb 13, 2017 - DEN +Wed, Feb 15, 2017 - SAC +Thu, Feb 23, 2017 - LAC +Sat, Feb 25, 2017 - BRK +Mon, Feb 27, 2017 - PHI +Tue, Feb 28, 2017 - WAS +Thu, Mar 2, 2017 - CHI +Sun, Mar 5, 2017 - NYK +Mon, Mar 6, 2017 - ATL +Wed, Mar 8, 2017 - BOS +Fri, Mar 10, 2017 - MIN +Sat, Mar 11, 2017 - SAS +Tue, Mar 14, 2017 - PHI +Thu, Mar 16, 2017 - ORL +Sat, Mar 18, 2017 - MIL +Mon, Mar 20, 2017 - OKC +Tue, Mar 21, 2017 - DAL +Fri, Mar 24, 2017 - SAC +Sun, Mar 26, 2017 - MEM +Tue, Mar 28, 2017 - HOU +Wed, Mar 29, 2017 - SAS +Fri, Mar 31, 2017 - HOU +Sun, Apr 2, 2017 - WAS +Tue, Apr 4, 2017 - MIN +Wed, Apr 5, 2017 - PHO +Sat, Apr 8, 2017 - NOP +Mon, Apr 10, 2017 - UTA +Wed, Apr 12, 2017 - LAL +Sun, Apr 16, 2017 - POR +Wed, Apr 19, 2017 - POR +Sat, Apr 22, 2017 - POR +Mon, Apr 24, 2017 - POR +Tue, May 2, 2017 - UTA +Thu, May 4, 2017 - UTA +Sat, May 6, 2017 - UTA +Mon, May 8, 2017 - UTA +Sun, May 14, 2017 - SAS +Tue, May 16, 2017 - SAS +Sat, May 20, 2017 - SAS +Mon, May 22, 2017 - SAS +Thu, Jun 1, 2017 - CLE +Sun, Jun 4, 2017 - CLE +Wed, Jun 7, 2017 - CLE +Fri, Jun 9, 2017 - CLE +Mon, Jun 12, 2017 - CLE""" + + assert self.schedule.__repr__() == expected + class TestNBAScheduleInvalidError: @mock.patch('requests.get', side_effect=mock_pyquery) diff --git a/tests/integration/schedule/test_ncaab_schedule.py b/tests/integration/schedule/test_ncaab_schedule.py index e41e4f9e..74cd44e9 100644 --- a/tests/integration/schedule/test_ncaab_schedule.py +++ b/tests/integration/schedule/test_ncaab_schedule.py @@ -159,6 +159,54 @@ def test_empty_page_return_no_games(self): assert len(schedule) == 0 + def test_game_string_representation(self): + game = self.schedule[0] + + assert game.__repr__() == 'Fri, Nov 10, 2017 - tennessee-state' + + def test_schedule_string_representation(self): + expected = """Fri, Nov 10, 2017 - tennessee-state +Tue, Nov 14, 2017 - kentucky +Fri, Nov 17, 2017 - south-dakota-state +Tue, Nov 21, 2017 - texas-southern +Fri, Nov 24, 2017 - oakland +Tue, Nov 28, 2017 - toledo +Sat, Dec 2, 2017 - syracuse +Wed, Dec 6, 2017 - washington +Sun, Dec 10, 2017 - arizona-state +Sat, Dec 16, 2017 - nebraska +Mon, Dec 18, 2017 - nebraska-omaha +Thu, Dec 21, 2017 - stanford +Fri, Dec 29, 2017 - texas +Tue, Jan 2, 2018 - texas-tech +Sat, Jan 6, 2018 - texas-christian +Tue, Jan 9, 2018 - iowa-state +Sat, Jan 13, 2018 - kansas-state +Mon, Jan 15, 2018 - west-virginia +Sat, Jan 20, 2018 - baylor +Tue, Jan 23, 2018 - oklahoma +Sat, Jan 27, 2018 - texas-am +Mon, Jan 29, 2018 - kansas-state +Sat, Feb 3, 2018 - oklahoma-state +Tue, Feb 6, 2018 - texas-christian +Sat, Feb 10, 2018 - baylor +Tue, Feb 13, 2018 - iowa-state +Sat, Feb 17, 2018 - west-virginia +Mon, Feb 19, 2018 - oklahoma +Sat, Feb 24, 2018 - texas-tech +Mon, Feb 26, 2018 - texas +Sat, Mar 3, 2018 - oklahoma-state +Thu, Mar 8, 2018 - oklahoma-state +Fri, Mar 9, 2018 - kansas-state +Sat, Mar 10, 2018 - west-virginia +Thu, Mar 15, 2018 - pennsylvania +Sat, Mar 17, 2018 - seton-hall +Fri, Mar 23, 2018 - clemson +Sun, Mar 25, 2018 - duke +Sat, Mar 31, 2018 - villanova""" + + assert self.schedule.__repr__() == expected + class TestNCAABScheduleInvalidYear: @mock.patch('requests.get', side_effect=mock_pyquery) diff --git a/tests/integration/schedule/test_ncaaf_schedule.py b/tests/integration/schedule/test_ncaaf_schedule.py index 086fd337..991593af 100644 --- a/tests/integration/schedule/test_ncaaf_schedule.py +++ b/tests/integration/schedule/test_ncaaf_schedule.py @@ -157,6 +157,28 @@ def test_empty_page_return_no_games(self): assert len(schedule) == 0 + def test_game_string_representation(self): + game = self.schedule[0] + + assert game.__repr__() == 'Sep 2, 2017 - florida' + + def test_schedule_string_representation(self): + expected = """Sep 2, 2017 - florida +Sep 9, 2017 - cincinnati +Sep 16, 2017 - air-force +Sep 23, 2017 - purdue +Oct 7, 2017 - michigan-state +Oct 14, 2017 - indiana +Oct 21, 2017 - penn-state +Oct 28, 2017 - rutgers +Nov 4, 2017 - minnesota +Nov 11, 2017 - maryland +Nov 18, 2017 - wisconsin +Nov 25, 2017 - ohio-state +Jan 1, 2018 - south-carolina""" + + assert self.schedule.__repr__() == expected + class TestNCAAFScheduleInvalidYear: @mock.patch('requests.get', side_effect=mock_pyquery) diff --git a/tests/integration/schedule/test_nfl_schedule.py b/tests/integration/schedule/test_nfl_schedule.py index f65d5644..2a9e1776 100644 --- a/tests/integration/schedule/test_nfl_schedule.py +++ b/tests/integration/schedule/test_nfl_schedule.py @@ -179,6 +179,34 @@ def test_empty_page_return_no_games(self): assert len(schedule) == 0 + def test_game_string_representation(self): + game = self.schedule[0] + + assert game.__repr__() == 'September 7 - KAN' + + def test_schedule_string_representation(self): + expected = """September 7 - KAN +September 17 - NOR +September 24 - HTX +October 1 - CAR +October 5 - TAM +October 15 - NYJ +October 22 - ATL +October 29 - SDG +November 12 - DEN +November 19 - RAI +November 26 - MIA +December 3 - BUF +December 11 - MIA +December 17 - PIT +December 24 - BUF +December 31 - NYJ +January 13 - OTI +January 21 - JAX +February 4 - PHI""" + + assert self.schedule.__repr__() == expected + class TestNFLScheduleInvalidYear: @mock.patch('requests.get', side_effect=mock_pyquery) diff --git a/tests/integration/schedule/test_nhl_schedule.py b/tests/integration/schedule/test_nhl_schedule.py index 1377e0e5..5d9a440b 100644 --- a/tests/integration/schedule/test_nhl_schedule.py +++ b/tests/integration/schedule/test_nhl_schedule.py @@ -171,6 +171,97 @@ def test_empty_page_return_no_games(self): assert len(schedule) == 0 + def test_game_string_representation(self): + game = self.schedule[0] + + assert game.__repr__() == '2016-10-13 - NYI' + + def test_schedule_string_representation(self): + expected = """2016-10-13 - NYI +2016-10-15 - STL +2016-10-17 - SJS +2016-10-19 - DET +2016-10-22 - WSH +2016-10-23 - ARI +2016-10-26 - BOS +2016-10-28 - CAR +2016-10-30 - TBL +2016-11-01 - STL +2016-11-03 - EDM +2016-11-05 - BOS +2016-11-06 - WPG +2016-11-08 - VAN +2016-11-12 - CGY +2016-11-13 - EDM +2016-11-15 - VAN +2016-11-18 - CBJ +2016-11-20 - FLA +2016-11-21 - PIT +2016-11-23 - PIT +2016-11-25 - PHI +2016-11-27 - OTT +2016-11-29 - CAR +2016-12-01 - BUF +2016-12-03 - CAR +2016-12-06 - NYI +2016-12-08 - WPG +2016-12-09 - CHI +2016-12-11 - NJD +2016-12-13 - CHI +2016-12-15 - DAL +2016-12-17 - NSH +2016-12-18 - NJD +2016-12-20 - PIT +2016-12-23 - MIN +2016-12-27 - OTT +2016-12-29 - ARI +2016-12-31 - COL +2017-01-03 - BUF +2017-01-04 - PHI +2017-01-07 - CBJ +2017-01-13 - TOR +2017-01-14 - MTL +2017-01-17 - DAL +2017-01-19 - TOR +2017-01-22 - DET +2017-01-23 - LAK +2017-01-25 - PHI +2017-01-31 - CBJ +2017-02-02 - BUF +2017-02-05 - CGY +2017-02-07 - ANA +2017-02-09 - NSH +2017-02-11 - COL +2017-02-13 - CBJ +2017-02-16 - NYI +2017-02-19 - WSH +2017-02-21 - MTL +2017-02-23 - TOR +2017-02-25 - NJD +2017-02-26 - CBJ +2017-02-28 - WSH +2017-03-02 - BOS +2017-03-04 - MTL +2017-03-06 - TBL +2017-03-07 - FLA +2017-03-09 - CAR +2017-03-12 - DET +2017-03-13 - TBL +2017-03-17 - FLA +2017-03-18 - MIN +2017-03-21 - NJD +2017-03-22 - NYI +2017-03-25 - LAK +2017-03-26 - ANA +2017-03-28 - SJS +2017-03-31 - PIT +2017-04-02 - PHI +2017-04-05 - WSH +2017-04-08 - OTT +2017-04-09 - PIT""" + + assert self.schedule.__repr__() == expected + class TestNHLScheduleInvalidYear: @mock.patch('requests.get', side_effect=mock_pyquery) diff --git a/tests/integration/team/test_fb_team.py b/tests/integration/team/test_fb_team.py index b089cbf7..f65a6a22 100644 --- a/tests/integration/team/test_fb_team.py +++ b/tests/integration/team/test_fb_team.py @@ -57,3 +57,9 @@ def test_fb_team_returns_correct_attributes(self, *args, **kwargs): for attribute, value in self.results.items(): assert getattr(tottenham, attribute) == value + + @patch('requests.get', side_effect=mock_pyquery) + def test_team_name(self, *args, **kwargs): + team = Team('Tottenham Hotspur') + + assert team.__repr__() == 'Tottenham Hotspur (361ca564) - 2019-2020' diff --git a/tests/integration/teams/test_mlb_integration.py b/tests/integration/teams/test_mlb_integration.py index 913996fd..64c4b516 100644 --- a/tests/integration/teams/test_mlb_integration.py +++ b/tests/integration/teams/test_mlb_integration.py @@ -273,3 +273,44 @@ def test_mlb_empty_page_returns_no_teams(self): teams = Teams() assert len(teams) == 0 + + def test_mlb_team_string_representation(self): + hou = Team('HOU') + + assert hou.__repr__() == 'Houston Astros (HOU) - 2017' + + def test_mlb_teams_string_representation(self): + expected = """Los Angeles Dodgers (LAD) +Cleveland Indians (CLE) +Houston Astros (HOU) +Washington Nationals (WSN) +Boston Red Sox (BOS) +Arizona Diamondbacks (ARI) +Chicago Cubs (CHC) +New York Yankees (NYY) +Colorado Rockies (COL) +Milwaukee Brewers (MIL) +Minnesota Twins (MIN) +St. Louis Cardinals (STL) +Los Angeles Angels (LAA) +Tampa Bay Rays (TBR) +Kansas City Royals (KCR) +Seattle Mariners (SEA) +Texas Rangers (TEX) +Miami Marlins (MIA) +Toronto Blue Jays (TOR) +Pittsburgh Pirates (PIT) +Baltimore Orioles (BAL) +Oakland Athletics (OAK) +Atlanta Braves (ATL) +San Diego Padres (SDP) +New York Mets (NYM) +Cincinnati Reds (CIN) +Chicago White Sox (CHW) +Philadelphia Phillies (PHI) +San Francisco Giants (SFG) +Detroit Tigers (DET)""" + + teams = Teams() + + assert teams.__repr__() == expected diff --git a/tests/integration/teams/test_nba_integration.py b/tests/integration/teams/test_nba_integration.py index aebaccae..e5f42dd0 100644 --- a/tests/integration/teams/test_nba_integration.py +++ b/tests/integration/teams/test_nba_integration.py @@ -173,6 +173,47 @@ def test_pulling_team_directly(self): for attribute, value in self.results.items(): assert getattr(detroit, attribute) == value + def test_team_string_representation(self): + detroit = Team('DET') + + assert detroit.__repr__() == 'Detroit Pistons (DET) - 2017' + + def test_teams_string_representation(self): + expected = """Golden State Warriors (GSW) +Houston Rockets (HOU) +Denver Nuggets (DEN) +Cleveland Cavaliers (CLE) +Washington Wizards (WAS) +Los Angeles Clippers (LAC) +Boston Celtics (BOS) +Portland Trail Blazers (POR) +Phoenix Suns (PHO) +Toronto Raptors (TOR) +Oklahoma City Thunder (OKC) +Brooklyn Nets (BRK) +Minnesota Timberwolves (MIN) +San Antonio Spurs (SAS) +Indiana Pacers (IND) +Charlotte Hornets (CHO) +Los Angeles Lakers (LAL) +New Orleans Pelicans (NOP) +New York Knicks (NYK) +Milwaukee Bucks (MIL) +Miami Heat (MIA) +Atlanta Hawks (ATL) +Chicago Bulls (CHI) +Sacramento Kings (SAC) +Philadelphia 76ers (PHI) +Detroit Pistons (DET) +Orlando Magic (ORL) +Utah Jazz (UTA) +Memphis Grizzlies (MEM) +Dallas Mavericks (DAL)""" + + teams = Teams() + + assert teams.__repr__() == expected + class TestNBAIntegrationInvalidDate: @mock.patch('requests.get', side_effect=mock_pyquery) diff --git a/tests/integration/teams/test_ncaab_integration.py b/tests/integration/teams/test_ncaab_integration.py index ba3eaf46..8fe57b4d 100644 --- a/tests/integration/teams/test_ncaab_integration.py +++ b/tests/integration/teams/test_ncaab_integration.py @@ -693,6 +693,370 @@ def test_pulling_team_directly(self, *args, **kwargs): for attribute, value in self.results.items(): assert getattr(purdue, attribute) == value + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_team_string_representation(self, *args, **kwargs): + purdue = Team('PURDUE') + + assert purdue.__repr__() == 'Purdue (PURDUE) - 2018' + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_teams_string_representation(self, *args, **kwargs): + expected = """Abilene Christian (ABILENE-CHRISTIAN) +Air Force (AIR-FORCE) +Akron (AKRON) +Alabama A&M (ALABAMA-AM) +Alabama-Birmingham (ALABAMA-BIRMINGHAM) +Alabama State (ALABAMA-STATE) +Alabama (ALABAMA) +Albany (NY) (ALBANY-NY) +Alcorn State (ALCORN-STATE) +American (AMERICAN) +Appalachian State (APPALACHIAN-STATE) +Arizona State (ARIZONA-STATE) +Arizona (ARIZONA) +Little Rock (ARKANSAS-LITTLE-ROCK) +Arkansas-Pine Bluff (ARKANSAS-PINE-BLUFF) +Arkansas State (ARKANSAS-STATE) +Arkansas (ARKANSAS) +Army (ARMY) +Auburn (AUBURN) +Austin Peay (AUSTIN-PEAY) +Ball State (BALL-STATE) +Baylor (BAYLOR) +Belmont (BELMONT) +Bethune-Cookman (BETHUNE-COOKMAN) +Binghamton (BINGHAMTON) +Boise State (BOISE-STATE) +Boston College (BOSTON-COLLEGE) +Boston University (BOSTON-UNIVERSITY) +Bowling Green State (BOWLING-GREEN-STATE) +Bradley (BRADLEY) +Brigham Young (BRIGHAM-YOUNG) +Brown (BROWN) +Bryant (BRYANT) +Bucknell (BUCKNELL) +Buffalo (BUFFALO) +Butler (BUTLER) +Cal Poly (CAL-POLY) +Cal State Bakersfield (CAL-STATE-BAKERSFIELD) +Cal State Fullerton (CAL-STATE-FULLERTON) +Cal State Northridge (CAL-STATE-NORTHRIDGE) +UC-Davis (CALIFORNIA-DAVIS) +UC-Irvine (CALIFORNIA-IRVINE) +UC-Riverside (CALIFORNIA-RIVERSIDE) +UC-Santa Barbara (CALIFORNIA-SANTA-BARBARA) +University of California (CALIFORNIA) +Campbell (CAMPBELL) +Canisius (CANISIUS) +Central Arkansas (CENTRAL-ARKANSAS) +Central Connecticut State (CENTRAL-CONNECTICUT-STATE) +Central Florida (CENTRAL-FLORIDA) +Central Michigan (CENTRAL-MICHIGAN) +Charleston Southern (CHARLESTON-SOUTHERN) +Charlotte (CHARLOTTE) +Chattanooga (CHATTANOOGA) +Chicago State (CHICAGO-STATE) +Cincinnati (CINCINNATI) +Citadel (CITADEL) +Clemson (CLEMSON) +Cleveland State (CLEVELAND-STATE) +Coastal Carolina (COASTAL-CAROLINA) +Colgate (COLGATE) +College of Charleston (COLLEGE-OF-CHARLESTON) +Colorado State (COLORADO-STATE) +Colorado (COLORADO) +Columbia (COLUMBIA) +Connecticut (CONNECTICUT) +Coppin State (COPPIN-STATE) +Cornell (CORNELL) +Creighton (CREIGHTON) +Dartmouth (DARTMOUTH) +Davidson (DAVIDSON) +Dayton (DAYTON) +Delaware State (DELAWARE-STATE) +Delaware (DELAWARE) +Denver (DENVER) +DePaul (DEPAUL) +Detroit Mercy (DETROIT-MERCY) +Drake (DRAKE) +Drexel (DREXEL) +Duke (DUKE) +Duquesne (DUQUESNE) +East Carolina (EAST-CAROLINA) +East Tennessee State (EAST-TENNESSEE-STATE) +Eastern Illinois (EASTERN-ILLINOIS) +Eastern Kentucky (EASTERN-KENTUCKY) +Eastern Michigan (EASTERN-MICHIGAN) +Eastern Washington (EASTERN-WASHINGTON) +Elon (ELON) +Evansville (EVANSVILLE) +Fairfield (FAIRFIELD) +Fairleigh Dickinson (FAIRLEIGH-DICKINSON) +Florida A&M (FLORIDA-AM) +Florida Atlantic (FLORIDA-ATLANTIC) +Florida Gulf Coast (FLORIDA-GULF-COAST) +Florida International (FLORIDA-INTERNATIONAL) +Florida State (FLORIDA-STATE) +Florida (FLORIDA) +Fordham (FORDHAM) +Fresno State (FRESNO-STATE) +Furman (FURMAN) +Gardner-Webb (GARDNER-WEBB) +George Mason (GEORGE-MASON) +George Washington (GEORGE-WASHINGTON) +Georgetown (GEORGETOWN) +Georgia Southern (GEORGIA-SOUTHERN) +Georgia State (GEORGIA-STATE) +Georgia Tech (GEORGIA-TECH) +Georgia (GEORGIA) +Gonzaga (GONZAGA) +Grambling (GRAMBLING) +Grand Canyon (GRAND-CANYON) +Green Bay (GREEN-BAY) +Hampton (HAMPTON) +Hartford (HARTFORD) +Harvard (HARVARD) +Hawaii (HAWAII) +High Point (HIGH-POINT) +Hofstra (HOFSTRA) +Holy Cross (HOLY-CROSS) +Houston Baptist (HOUSTON-BAPTIST) +Houston (HOUSTON) +Howard (HOWARD) +Idaho State (IDAHO-STATE) +Idaho (IDAHO) +Illinois-Chicago (ILLINOIS-CHICAGO) +Illinois State (ILLINOIS-STATE) +Illinois (ILLINOIS) +Incarnate Word (INCARNATE-WORD) +Indiana State (INDIANA-STATE) +Indiana (INDIANA) +Iona (IONA) +Iowa State (IOWA-STATE) +Iowa (IOWA) +Fort Wayne (IPFW) +IUPUI (IUPUI) +Jackson State (JACKSON-STATE) +Jacksonville State (JACKSONVILLE-STATE) +Jacksonville (JACKSONVILLE) +James Madison (JAMES-MADISON) +Kansas State (KANSAS-STATE) +Kansas (KANSAS) +Kennesaw State (KENNESAW-STATE) +Kent State (KENT-STATE) +Kentucky (KENTUCKY) +La Salle (LA-SALLE) +Lafayette (LAFAYETTE) +Lamar (LAMAR) +Lehigh (LEHIGH) +Liberty (LIBERTY) +Lipscomb (LIPSCOMB) +Long Beach State (LONG-BEACH-STATE) +Long Island University (LONG-ISLAND-UNIVERSITY) +Longwood (LONGWOOD) +Louisiana (LOUISIANA-LAFAYETTE) +Louisiana-Monroe (LOUISIANA-MONROE) +Louisiana State (LOUISIANA-STATE) +Louisiana Tech (LOUISIANA-TECH) +Louisville (LOUISVILLE) +Loyola (IL) (LOYOLA-IL) +Loyola Marymount (LOYOLA-MARYMOUNT) +Loyola (MD) (LOYOLA-MD) +Maine (MAINE) +Manhattan (MANHATTAN) +Marist (MARIST) +Marquette (MARQUETTE) +Marshall (MARSHALL) +Maryland-Baltimore County (MARYLAND-BALTIMORE-COUNTY) +Maryland-Eastern Shore (MARYLAND-EASTERN-SHORE) +Maryland (MARYLAND) +Massachusetts-Lowell (MASSACHUSETTS-LOWELL) +Massachusetts (MASSACHUSETTS) +McNeese State (MCNEESE-STATE) +Memphis (MEMPHIS) +Mercer (MERCER) +Miami (FL) (MIAMI-FL) +Miami (OH) (MIAMI-OH) +Michigan State (MICHIGAN-STATE) +Michigan (MICHIGAN) +Middle Tennessee (MIDDLE-TENNESSEE) +Milwaukee (MILWAUKEE) +Minnesota (MINNESOTA) +Mississippi State (MISSISSIPPI-STATE) +Mississippi Valley State (MISSISSIPPI-VALLEY-STATE) +Mississippi (MISSISSIPPI) +Missouri-Kansas City (MISSOURI-KANSAS-CITY) +Missouri State (MISSOURI-STATE) +Missouri (MISSOURI) +Monmouth (MONMOUTH) +Montana State (MONTANA-STATE) +Montana (MONTANA) +Morehead State (MOREHEAD-STATE) +Morgan State (MORGAN-STATE) +Mount St. Mary's (MOUNT-ST-MARYS) +Murray State (MURRAY-STATE) +Navy (NAVY) +Omaha (NEBRASKA-OMAHA) +Nebraska (NEBRASKA) +Nevada-Las Vegas (NEVADA-LAS-VEGAS) +Nevada (NEVADA) +New Hampshire (NEW-HAMPSHIRE) +New Mexico State (NEW-MEXICO-STATE) +New Mexico (NEW-MEXICO) +New Orleans (NEW-ORLEANS) +Niagara (NIAGARA) +Nicholls State (NICHOLLS-STATE) +NJIT (NJIT) +Norfolk State (NORFOLK-STATE) +North Carolina-Asheville (NORTH-CAROLINA-ASHEVILLE) +North Carolina A&T (NORTH-CAROLINA-AT) +North Carolina Central (NORTH-CAROLINA-CENTRAL) +North Carolina-Greensboro (NORTH-CAROLINA-GREENSBORO) +North Carolina State (NORTH-CAROLINA-STATE) +North Carolina-Wilmington (NORTH-CAROLINA-WILMINGTON) +North Carolina (NORTH-CAROLINA) +North Dakota State (NORTH-DAKOTA-STATE) +North Dakota (NORTH-DAKOTA) +North Florida (NORTH-FLORIDA) +North Texas (NORTH-TEXAS) +Northeastern (NORTHEASTERN) +Northern Arizona (NORTHERN-ARIZONA) +Northern Colorado (NORTHERN-COLORADO) +Northern Illinois (NORTHERN-ILLINOIS) +Northern Iowa (NORTHERN-IOWA) +Northern Kentucky (NORTHERN-KENTUCKY) +Northwestern State (NORTHWESTERN-STATE) +Northwestern (NORTHWESTERN) +Notre Dame (NOTRE-DAME) +Oakland (OAKLAND) +Ohio State (OHIO-STATE) +Ohio (OHIO) +Oklahoma State (OKLAHOMA-STATE) +Oklahoma (OKLAHOMA) +Old Dominion (OLD-DOMINION) +Oral Roberts (ORAL-ROBERTS) +Oregon State (OREGON-STATE) +Oregon (OREGON) +Pacific (PACIFIC) +Penn State (PENN-STATE) +Pennsylvania (PENNSYLVANIA) +Pepperdine (PEPPERDINE) +Pittsburgh (PITTSBURGH) +Portland State (PORTLAND-STATE) +Portland (PORTLAND) +Prairie View (PRAIRIE-VIEW) +Presbyterian (PRESBYTERIAN) +Princeton (PRINCETON) +Providence (PROVIDENCE) +Purdue (PURDUE) +Quinnipiac (QUINNIPIAC) +Radford (RADFORD) +Rhode Island (RHODE-ISLAND) +Rice (RICE) +Richmond (RICHMOND) +Rider (RIDER) +Robert Morris (ROBERT-MORRIS) +Rutgers (RUTGERS) +Sacramento State (SACRAMENTO-STATE) +Sacred Heart (SACRED-HEART) +Saint Francis (PA) (SAINT-FRANCIS-PA) +Saint Joseph's (SAINT-JOSEPHS) +Saint Louis (SAINT-LOUIS) +Saint Mary's (CA) (SAINT-MARYS-CA) +Saint Peter's (SAINT-PETERS) +Sam Houston State (SAM-HOUSTON-STATE) +Samford (SAMFORD) +San Diego State (SAN-DIEGO-STATE) +San Diego (SAN-DIEGO) +San Francisco (SAN-FRANCISCO) +San Jose State (SAN-JOSE-STATE) +Santa Clara (SANTA-CLARA) +Savannah State (SAVANNAH-STATE) +Seattle (SEATTLE) +Seton Hall (SETON-HALL) +Siena (SIENA) +South Alabama (SOUTH-ALABAMA) +South Carolina State (SOUTH-CAROLINA-STATE) +South Carolina Upstate (SOUTH-CAROLINA-UPSTATE) +South Carolina (SOUTH-CAROLINA) +South Dakota State (SOUTH-DAKOTA-STATE) +South Dakota (SOUTH-DAKOTA) +South Florida (SOUTH-FLORIDA) +Southeast Missouri State (SOUTHEAST-MISSOURI-STATE) +Southeastern Louisiana (SOUTHEASTERN-LOUISIANA) +Southern California (SOUTHERN-CALIFORNIA) +SIU Edwardsville (SOUTHERN-ILLINOIS-EDWARDSVILLE) +Southern Illinois (SOUTHERN-ILLINOIS) +Southern Methodist (SOUTHERN-METHODIST) +Southern Mississippi (SOUTHERN-MISSISSIPPI) +Southern Utah (SOUTHERN-UTAH) +Southern (SOUTHERN) +St. Bonaventure (ST-BONAVENTURE) +St. Francis (NY) (ST-FRANCIS-NY) +St. John's (NY) (ST-JOHNS-NY) +Stanford (STANFORD) +Stephen F. Austin (STEPHEN-F-AUSTIN) +Stetson (STETSON) +Stony Brook (STONY-BROOK) +Syracuse (SYRACUSE) +Temple (TEMPLE) +Tennessee-Martin (TENNESSEE-MARTIN) +Tennessee State (TENNESSEE-STATE) +Tennessee Tech (TENNESSEE-TECH) +Tennessee (TENNESSEE) +Texas A&M-Corpus Christi (TEXAS-AM-CORPUS-CHRISTI) +Texas A&M (TEXAS-AM) +Texas-Arlington (TEXAS-ARLINGTON) +Texas Christian (TEXAS-CHRISTIAN) +Texas-El Paso (TEXAS-EL-PASO) +Texas-Rio Grande Valley (TEXAS-PAN-AMERICAN) +Texas-San Antonio (TEXAS-SAN-ANTONIO) +Texas Southern (TEXAS-SOUTHERN) +Texas State (TEXAS-STATE) +Texas Tech (TEXAS-TECH) +Texas (TEXAS) +Toledo (TOLEDO) +Towson (TOWSON) +Troy (TROY) +Tulane (TULANE) +Tulsa (TULSA) +UCLA (UCLA) +Utah State (UTAH-STATE) +Utah Valley (UTAH-VALLEY) +Utah (UTAH) +Valparaiso (VALPARAISO) +Vanderbilt (VANDERBILT) +Vermont (VERMONT) +Villanova (VILLANOVA) +Virginia Commonwealth (VIRGINIA-COMMONWEALTH) +VMI (VIRGINIA-MILITARY-INSTITUTE) +Virginia Tech (VIRGINIA-TECH) +Virginia (VIRGINIA) +Wagner (WAGNER) +Wake Forest (WAKE-FOREST) +Washington State (WASHINGTON-STATE) +Washington (WASHINGTON) +Weber State (WEBER-STATE) +West Virginia (WEST-VIRGINIA) +Western Carolina (WESTERN-CAROLINA) +Western Illinois (WESTERN-ILLINOIS) +Western Kentucky (WESTERN-KENTUCKY) +Western Michigan (WESTERN-MICHIGAN) +Wichita State (WICHITA-STATE) +William & Mary (WILLIAM-MARY) +Winthrop (WINTHROP) +Wisconsin (WISCONSIN) +Wofford (WOFFORD) +Wright State (WRIGHT-STATE) +Wyoming (WYOMING) +Xavier (XAVIER) +Yale (YALE) +Youngstown State (YOUNGSTOWN-STATE)""" + + teams = Teams() + + assert teams.__repr__() == expected + class TestNCAABIntegrationInvalidYear: @mock.patch('requests.get', side_effect=mock_pyquery) diff --git a/tests/integration/teams/test_ncaaf_integration.py b/tests/integration/teams/test_ncaaf_integration.py index 91e746dc..96705465 100644 --- a/tests/integration/teams/test_ncaaf_integration.py +++ b/tests/integration/teams/test_ncaaf_integration.py @@ -365,6 +365,149 @@ def test_pulling_team_directly(self, *args, **kwargs): for attribute, value in self.results.items(): assert getattr(purdue, attribute) == value + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_team_string_representation(self, *args, **kwargs): + purdue = Team('PURDUE') + + assert purdue.__repr__() == 'Purdue (PURDUE) - 2017' + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_teams_string_representation(self, *args, **kwargs): + expected = """Clemson (CLEMSON) +North Carolina State (NORTH-CAROLINA-STATE) +Louisville (LOUISVILLE) +Wake Forest (WAKE-FOREST) +Boston College (BOSTON-COLLEGE) +Florida State (FLORIDA-STATE) +Syracuse (SYRACUSE) +Miami (FL) (MIAMI-FL) +Virginia Tech (VIRGINIA-TECH) +Georgia Tech (GEORGIA-TECH) +Duke (DUKE) +Pitt (PITTSBURGH) +Virginia (VIRGINIA) +North Carolina (NORTH-CAROLINA) +UCF (CENTRAL-FLORIDA) +South Florida (SOUTH-FLORIDA) +Temple (TEMPLE) +Cincinnati (CINCINNATI) +Connecticut (CONNECTICUT) +East Carolina (EAST-CAROLINA) +Memphis (MEMPHIS) +Houston (HOUSTON) +Navy (NAVY) +SMU (SOUTHERN-METHODIST) +Tulane (TULANE) +Tulsa (TULSA) +Oklahoma (OKLAHOMA) +Texas Christian (TEXAS-CHRISTIAN) +Oklahoma State (OKLAHOMA-STATE) +Iowa State (IOWA-STATE) +Kansas State (KANSAS-STATE) +Texas (TEXAS) +West Virginia (WEST-VIRGINIA) +Texas Tech (TEXAS-TECH) +Baylor (BAYLOR) +Kansas (KANSAS) +Ohio State (OHIO-STATE) +Penn State (PENN-STATE) +Michigan State (MICHIGAN-STATE) +Michigan (MICHIGAN) +Rutgers (RUTGERS) +Indiana (INDIANA) +Maryland (MARYLAND) +Wisconsin (WISCONSIN) +Northwestern (NORTHWESTERN) +Iowa (IOWA) +Purdue (PURDUE) +Nebraska (NEBRASKA) +Minnesota (MINNESOTA) +Illinois (ILLINOIS) +Florida Atlantic (FLORIDA-ATLANTIC) +Florida International (FLORIDA-INTERNATIONAL) +Marshall (MARSHALL) +Middle Tennessee State (MIDDLE-TENNESSEE-STATE) +Western Kentucky (WESTERN-KENTUCKY) +Old Dominion (OLD-DOMINION) +Charlotte (CHARLOTTE) +North Texas (NORTH-TEXAS) +Southern Mississippi (SOUTHERN-MISSISSIPPI) +UAB (ALABAMA-BIRMINGHAM) +Louisiana Tech (LOUISIANA-TECH) +UTSA (TEXAS-SAN-ANTONIO) +Rice (RICE) +UTEP (TEXAS-EL-PASO) +Massachusetts (MASSACHUSETTS) +Army (ARMY) +Notre Dame (NOTRE-DAME) +Brigham Young (BRIGHAM-YOUNG) +Akron (AKRON) +Ohio (OHIO) +Buffalo (BUFFALO) +Miami (OH) (MIAMI-OH) +Bowling Green State (BOWLING-GREEN-STATE) +Kent State (KENT-STATE) +Toledo (TOLEDO) +Central Michigan (CENTRAL-MICHIGAN) +Northern Illinois (NORTHERN-ILLINOIS) +Western Michigan (WESTERN-MICHIGAN) +Eastern Michigan (EASTERN-MICHIGAN) +Ball State (BALL-STATE) +Boise State (BOISE-STATE) +Wyoming (WYOMING) +Colorado State (COLORADO-STATE) +Air Force (AIR-FORCE) +Utah State (UTAH-STATE) +New Mexico (NEW-MEXICO) +Fresno State (FRESNO-STATE) +San Diego State (SAN-DIEGO-STATE) +Nevada-Las Vegas (NEVADA-LAS-VEGAS) +Nevada (NEVADA) +Hawaii (HAWAII) +San Jose State (SAN-JOSE-STATE) +Washington (WASHINGTON) +Stanford (STANFORD) +Washington State (WASHINGTON-STATE) +Oregon (OREGON) +California (CALIFORNIA) +Oregon State (OREGON-STATE) +USC (SOUTHERN-CALIFORNIA) +Arizona State (ARIZONA-STATE) +Arizona (ARIZONA) +UCLA (UCLA) +Utah (UTAH) +Colorado (COLORADO) +Georgia (GEORGIA) +South Carolina (SOUTH-CAROLINA) +Kentucky (KENTUCKY) +Missouri (MISSOURI) +Florida (FLORIDA) +Vanderbilt (VANDERBILT) +Tennessee (TENNESSEE) +Alabama (ALABAMA) +Auburn (AUBURN) +LSU (LOUISIANA-STATE) +Mississippi State (MISSISSIPPI-STATE) +Texas A&M (TEXAS-AM) +Ole Miss (MISSISSIPPI) +Arkansas (ARKANSAS) +Appalachian State (APPALACHIAN-STATE) +Coastal Carolina (COASTAL-CAROLINA) +Georgia Southern (GEORGIA-SOUTHERN) +Troy (TROY) +Arkansas State (ARKANSAS-STATE) +Georgia State (GEORGIA-STATE) +New Mexico State (NEW-MEXICO-STATE) +Louisiana (LOUISIANA-LAFAYETTE) +Louisiana-Monroe (LOUISIANA-MONROE) +Idaho (IDAHO) +South Alabama (SOUTH-ALABAMA) +Texas State (TEXAS-STATE)""" + + teams = Teams() + + assert teams.__repr__() == expected + class TestNCAAFIntegrationInvalidYear: @mock.patch('requests.get', side_effect=mock_pyquery) diff --git a/tests/integration/teams/test_nfl_integration.py b/tests/integration/teams/test_nfl_integration.py index 73863d75..21161b44 100644 --- a/tests/integration/teams/test_nfl_integration.py +++ b/tests/integration/teams/test_nfl_integration.py @@ -185,6 +185,51 @@ def test_pulling_team_directly(self, *args, **kwargs): for attribute, value in self.results.items(): assert getattr(kansas, attribute) == value + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_team_string_representation(self, *args, **kwargs): + kansas = Team('KAN') + + assert kansas.__repr__() == 'Kansas City Chiefs (KAN) - 2017' + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_teams_string_representation(self, *args, **kwargs): + expected = """Los Angeles Rams (RAM) +New England Patriots (NWE) +Philadelphia Eagles (PHI) +New Orleans Saints (NOR) +Jacksonville Jaguars (JAX) +Kansas City Chiefs (KAN) +Detroit Lions (DET) +Pittsburgh Steelers (PIT) +Baltimore Ravens (RAV) +Minnesota Vikings (MIN) +Seattle Seahawks (SEA) +Carolina Panthers (CAR) +Los Angeles Chargers (SDG) +Dallas Cowboys (DAL) +Atlanta Falcons (ATL) +Washington Redskins (WAS) +Houston Texans (HTX) +Tampa Bay Buccaneers (TAM) +Tennessee Titans (OTI) +San Francisco 49ers (SFO) +Green Bay Packers (GNB) +Buffalo Bills (BUF) +Oakland Raiders (RAI) +New York Jets (NYJ) +Arizona Cardinals (CRD) +Cincinnati Bengals (CIN) +Denver Broncos (DEN) +Miami Dolphins (MIA) +Chicago Bears (CHI) +Indianapolis Colts (CLT) +New York Giants (NYG) +Cleveland Browns (CLE)""" + + teams = Teams() + + assert teams.__repr__() == expected + class TestNFLIntegrationInvalidYear: @mock.patch('requests.get', side_effect=mock_pyquery) diff --git a/tests/integration/teams/test_nhl_integration.py b/tests/integration/teams/test_nhl_integration.py index 89425158..e5dc650e 100644 --- a/tests/integration/teams/test_nhl_integration.py +++ b/tests/integration/teams/test_nhl_integration.py @@ -154,6 +154,49 @@ def test_pulling_team_directly(self, *args, **kwargs): for attribute, value in self.results.items(): assert getattr(detroit, attribute) == value + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_team_string_representation(self, *args, **kwargs): + detroit = Team('DET') + + assert detroit.__repr__() == 'Detroit Red Wings (DET) - 2017' + + @mock.patch('requests.get', side_effect=mock_pyquery) + def test_teams_string_representation(self, *args, **kwargs): + expected = """Washington Capitals (WSH) +Pittsburgh Penguins (PIT) +Chicago Blackhawks (CHI) +Columbus Blue Jackets (CBJ) +Minnesota Wild (MIN) +Anaheim Ducks (ANA) +Montreal Canadiens (MTL) +Edmonton Oilers (EDM) +New York Rangers (NYR) +St. Louis Blues (STL) +San Jose Sharks (SJS) +Ottawa Senators (OTT) +Toronto Maple Leafs (TOR) +Boston Bruins (BOS) +Tampa Bay Lightning (TBL) +New York Islanders (NYI) +Nashville Predators (NSH) +Calgary Flames (CGY) +Philadelphia Flyers (PHI) +Winnipeg Jets (WPG) +Carolina Hurricanes (CAR) +Los Angeles Kings (LAK) +Florida Panthers (FLA) +Dallas Stars (DAL) +Detroit Red Wings (DET) +Buffalo Sabres (BUF) +Arizona Coyotes (ARI) +New Jersey Devils (NJD) +Vancouver Canucks (VAN) +Colorado Avalanche (COL)""" + + teams = Teams() + + assert teams.__repr__() == expected + class TestNHLIntegrationInvalidYear: @mock.patch('requests.get', side_effect=mock_pyquery)