def test_get_12races(boatrace_tools: PyJPBoatrace): # preparation d = date(2020, 10, 8) dstr = d.strftime('%Y%m%d') stadium = 1 # expectation expected = get_expected_json( f"expected_raceindex.jcd={stadium:02d}&hd={dstr}.json", ) # actual actual = boatrace_tools.get_12races(d, stadium) # assertion assert actual == expected
def test_bet(boatrace_tools: PyJPBoatrace): # preparation current = boatrace_tools.get_bet_limit() if current <= 700: # deposit num = 1000 boatrace_tools.deposit(num // 1000) time.sleep(10) # scrape stadiums/races stadiums_dic = boatrace_tools.get_stadiums(date.today()) _flag = False for key in stadiums_dic: stadium = {s: i for i, s in STADIUMS_MAP}.get(key) races_dic = boatrace_tools.get_12races(date.today(), stadium) for r, dic in races_dic.items(): if dic.get("status") == "投票": race = int(r[:-1]) _flag = True break if _flag: break time.sleep(2) if not _flag: raise Exception("Failed to find any active races.") # bet list betdict = { 'trifecta': { '1-2-4': 100 }, 'trio': { '2=3=4': 100 }, 'exacta': { '2-1': 100 }, 'quinella': { '3=4': 100 }, 'quinellaplace': { '2=6': 100 }, 'win': { '5': 100 }, 'placeshow': { '6': 100 }, } assert boatrace_tools.bet( stadium=stadium, race=race, trifecta_betting_dict=betdict['trifecta'], trio_betting_dict=betdict['trio'], exacta_betting_dict=betdict['exacta'], quinella_betting_dict=betdict['quinella'], quinellaplace_betting_dict=betdict['quinellaplace'], win_betting_dict=betdict['win'], placeshow_betting_dict=betdict['placeshow'])