Example #1
0
def test_deposit_withdraw(boatrace_tools: PyJPBoatrace):
    # pre-status
    current = boatrace_tools.get_bet_limit()
    # deposit
    num = 1000
    boatrace_tools.deposit(num // 1000)
    time.sleep(10)
    after = boatrace_tools.get_bet_limit()
    assert after == current + num
    # withdraw
    boatrace_tools.withdraw()
    time.sleep(10)
    current = boatrace_tools.get_bet_limit()
    assert current == 0
Example #2
0
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'])