コード例 #1
0
def test_get_race_result_cancelled_race(boatrace_tools: PyJPBoatrace):
    # CANCELLED RACERS CASE #
    # preparation
    d = date(2019, 1, 26)
    stadium = 8
    race = 8
    # assert
    with pytest.raises(RaceCancelledException):
        boatrace_tools.get_race_result(d, stadium, race)
コード例 #2
0
def test_get_race_result_not_yet(mock_chrome):
    # NOT YET DISPLAYED CASE#
    # preparation: anything OK
    d = date(2020, 11, 29)
    stadium = 10
    race = 2
    # set mock
    mock_chrome.page_source = get_mock_html("not_yet_raceresult.html")

    # assert
    pyjpboatrace = PyJPBoatrace(driver=mock_chrome)
    with pytest.raises(NoDataException):
        pyjpboatrace.get_race_result(d, stadium, race)

    # close
    mock_chrome.close()
コード例 #3
0
def test_get_race_result_invalid_arguments(boatrace_tools: PyJPBoatrace):

    # TODO invalid args test for get_stadiums
    # TODO invalid args test for get_12races
    # TODO invalid args test for get_just_before_info
    # TODO invalid args test for get_race_info
    # TODO invalid args test for get_odds_win_placeshow
    # TODO invalid args test for get_odds_quinellaplace
    # TODO invalid args test for get_odds_exacta_quinella
    # TODO invalid args test for get_odds_trifecta
    # TODO invalid args test for get_odds_trio

    # invalid date
    d = (datetime.today() + timedelta(days=1)).date()
    stadium = 10
    race = 2
    # msg = f'Date d must be before today. {d} is given.'
    with pytest.raises(ValueError):
        boatrace_tools.get_race_result(d, stadium, race)

    # invalid stadium
    d = datetime.today().date()
    stadium = 0
    race = 2
    # msg = f'Stadium must be between 1 and 24. {stadium} is given.'
    with pytest.raises(ValueError):
        boatrace_tools.get_race_result(d, stadium, race)

    # invalid race
    d = datetime.today().date()
    stadium = 10
    race = 13
    # msg = f'Race must be between 1 and 12. {race} is given.'
    with pytest.raises(ValueError):
        boatrace_tools.get_race_result(d, stadium, race)
コード例 #4
0
def test_get_race_result(boatrace_tools: PyJPBoatrace):
    # USUAL CASE #
    # preparation
    d = date(2020, 10, 24)
    dstr = d.strftime('%Y%m%d')
    stadium = 14
    race = 1
    # load true data
    expected = get_expected_json(
        f'expected_raceresult.rno={race}&jcd={stadium:02d}&hd={dstr}.json', )
    # actual data
    actual = boatrace_tools.get_race_result(d, stadium, race)
    # assertion
    assert actual == expected