Exemple #1
0
def test_get_player_week_stats():
	stats = Stats()
	week_stats = stats.get_week_stats("regular", 2018, 5)
	player_week_stats = stats.get_player_week_stats(week_stats, "1262")

	assert isinstance(player_week_stats, dict)

	player_week_stats = stats.get_player_week_stats(week_stats, "300000000")
	assert player_week_stats is None
Exemple #2
0
def get_stats_projections_and_diff_for_player(player_id, scoring_settings):
    stats = Stats()
    player_pts_by_week = {}

    for week in all_weeks_stats:
        player_week_stats = stats.get_player_week_stats(week, player_id)
        player_pts_by_week[week[0]['week']] = {"stats": {}, "projections": {}}
        if player_week_stats is not None:
            pts = utils.calculate_points(scoring_settings,
                                         player_week_stats['stats'])
            player_pts_by_week[week[0]['week']]['stats'] = round(pts, 2)
        else:
            player_pts_by_week[week[0]['week']]['stats'] = 'BYE'

    for week in all_weeks_projections:
        player_week_projections = stats.get_player_week_projections(
            week, player_id)
        if player_week_projections is not None:
            pts = utils.calculate_points(scoring_settings,
                                         player_week_projections['stats'])
            player_pts_by_week[week[0]['week']]['projections'] = round(pts, 2)
        else:
            player_pts_by_week[week[0]['week']]['projections'] = 'BYE'

    for week, stats in player_pts_by_week.items():
        if stats['stats'] != 'BYE':
            player_pts_by_week[week]["difference"] = round(
                float(player_pts_by_week[week]['stats']) -
                float(player_pts_by_week[week]['projections']), 2)

    return player_pts_by_week