def test_statcast() -> None: result = statcast('2019-05-01', '2019-05-04') assert result is not None assert not result.empty assert len(result.columns) == CURRENT_SC_COLUMNS assert len(result) > 0
def test_statcast() -> None: result = statcast('2019-05-01', '2019-05-04') assert result is not None assert not result.empty assert len(result.columns) == 89 assert len(result) == 16130
def test_statcast_chunking() -> None: result = statcast('2019-05-01', '2019-05-15').reset_index(drop=True) assert result is not None assert not result.empty day_results = [] start_date = date(2019, 5, 1) for day in range(15): day_results.append(statcast(str(start_date + timedelta(days=day)))) day_results_dataframe = pd.concat( day_results, axis=0).convert_dtypes(convert_string=False) day_results_dataframe = day_results_dataframe.sort_values( ['game_date', 'game_pk', 'at_bat_number', 'pitch_number'], ascending=False).reset_index(drop=True) assert list(result.columns) == list(day_results_dataframe.columns) assert len(result) == len(day_results_dataframe)
def test_statcast(response_get_monkeypatch: Callable, small_request_raw: str, small_request: pd.DataFrame) -> None: start_dt, end_dt = sanitize_date_range(None, None) response_get_monkeypatch( small_request_raw.encode('UTF-8'), _SC_SMALL_REQUEST.format(start_dt=start_dt, end_dt=end_dt, team='')) statcast_result = statcast().reset_index(drop=True) pd.testing.assert_frame_equal(statcast_result, small_request, check_dtype=False)
def test_statcast( self, response_get_monkeypatch: Callable, small_request_raw: str, small_request: pd.DataFrame ): start_dt, end_dt = sanitize_input(None, None) response_get_monkeypatch( small_request_raw.encode('UTF-8'), _SC_SMALL_REQUEST.format( start_dt=start_dt, end_dt=end_dt ) ) statcast_result = statcast().reset_index(drop=True) pd.testing.assert_frame_equal(statcast_result, small_request)