Exemplo n.º 1
0
    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
Exemplo n.º 2
0
def insertNCAAstats(cur, conn):
    NBA_names = cur.execute("SELECT name FROM players").fetchall()
    NCAA_names = cur.execute("SELECT name FROM NCAA").fetchall()
    count = 0
    current_list = [x[0] for x in NCAA_names]
    name_list = [x[0] for x in NBA_names]
    names = set(name_list)
    name_list = [item for item in names if item not in current_list]
    schools = getSchools()
    seasons = [
        '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014',
        '2015', '2016'
    ]
    for team in schools:
        for x in seasons:
            roster = Roster(team, x, False)
            for player in roster.players:
                if player.name in name_list and player.name not in current_list:
                    if len(current_list) < 100:
                        count += 1
                        if count > 24:
                            break
                    print("Found " + player.name + " played in NCAA in " + x)
                    season = x[:3] + (str(int(x[3]) - 1)) + '-' + (x[2:])
                    if season == '201-1-10':
                        season = '2009-10'
                    games_played = player(season).games_played
                    assist = player(season).assists / games_played
                    rebound = player(season).total_rebounds / games_played
                    block = player(season).blocks / games_played
                    fieldgoals = player(season).field_goal_percentage
                    minutes = player(season).minutes_played / games_played
                    total_points = player(season).points
                    point = player(season).points / games_played
                    steal = player(season).steals / games_played
                    three_point_perc = player(season).three_point_percentage
                    points_per_minute = player(season).points / minutes
                    cur.execute(
                        "INSERT INTO NCAA (name, id, season,total_points,points,assists,rebounds,blocks,steals,field_goal_perc,three_point_percentage,minutes,points_per_minute) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)",
                        (
                            player.name,
                            player.player_id,
                            season,
                            total_points,
                            point,
                            assist,
                            rebound,
                            block,
                            steal,
                            fieldgoals,
                            three_point_perc,
                            minutes,
                            points_per_minute,
                        ))
                    conn.commit()
        if len(current_list) < len(
                cur.execute("SELECT name from NCAA").fetchall()):
            break
Exemplo n.º 3
0
    def test_roster_class_pulls_all_player_stats(self, *args, **kwargs):
        flexmock(utils) \
            .should_receive('_find_year_for_season') \
            .and_return('2018')
        roster = Roster('PURDUE')

        assert len(roster.players) == 3

        for player in roster.players:
            assert player.name in ['Carsen Edwards', 'Isaac Haas',
                                   'Vince Edwards']
Exemplo n.º 4
0
    def test_roster_class_with_slim_parameter(self, *args, **kwargs):
        flexmock(utils) \
            .should_receive('_find_year_for_season') \
            .and_return('2018')
        roster = Roster('PURDUE', slim=True)

        assert len(roster.players) == 3
        assert roster.players == {
            'carsen-edwards-1': 'Carsen Edwards',
            'isaac-haas-1': 'Isaac Haas',
            'vince-edwards-2': 'Vince Edwards'
        }
Exemplo n.º 5
0
    def test_invalid_default_year_reverts_to_previous_year(self,
                                                           *args,
                                                           **kwargs):
        flexmock(utils) \
            .should_receive('_find_year_for_season') \
            .and_return(2019)

        roster = Roster('PURDUE')

        assert len(roster.players) == 3

        for player in roster.players:
            assert player.name in ['Carsen Edwards', 'Isaac Haas',
                                   'Vince Edwards']
def get_player_id(school, start, end):
    """
    Creates csv with all player_ids from [X] school
    
    Parameters : school (string) - A string containing the abbreviation of team name
                 start (int) - Beginning year of search
                 end (int) -  last year of search - 1
    """
    player_id = []
    for i in range(start, end):
        for player in Roster(school, i).players:
            player_id.append(player.player_id)

    #
    player_id = set(player_id)

    # Output list of player_id to a csv file
    with open('sportsref_Data/%s_player_id.csv' % school, 'w',
              newline='') as result_file:
        wr = csv.writer(result_file, quoting=csv.QUOTE_ALL)
        wr.writerow(player_id)
Exemplo n.º 7
0
 def test_coach(self):
     assert "Matt Painter" == Roster('PURDUE', year=YEAR).coach
Exemplo n.º 8
0
 def test_bad_url_raises_value_error(self, *args, **kwargs):
     with pytest.raises(ValueError):
         roster = Roster('BAD')