def test_get_real_time_odds(method_name: str, boatrace_tools: PyJPBoatrace): # preparation today = date.today() stadiums = boatrace_tools.get_stadiums(today) # search active race for stadium_str, dic in stadiums.items(): if stadium_str not in (s for _, s in STADIUMS_MAP): continue if "R以降発売中" in dic["status"]: race = dic["next_race"] stadium = {k: v for v, k in STADIUMS_MAP}.get(stadium_str) break else: raise Exception("Failed to find any active race.") # actual data actual: Dict[str, Any] actual = boatrace_tools.__getattribute__(method_name)(today, stadium, race) # assertion assert actual.get("date") == today.strftime("%Y-%m-%d") assert actual.get("stadium") == stadium assert actual.get("race") == race assert re.fullmatch(r"(\d|\d\d):\d\d", actual.get("update"))
def test_get_stadiums(boatrace_tools: PyJPBoatrace): # preparation d = date(2020, 9, 8) dstr = d.strftime('%Y%m%d') # expectation expected = get_expected_json(f"expected_index.hd={dstr}.json") # actual actual = boatrace_tools.get_stadiums(d) # 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'])