def _update_schedule_with_coaches(season, game, homecoach, roadcoach):
    """
    Updates the season schedule file with given coaches' names (which are listed 'N/A' at schedule generation)

    :param season: int, the season
    :param game: int, the game
    :param homecoach: str, the home coach name
    :param roadcoach: str, the road coach name

    :return:
    """

    # Replace coaches with N/A if None b/c feather has trouble with mixed datatypes. Need str here.
    if homecoach is None:
        homecoach = 'N/A'
    if roadcoach is None:
        roadcoach = 'N/A'

    # Edit relevant schedule files
    df = schedules.get_season_schedule(season)
    df.loc[df.Game == game, 'HomeCoach'] = homecoach
    df.loc[df.Game == game, 'RoadCoach'] = roadcoach

    # Write to file and refresh schedule in memory
    schedules.write_season_schedule(df, season, True)
def update_schedule_with_toi_scrape(season, game):
    """
    Updates the schedule file saying that specified game's toi has been scraped.

    :param season: int, the season
    :param game: int, the game, or list of int

    :return: nothing
    """
    df = schedules.get_season_schedule(season)
    if helpers.check_types(game):
        df.loc[df.Game == game, "TOIStatus"] = "Scraped"
    else:
        df.loc[df.Game.isin(game), "TOIStatus"] = "Scraped"
    schedules.write_season_schedule(df, season, True)
    return schedules.get_season_schedule(season)
示例#3
0
def test_write_season_schedule(mocker):

    feather_mock = mocker.patch("scrapenhl2.scrape.schedules.feather")
    dataframe_mock = MagicMock()

    ret = write_season_schedule(dataframe_mock, 2017, True)

    feather_mock.write_dataframe.assert_called_once_with(
        dataframe_mock, get_season_schedule_filename(2017))

    get_season_schedule_mock = mocker.patch(
        "scrapenhl2.scrape.schedules.get_season_schedule")
    panda_mock = mocker.patch("scrapenhl2.scrape.schedules.pd")

    ret = write_season_schedule(dataframe_mock, 2017, False)

    assert get_season_schedule_mock().query.called_once_with("Status != Final")
    assert panda_mock.concat.called_once_with(
        get_season_schedule_mock().query())
def update_schedule_with_result(season, game, result):
    """
    Updates the season schedule file with game result (which are listed 'N/A' at schedule generation)

    :param season: int, the season
    :param game: int, the game
    :param result: str, the result from home team perspective

    :return:
    """

    # Replace coaches with N/A if None b/c feather has trouble with mixed datatypes. Need str here.
    if result is None:
        result = 'N/A'

    # Edit relevant schedule files
    df = schedules.get_season_schedule(season)
    df.loc[df.Game == game, 'Result'] = result

    # Write to file and refresh schedule in memory
    schedules.write_season_schedule(df, season, True)