def test_fb_no_doc_returns_roster(self): flexmock(Team) \ .should_receive('__init__') \ .and_return(None) team = Team('Tottenham Hotspur') team._squad_id = '361ca564' assert len(team.roster) == 0
def test_invalid_http_page_error(self, *args, **kwargs): flexmock(Team) \ .should_receive('__init__') \ .and_return(None) team = Team(None) team._squad_id = '' output = team._pull_team_page() assert not output
def setup_method(self): flexmock(Team) \ .should_receive('_pull_team_page') \ .and_return(None) flexmock(Schedule) \ .should_receive('_pull_schedule') \ .and_return(None) flexmock(Roster) \ .should_receive('_pull_stats') \ .and_return(None) self.team = Team('Tottenham Hotspur')
def teams_detail(request, team_name): team_name = team_name.replace('_', ' ') try: team = Team(team_name) except: return Response(status=status.HTTP_404_NOT_FOUND) data = TeamModel(name=string.capwords(team_name), points=team.points, league=team.league, position=team.position, record=team.record) serializer = TeamSerializer(data) return Response(serializer.data)
class TestFBTeam: def setup_method(self): flexmock(Team) \ .should_receive('_pull_team_page') \ .and_return(None) flexmock(Schedule) \ .should_receive('_pull_schedule') \ .and_return(None) flexmock(Roster) \ .should_receive('_pull_stats') \ .and_return(None) self.team = Team('Tottenham Hotspur') def test_location_record_missing_result(self): html = 'Home Record: (5-0-0)' output = self.team._location_records(html) assert output == (None, None, None, None) def test_location_record_missing_points(self): html = 'Home Record: 15 points (5-0-0)' output = self.team._location_records(html) assert output == (None, None, None, None) def test_records_missing_result(self): html = 'Record: 5-0-0, 15 points (3.0 per game)' output = self.team._records(html) assert output == (None, None, None) def test_goals_missing(self): html = 'Goals: 20 (2.5 per game), Goals Against: 11 (1.38 per game)' output = self.team._goals(html) assert output == (None, None, None) def test_expected_goals(self): html = 'xG: 19.3, xGA: 12.1' output = self.team._parse_expected_goals(html) assert output == (None, None, None) def test_missing_home_games_returns_none(self): output = self.team.home_games assert not output def test_missing_away_games_returns_none(self): output = self.team.away_games assert not output def test_invalid_home_wins_returns_none(self): self.team._home_record = 'a-0-0' output = self.team.home_wins assert not output def test_invalid_home_draws_returns_none(self): self.team._home_record = '5-a-0' output = self.team.home_draws assert not output def test_missing_home_draws_returns_none(self): self.team._home_record = '5' output = self.team.home_draws assert not output def test_invalid_home_losses_returns_none(self): self.team._home_record = '5-0-a' output = self.team.home_losses assert not output def test_missing_home_losses_returns_none(self): self.team._home_record = '5-0' output = self.team.home_losses assert not output def test_invalid_home_record_returns_none_for_losses(self): self.team._home_record = None output = self.team.home_losses assert not output def test_invalid_away_wins_returns_none(self): self.team._away_record = 'a-0-0' output = self.team.away_wins assert not output def test_missing_away_draws_returns_none(self): self.team._away_record = '5' output = self.team.away_draws assert not output def test_invalid_away_draws_returns_none(self): self.team._away_record = '5-a-0' output = self.team.away_draws assert not output def test_missing_away_losses_returns_none(self): self.team._away_record = '5-0' output = self.team.away_losses assert not output def test_invalid_away_losses_returns_none(self): self.team._away_record = '5-0-a' output = self.team.away_losses assert not output def test_invalid_away_record_returns_none_for_losses(self): self.team._away_record = None output = self.team.away_losses assert not output def test_fb_schedule_returns_schedule(self): self.team._doc = None assert len(self.team.schedule) == 0 def test_fb_roster_returns_roster(self): self.team._doc = None assert len(self.team.roster) == 0
def test_fb_team_returns_correct_attributes(self, *args, **kwargs): tottenham = Team('Tottenham Hotspur') for attribute, value in self.results.items(): assert getattr(tottenham, attribute) == value
import sys, os sys.path.append(os.path.dirname(os.path.dirname(sys.path[0]))) from sportsreference.fb.team import Team from sportsreference.fb.squad_ids import SQUAD_IDS for team in list(set(SQUAD_IDS.values())): squad = Team(team) print(squad.name) for game in squad.schedule: print(game.date) for player in squad.roster: print(player.name.encode('utf-8'))
def test_team_name(self, *args, **kwargs): team = Team('Tottenham Hotspur') assert team.__repr__() == 'Tottenham Hotspur (361ca564) - 2019-2020'
import logging import sportsreference import numpy from matplotlib import pyplot logging.basicConfig(filename='Final-log' + '.log', format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO) user = input("Please select Premier League or Bundeliga: ") #Split the leagues so it only loaded the teams you needed if user == "Bundesliga": from sportsreference.fb.team import Team Dortmund = Team('add600ae') BMunich = Team('9133b975') Leipzig = Team('acbb6a5b') Monchengladbach = Team('cbefe26c') Leverkusen = Team('c7a9f859') Schalke = Team('c539e393') Wolfsburg = Team('a1393014') Freiburg = Team('b4de690d') Hoffenheim = Team('033ea6b8') Koln = Team('bc357bf7') UnionBerlin = Team('7a41008f') Frankfurt = Team('f0ac8ee6') Augsburg = Team('0cdc4311') Mainz = Team('a224b06a') Dusseldorf = Team('b1278397') Bremen = Team('7adbf480')