def test_batting_stats(self, response_get_monkeypatch: Callable, test_batting_stats_html: str, test_batting_stats_result: pd.DataFrame): season = 2019 query_params = urllib.parse.urlencode( { 'pos': 'all', 'stats': 'bat', 'lg': 'all', 'qual': 'y', 'type': stat_list_to_str(FangraphsBattingStats.ALL()), 'season': season, 'month': 0, 'season1': season, 'ind': '1', 'team': '', 'rost': '0', 'age': f"{MIN_AGE},{MAX_AGE}", 'filter': '', 'players': '', 'page': f'1_1000000' }, safe=',') expected_url = f"{_FG_LEADERS_URL}?{query_params}" response_get_monkeypatch(test_batting_stats_html, expected_url) batting_stats_result = fg_batting_data(season).reset_index(drop=True) pd.testing.assert_frame_equal(batting_stats_result, test_batting_stats_result)
def test_team_fielding_custom_types( self, response_get_monkeypatch: Callable, test_team_fielding_html: str, test_team_fielding_result: pd.DataFrame): season = 2019 query_params = urllib.parse.urlencode( { 'pos': 'all', 'stats': 'fld', 'lg': 'all', 'qual': 'y', 'type': stat_list_to_str([ FangraphsFieldingStats.COMMON, FangraphsFieldingStats.ULTIMATE_ZONE_RATING ], replace_common=False), 'season': season, 'month': 0, 'season1': season, 'ind': '1', 'team': '0,ts', 'rost': '0', 'age': f"{MIN_AGE},{MAX_AGE}", 'filter': '', 'players': '', 'page': f'1_1000000' }, safe=',') expected_url = f"{_FG_LEADERS_URL}?{query_params}" response_get_monkeypatch(test_team_fielding_html, expected_url) team_fielding_result = fg_team_fielding_data( season, stat_columns='ULTIMATE_ZONE_RATING').reset_index(drop=True) pd.testing.assert_frame_equal(team_fielding_result, test_team_fielding_result)