Ejemplo n.º 1
0
def test_parse_showdown():
    parser = PokerStarsParser("")

    line = "onucee: shows [7s 9d] (a pair of Eights)\n"\
           "MaGiCLeTuR: shows [2s Ah] (two pair, Eights and Deuces)\n"\
           "MaGiCLeTuR collected 120 from pot"

    parser.hand_id = 202004455940
    parser.game_id = 2642898548
    parser.buy_in = 1
    parser.small_blind = 10
    parser.big_blind = 20
    parser.positions["BTN"] = "leti5795"
    parser.positions["SB"] = "onucee"
    parser.positions["BB"] = "MaGiCLeTuR"
    parser.stacks["BTN"] = 500
    parser.stacks["SB"] = 500
    parser.stacks["BB"] = 500
    parser.players["leti5795"] = "BTN"
    parser.players["onucee"] = "SB"
    parser.players["MaGiCLeTuR"] = "BB"

    parser.part_dict['SHOW DOWN'] = line

    parser.parse_showdown()
    assert parser.cards["SB"].__len__() == 2

    assert parser.cards["SB"][0] == Card(Value.SEVEN, Color.SPADES)
    assert parser.cards["SB"][1] == Card(Value.NINE, Color.DIAMONDS)

    assert parser.cards["BB"].__len__() == 2
    assert parser.cards["BB"][0] == Card(Value.TWO, Color.SPADES)
    assert parser.cards["BB"][1] == Card(Value.ACE, Color.HEARTS)
Ejemplo n.º 2
0
def test_parse_preflop():
    # TODO: create a fixture for the initialization
    parser = PokerStarsParser("")

    line = "Dealt to MaGiCLeTuR [2s Ah]\n" \
           "leti5795: calls 20\n" \
           "onucee: calls 10\n" \
           "MaGiCLeTuR: checks"

    parser.hand_id = 202004455940
    parser.game_id = 2642898548
    parser.buy_in = 1
    parser.small_blind = 10
    parser.big_blind = 20
    parser.positions["BTN"] = "leti5795"
    parser.positions["SB"] = "onucee"
    parser.positions["BB"] = "MaGiCLeTuR"
    parser.stacks["BTN"] = 500
    parser.stacks["SB"] = 500
    parser.stacks["BB"] = 500
    parser.players["leti5795"] = "BTN"
    parser.players["onucee"] = "SB"
    parser.players["MaGiCLeTuR"] = "BB"

    parser.part_dict['HOLE CARDS'] = line

    parser.parse_preflop()

    assert parser.cards["BB"][0] == Card(Value.TWO, Color.SPADES)
    assert parser.cards["BB"][1] == Card(Value.ACE, Color.HEARTS)

    assert parser.action_preflop.__len__() == 3
    assert parser.action_preflop[0] == Action("BTN", ActionType.CALL, 20)
    assert parser.action_preflop[1] == Action("SB", ActionType.CALL, 10)
    assert parser.action_preflop[2] == Action("BB", ActionType.CHECK, 0)
Ejemplo n.º 3
0
def test_parse_river():
    parser = PokerStarsParser("")

    line = "[5s 8c Tc 2h] [Th]\n" \
           "leti5795: calls 20\n" \
           "onucee: calls 10\n" \
           "MaGiCLeTuR: checks"

    parser.hand_id = 202004455940
    parser.game_id = 2642898548
    parser.buy_in = 1
    parser.small_blind = 10
    parser.big_blind = 20
    parser.positions["BTN"] = "leti5795"
    parser.positions["SB"] = "onucee"
    parser.positions["BB"] = "MaGiCLeTuR"
    parser.stacks["BTN"] = 500
    parser.stacks["SB"] = 500
    parser.stacks["BB"] = 500
    parser.players["leti5795"] = "BTN"
    parser.players["onucee"] = "SB"
    parser.players["MaGiCLeTuR"] = "BB"

    parser.part_dict['RIVER'] = line

    parser.parse_river()

    assert parser.board_river.__len__() == 1
    assert parser.board_river[0] == Card(Value.TEN, Color.HEARTS)

    assert parser.action_river.__len__() == 3
    assert parser.action_river[0] == Action("BTN", ActionType.CALL, 20)
    assert parser.action_river[1] == Action("SB", ActionType.CALL, 10)
    assert parser.action_river[2] == Action("BB", ActionType.CHECK, 0)