Ejemplo n.º 1
0
 def test_player_encoding_without_combo(self, json_encoder):
     hero = _Player(name="pokerHero",
                    stack=Decimal('1.86'),
                    seat=3,
                    combo=None)
     assert json_encoder.encode(
         hero) == "{\"name\": \"pokerHero\", \"stack\": 1.86, \"seat\": 3}"
Ejemplo n.º 2
0
 def test_player_encoding_with_combo(self, json_encoder):
     hero_combo = Combo.from_cards(Card("Ad"), Card("Kc"))
     hero = _Player(name="pokerHero",
                    stack=Decimal('1.86'),
                    seat=3,
                    combo=hero_combo)
     expected = "{\"name\": \"pokerHero\", \"stack\": 1.86, \"seat\": 3, \"hand\": " \
                "{\"1\": {\"rank\": \"A\", \"suit\": \"DIAMONDS\"}, \"2\": {\"rank\": \"K\", \"suit\": \"CLUBS\"}}}"
     assert json_encoder.encode(hero) == expected
Ejemplo n.º 3
0
class TestHoldemHand:
    hand_text = HANDS['holdem_full']

    @pytest.mark.parametrize('attribute, expected_value', [
        ('game_type', GameType.CASH),
        ('sb', D('0.25')),
        ('bb', D('0.50')),
        ('date', UTC.localize(datetime(2013, 10, 5, 1, 15, 45))),
        ('game', Game.HOLDEM),
        ('limit', Limit.NL),
        ('ident', '2433297728'),
        ('tournament_ident', None),
        ('tournament_name', None),
        ('tournament_level', None),
        ('table_name', "#52121155 - Rapanui's Leela"),
        ('buyin', D('50')),
        ('currency', Currency.USD),
    ])
    def test_header(self, hand_header, attribute, expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(
        'attribute, expected_value',
        [
            ('players', [
                _Player(name='laxi23', stack=D('51.89'), seat=1, combo=None),
                _Player(name='NikosMRF', stack=D('50'), seat=2, combo=None),
                _Player(name='Capricorn', stack=D('33.6'), seat=3, combo=None),
                _Player(
                    name='Walkman', stack=D('50'), seat=4,
                    combo=Combo('9s6d')),
                _Player(name='Empty Seat 5', stack=0, seat=5, combo=None),
                _Player(name='barly123', stack=D('50.35'), seat=6, combo=None),
            ]),
            ('button',
             _Player(name='Capricorn', stack=D('33.6'), seat=3, combo=None)),
            ('max_players', 6),  # maybe imprecise
            ('hero',
             _Player(
                 name='Walkman', stack=D('50'), seat=4, combo=Combo('9s6d'))),
            ('preflop_actions',
             ('laxi23 folds', 'Capricorn calls $0.50', 'Walkman folds',
              'barly123 raises to $1.25', 'Capricorn calls $1.25')),
            ('turn', Card('Js')),
            ('turn_pot', D('10.97')),
            ('turn_actions',
             ('barly123 checks', 'Capricorn checks', 'Pot sizes: $10.97')),
            ('river', Card('5h')),
            ('river_pot', D('10.97')),
            ('river_actions',
             ('barly123 checks', 'Capricorn checks', 'Pot sizes: $10.97')),
            ('total_pot', D('10.97')),
            ('rake', D('0.54')),
            ('winners', ('barly123', )),
            ('show_down', True),
            ('board',
             (Card('7d'), Card('3c'), Card('Jd'), Card('Js'), Card('5h'))),
            ('extra', dict(money_type=MoneyType.REAL,
                           last_ident='2433297369')),
        ])
    def test_body(self, hand, attribute, expected_value):
        assert getattr(hand, attribute) == expected_value

    @pytest.mark.parametrize(
        ('attribute', 'expected_value'), [('actions', (
            _PlayerAction('barly123', Action.CHECK, None),
            _PlayerAction('Capricorn', Action.BET, D('1.37')),
            _PlayerAction('barly123', Action.RAISE, D('4.11')),
            _PlayerAction('Capricorn', Action.CALL, D('4.11')),
        )), ('cards', (Card('7d'), Card('3c'), Card('Jd'))),
                                          ('is_rainbow', False),
                                          ('is_monotone', False),
                                          ('is_triplet', False),
                                          ('has_pair', False),
                                          ('has_straightdraw', False),
                                          ('has_gutshot', True),
                                          ('has_flushdraw', True),
                                          ('players',
                                           ('barly123', 'Capricorn')),
                                          ('pot', D('10.97'))])
    def test_flop_attributes(self, hand, attribute, expected_value):
        assert getattr(hand.flop, attribute) == expected_value

    def test_flop(self, hand):
        assert isinstance(hand.flop, _Street)
Ejemplo n.º 4
0
class TestHandWithFlopOnly:
    hand_text = stars_hands.HAND1

    # in py.test 2.4 it is recommended to use string like "attribute,expected",
    # but with tuple, it works in both 2.3.5 and 2.4
    @pytest.mark.parametrize(
        ('attribute', 'expected_value'),
        [('ident', '105024000105'), ('game_type', GameType.TOUR),
         ('tournament_ident', '797469411'), ('tournament_level', 'I'),
         ('currency', Currency.USD), ('buyin', Decimal('3.19')),
         ('rake', Decimal('0.31')), ('game', Game.HOLDEM), ('limit', Limit.NL),
         ('sb', Decimal(10)), ('bb', Decimal(20)),
         ('date', ET.localize(datetime(2013, 10, 4, 13, 53, 27)))])
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(('attribute', 'expected_value'), [
        ('table_name', '797469411 15'),
        ('max_players', 9),
        ('button', _Player(name='flettl2', stack=1500, seat=1, combo=None)),
        ('hero',
         _Player(name='W2lkm2n', stack=3000, seat=5, combo=Combo('AcJh'))),
        ('players', [
            _Player(name='flettl2', stack=1500, seat=1, combo=None),
            _Player(name='santy312', stack=3000, seat=2, combo=None),
            _Player(name='flavio766', stack=3000, seat=3, combo=None),
            _Player(name='strongi82', stack=3000, seat=4, combo=None),
            _Player(name='W2lkm2n', stack=3000, seat=5, combo=Combo('AcJh')),
            _Player(name='MISTRPerfect', stack=3000, seat=6, combo=None),
            _Player(name='blak_douglas', stack=3000, seat=7, combo=None),
            _Player(name='sinus91', stack=1500, seat=8, combo=None),
            _Player(name='STBIJUJA', stack=1500, seat=9, combo=None),
        ]),
        ('turn', None),
        ('river', None),
        ('board', (Card('2s'), Card('6d'), Card('6h'))),
        ('preflop_actions',
         ("strongi82: folds", "W2lkm2n: raises 40 to 60",
          "MISTRPerfect: calls 60", "blak_douglas: folds", "sinus91: folds",
          "STBIJUJA: folds", "flettl2: folds", "santy312: folds",
          "flavio766: folds")),
        ('turn_actions', None),
        ('river_actions', None),
        ('total_pot', Decimal(150)),
        ('show_down', False),
        ('winners', ('W2lkm2n', )),
    ])
    def test_body(self, hand, attribute, expected_value):
        assert getattr(hand, attribute) == expected_value

    @pytest.mark.parametrize(
        ('attribute', 'expected_value'),
        [
            ('actions', (
                _PlayerAction('W2lkm2n', Action.BET, Decimal(80)),
                _PlayerAction('MISTRPerfect', Action.FOLD, None),
                _PlayerAction('W2lkm2n', Action.RETURN, Decimal(80)),
                _PlayerAction('W2lkm2n', Action.WIN, Decimal(150)),
                _PlayerAction('W2lkm2n', Action.MUCK, None),
            )),
            ('cards', (Card('2s'), Card('6d'), Card('6h'))),
            ('is_rainbow', True),
            ('is_monotone', False),
            ('is_triplet', False),
            # TODO: http://www.pokerology.com/lessons/flop-texture/
            # assert flop.is_dry
            ('has_pair', True),
            ('has_straightdraw', False),
            ('has_gutshot', True),
            ('has_flushdraw', False),
            ('players', ('W2lkm2n', 'MISTRPerfect')),
            ('pot', Decimal(150))
        ])
    def test_flop_attributes(self, hand, attribute, expected_value):
        assert getattr(hand.flop, attribute) == expected_value

    def test_flop(self, hand):
        assert isinstance(hand.flop, _Street)
Ejemplo n.º 5
0
class TestBodyMissingPlayerNoBoard:
    hand_text = stars_hands.HAND3

    @pytest.mark.parametrize(
        ('attribute', 'expected_value'),
        [('ident', '105026771696'), ('game_type', GameType.TOUR),
         ('tournament_ident', '797469411'), ('tournament_level', 'X'),
         ('currency', Currency.USD), ('buyin', Decimal('3.19')),
         ('rake', Decimal('0.31')), ('game', Game.HOLDEM), ('limit', Limit.NL),
         ('sb', Decimal(300)), ('bb', Decimal(600)),
         ('date', ET.localize(datetime(2013, 10, 4, 14, 50, 56)))])
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(('attribute', 'expected_value'), [
        ('table_name', '797469411 11'),
        ('max_players', 9),
        ('button',
         _Player(name='W2lkm2n', stack=10714, seat=8, combo=Combo('6d8d'))),
        ('hero',
         _Player(name='W2lkm2n', stack=10714, seat=8, combo=Combo('6d8d'))),
        ('players', [
            _Player(name='Empty Seat 1', stack=0, seat=1, combo=None),
            _Player(name='snelle_jel', stack=4295, seat=2, combo=None),
            _Player(name='EuSh0wTelm0', stack=11501, seat=3, combo=None),
            _Player(name='panost3', stack=7014, seat=4, combo=None),
            _Player(name='Samovlyblen', stack=7620, seat=5, combo=None),
            _Player(name='Theralion', stack=4378, seat=6, combo=None),
            _Player(name='wrsport1015', stack=9880, seat=7, combo=None),
            _Player(name='W2lkm2n', stack=10714, seat=8, combo=Combo('6d8d')),
            _Player(name='fischero68', stack=8724, seat=9, combo=None),
        ]),
        ('turn', None),
        ('river', None),
        ('board', None),
        ('preflop_actions',
         ('EuSh0wTelm0: folds', 'panost3: folds', 'Samovlyblen: folds',
          'Theralion: raises 600 to 1200', 'wrsport1015: folds',
          'W2lkm2n: folds', 'fischero68: folds', 'snelle_jel: folds',
          'Uncalled bet (600) returned to Theralion',
          'Theralion collected 1900 from pot',
          "Theralion: doesn't show hand")),
        ('turn_actions', None),
        ('river_actions', None),
        ('total_pot', Decimal(1900)),
        ('show_down', False),
        ('winners', ('Theralion', )),
    ])
    def test_body(self, hand, attribute, expected_value):
        assert getattr(hand, attribute) == expected_value

    def test_flop(self, hand):
        assert hand.flop is None
Ejemplo n.º 6
0
class TestBodyEveryStreet:
    hand_text = stars_hands.HAND4

    @pytest.mark.parametrize(
        ('attribute', 'expected_value'),
        [('ident', '105025168298'), ('game_type', GameType.TOUR),
         ('tournament_ident', '797469411'), ('tournament_level', 'IV'),
         ('currency', Currency.USD), ('buyin', Decimal('3.19')),
         ('rake', Decimal('0.31')), ('game', Game.HOLDEM), ('limit', Limit.NL),
         ('sb', Decimal(50)), ('bb', Decimal(100)),
         ('date', ET.localize(datetime(2013, 10, 4, 14, 19, 17)))])
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(('attribute', 'expected_value'), [
        ('table_name', '797469411 15'),
        ('max_players', 9),
        ('button',
         _Player(name='W2lkm2n', stack=5145, seat=5, combo=Combo('Jc5c'))),
        ('hero',
         _Player(name='W2lkm2n', stack=5145, seat=5, combo=Combo('Jc5c'))),
        ('players', [
            _Player(name='flettl2', stack=3000, seat=1, combo=None),
            _Player(name='santy312', stack=5890, seat=2, combo=None),
            _Player(name='flavio766', stack=11010, seat=3, combo=None),
            _Player(name='strongi82', stack=2855, seat=4, combo=None),
            _Player(name='W2lkm2n', stack=5145, seat=5, combo=Combo('Jc5c')),
            _Player(name='MISTRPerfect', stack=2395, seat=6, combo=None),
            _Player(name='blak_douglas', stack=3000, seat=7, combo=None),
            _Player(name='sinus91', stack=3000, seat=8, combo=None),
            _Player(name='STBIJUJA', stack=1205, seat=9, combo=None),
        ]),
        ('turn', Card('8c')),
        ('river', Card('Kd')),
        ('board',
         (Card('6s'), Card('4d'), Card('3s'), Card('8c'), Card('Kd'))),
        ('preflop_actions',
         ('sinus91: folds', 'STBIJUJA: folds', 'flettl2: raises 125 to 225',
          'santy312: folds', 'flavio766: folds', 'strongi82: folds',
          'W2lkm2n: folds', 'MISTRPerfect: folds', 'blak_douglas: calls 125')),
        ('turn_actions', ('blak_douglas: checks', 'flettl2: bets 250',
                          'blak_douglas: calls 250')),
        ('river_actions',
         ('blak_douglas: checks', 'flettl2: bets 1300', 'blak_douglas: folds',
          'Uncalled bet (1300) returned to flettl2',
          'flettl2 collected 1300 from pot', "flettl2: doesn't show hand")),
        ('total_pot', Decimal(1300)),
        ('show_down', False),
        ('winners', ('flettl2', )),
    ])
    def test_body(self, hand, attribute, expected_value):
        assert getattr(hand, attribute) == expected_value

    @pytest.mark.parametrize(
        ('attribute', 'expected_value'),
        [
            ('actions', (
                _PlayerAction('blak_douglas', Action.CHECK, None),
                _PlayerAction('flettl2', Action.BET, Decimal(150)),
                _PlayerAction('blak_douglas', Action.CALL, Decimal(150)),
            )),
            ('cards', (Card('6s'), Card('4d'), Card('3s'))),
            ('is_rainbow', False),
            ('is_monotone', False),
            ('is_triplet', False),
            # TODO: http://www.pokerology.com/lessons/flop-texture/
            # assert flop.is_dry
            ('has_pair', False),
            ('has_straightdraw', True),
            ('has_gutshot', True),
            ('has_flushdraw', True),
            ('players', ('blak_douglas', 'flettl2')),
        ])
    def test_flop_attributes(self, hand, attribute, expected_value):
        assert getattr(hand.flop, attribute) == expected_value

    def test_flop(self, hand):
        assert isinstance(hand.flop, _Street)

    @pytest.mark.xfail
    def test_flop_pot(self, hand):
        assert hand.flop.pot == Decimal(800)
Ejemplo n.º 7
0
class TestBodyEveryStreet:
    hand_text = stars_hands.HAND4

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("ident", "105025168298"),
            ("game_type", GameType.TOUR),
            ("tournament_ident", "797469411"),
            ("tournament_level", "IV"),
            ("currency", Currency.USD),
            ("buyin", Decimal("3.19")),
            ("rake", Decimal("0.31")),
            ("game", Game.HOLDEM),
            ("limit", Limit.NL),
            ("sb", Decimal(50)),
            ("bb", Decimal(100)),
            ("date", ET.localize(datetime(2013, 10, 4, 14, 19, 17))),
        ],
    )
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("table_name", "797469411 15"),
            ("max_players", 9),
            (
                "button",
                _Player(
                    name="W2lkm2n", stack=5145, seat=5, combo=Combo("Jc5c")),
            ),
            ("hero",
             _Player(name="W2lkm2n", stack=5145, seat=5, combo=Combo("Jc5c"))),
            (
                "players",
                [
                    _Player(name="flettl2", stack=3000, seat=1, combo=None),
                    _Player(name="santy312", stack=5890, seat=2, combo=None),
                    _Player(name="flavio766", stack=11010, seat=3, combo=None),
                    _Player(name="strongi82", stack=2855, seat=4, combo=None),
                    _Player(name="W2lkm2n",
                            stack=5145,
                            seat=5,
                            combo=Combo("Jc5c")),
                    _Player(
                        name="MISTRPerfect", stack=2395, seat=6, combo=None),
                    _Player(
                        name="blak_douglas", stack=3000, seat=7, combo=None),
                    _Player(name="sinus91", stack=3000, seat=8, combo=None),
                    _Player(name="STBIJUJA", stack=1205, seat=9, combo=None),
                ],
            ),
            ("board",
             (Card("6s"), Card("4d"), Card("3s"), Card("8c"), Card("Kd"))),
            (
                "preflop",
                (_Street([
                    "",
                    "MISTRPerfect: posts small blind 50",
                    "blak_douglas: posts big blind 100",
                    "sinus91: folds",
                    "STBIJUJA: folds",
                    "flettl2: raises 125 to 225",
                    "santy312: folds",
                    "flavio766: folds",
                    "strongi82: folds",
                    "W2lkm2n: folds",
                    "MISTRPerfect: folds",
                    "blak_douglas: calls 125",
                ])),
            ),
            (
                "turn",
                (_Street([
                    "[6s 4d 3s] [8c]",
                    "blak_douglas: checks",
                    "flettl2: bets 250",
                    "blak_douglas: calls 250",
                ])),
            ),
            (
                "river",
                (_Street([
                    "[6s 4d 3s 8c] [Kd]",
                    "blak_douglas: checks",
                    "flettl2: bets 1300",
                    "blak_douglas: folds",
                    "Uncalled bet (1300) returned to flettl2",
                    "flettl2 collected 1300 from pot",
                    "flettl2: doesn't show hand",
                ])),
            ),
            ("total_pot", Decimal(1300)),
            ("show_down", None),
            ("winners", ("flettl2", )),
        ],
    )
    def test_body(self, hand, attribute, expected_value):
        attribute = getattr(hand, attribute)
        if (attribute is not None) & isinstance(attribute, _Street):
            assert attribute.actions == expected_value.actions
            assert attribute.cards == expected_value.cards
        else:
            assert attribute == expected_value

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            (
                "actions",
                (
                    _PlayerAction("blak_douglas", Action.CHECK, None),
                    _PlayerAction("flettl2", Action.BET, Decimal(150)),
                    _PlayerAction("blak_douglas", Action.CALL, Decimal(150)),
                ),
            ),
            ("cards", (Card("6s"), Card("4d"), Card("3s"))),
            ("is_rainbow", False),
            ("is_monotone", False),
            ("is_triplet", False),
            # TODO: http://www.pokerology.com/lessons/flop-texture/
            # assert flop.is_dry
            ("has_pair", False),
            ("has_straightdraw", True),
            ("has_gutshot", True),
            ("has_flushdraw", True),
            ("players", ("blak_douglas", "flettl2")),
        ],
    )
    def test_flop_attributes(self, hand, attribute, expected_value):
        assert getattr(hand.flop, attribute) == expected_value

    def test_flop(self, hand):
        assert isinstance(hand.flop, _Street)
Ejemplo n.º 8
0
class TestHandWithFlopOnly:
    hand_text = ftp_hands.HAND1

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("game_type", GameType.TOUR),
            ("sb", Decimal(10)),
            ("bb", Decimal(20)),
            ("date", ET.localize(datetime(2013, 9, 22, 13, 26, 50))),
            ("game", Game.HOLDEM),
            ("limit", Limit.NL),
            ("ident", "33286946295"),
            ("tournament_ident", "255707037"),
            ("table_name", "179"),
            ("tournament_level", None),
            ("buyin", None),
            ("rake", None),
            ("currency", None),
        ],
    )
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(
        "attribute,expected_value",
        [
            (
                "players",
                [
                    _Player(name="Popp1987", stack=13587, seat=1, combo=None),
                    _Player(
                        name="Luckytobgood", stack=10110, seat=2, combo=None),
                    _Player(
                        name="FatalRevange", stack=9970, seat=3, combo=None),
                    _Player(name="IgaziFerfi",
                            stack=10000,
                            seat=4,
                            combo=Combo("Ks9d")),
                    _Player(name="egis25", stack=6873, seat=5, combo=None),
                    _Player(name="gamblie", stack=9880, seat=6, combo=None),
                    _Player(name="idanuTz1", stack=10180, seat=7, combo=None),
                    _Player(name="PtheProphet", stack=9930, seat=8,
                            combo=None),
                    _Player(name="JohnyyR", stack=9840, seat=9, combo=None),
                ],
            ),
            ("button", _Player(name="egis25", stack=6873, seat=5, combo=None)),
            ("max_players", 9),
            (
                "hero",
                _Player(name="IgaziFerfi",
                        stack=10000,
                        seat=4,
                        combo=Combo("Ks9d")),
            ),
            (
                "preflop_actions",
                (
                    "PtheProphet has 15 seconds left to act",
                    "PtheProphet folds",
                    "JohnyyR raises to 40",
                    "Popp1987 has 15 seconds left to act",
                    "Popp1987 folds",
                    "Luckytobgood folds",
                    "FatalRevange raises to 100",
                    "IgaziFerfi folds",
                    "egis25 folds",
                    "gamblie folds",
                    "idanuTz1 folds",
                    "JohnyyR has 15 seconds left to act",
                    "JohnyyR calls 60",
                ),
            ),
            ("turn", None),
            ("river", None),
            ("total_pot", Decimal(230)),
            ("show_down", False),
            ("winners", ("FatalRevange", )),
            ("board", (Card("8h"), Card("4h"), Card("Tc"))),
            (
                "extra",
                dict(
                    tournament_name="MiniFTOPS Main Event",
                    turn_pot=None,
                    turn_num_players=None,
                    river_pot=None,
                    river_num_players=None,
                ),
            ),
        ],
    )
    def test_body(self, hand, attribute, expected_value):
        assert getattr(hand, attribute) == expected_value

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            (
                "actions",
                (
                    _PlayerAction("JohnyyR", Action.CHECK, None),
                    _PlayerAction("FatalRevange", Action.THINK, None),
                    _PlayerAction("FatalRevange", Action.BET, Decimal(120)),
                    _PlayerAction("JohnyyR", Action.FOLD, None),
                    _PlayerAction("FatalRevange", Action.RETURN, Decimal(120)),
                    _PlayerAction("FatalRevange", Action.MUCK, None),
                    _PlayerAction("FatalRevange", Action.WIN, Decimal(230)),
                ),
            ),
            ("cards", (Card("8h"), Card("4h"), Card("Tc"))),
            ("is_rainbow", False),
            ("is_monotone", False),
            ("is_triplet", False),
            # TODO: http://www.pokerology.com/lessons/flop-texture/
            # assert flop.is_dry
            ("has_pair", False),
            ("has_straightdraw", True),
            ("has_gutshot", True),
            ("has_flushdraw", True),
            ("players", ("JohnyyR", "FatalRevange")),
            ("pot", Decimal(230)),
        ],
    )
    def test_flop_attributes(self, hand, attribute, expected_value):
        assert getattr(hand.flop, attribute) == expected_value

    def test_flop(self, hand):
        assert isinstance(hand.flop, _Street)
Ejemplo n.º 9
0
class TestAllinPreflopHand:
    hand_text = stars_hands.HAND2

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("ident", "105034215446"),
            ("game_type", GameType.TOUR),
            ("tournament_ident", "797536898"),
            ("tournament_level", "XI"),
            ("currency", Currency.USD),
            ("buyin", Decimal("3.19")),
            ("rake", Decimal("0.31")),
            ("game", Game.HOLDEM),
            ("limit", Limit.NL),
            ("sb", Decimal(400)),
            ("bb", Decimal(800)),
            ("date", ET.localize(datetime(2013, 10, 4, 17, 22, 20))),
        ],
    )
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("table_name", "797536898 9"),
            ("max_players", 9),
            (
                "button",
                _Player(
                    name="W2lkm2n", stack=11815, seat=2, combo=Combo("JdJs")),
            ),
            ("hero",
             _Player(name="W2lkm2n", stack=11815, seat=2,
                     combo=Combo("JdJs"))),
            (
                "players",
                [
                    _Player(
                        name="RichFatWhale", stack=12910, seat=1, combo=None),
                    _Player(name="W2lkm2n",
                            stack=11815,
                            seat=2,
                            combo=Combo("JdJs")),
                    _Player(name="Labahra", stack=7395, seat=3, combo=None),
                    _Player(name="Lean Abadia", stack=7765, seat=4,
                            combo=None),
                    _Player(name="lkenny44", stack=10080, seat=5, combo=None),
                    _Player(name="Newfie_187", stack=1030, seat=6, combo=None),
                    _Player(name="Hokolix", stack=13175, seat=7, combo=None),
                    _Player(name="pmmr", stack=2415, seat=8, combo=None),
                    _Player(name="costamar",
                            stack=13070,
                            seat=9,
                            combo=Combo('AcKd')),
                ],
            ),
            ("board",
             (Card("3c"), Card("6s"), Card("9d"), Card("8d"), Card("Ks"))),
            (
                "preflop",
                (_Street([
                    "",
                    "Labahra: posts small blind 400",
                    "Lean Abadia: posts big blind 800",
                    "lkenny44: folds",
                    "Newfie_187: raises 155 to 955 and is all-in",
                    "Hokolix: folds",
                    "pmmr: folds",
                    "costamar: raises 12040 to 12995 and is all-in",
                    "RichFatWhale: folds",
                    "W2lkm2n: calls 11740 and is all-in",
                    "Labahra: folds",
                    "Lean Abadia: folds",
                    "Uncalled bet (1255) returned to costamar",
                ])),
            ),
            (
                "turn",
                (_Street([
                    "[3c 6s 9d] [8d]",
                ])),
            ),
            (
                "river",
                (_Street([
                    "[3c 6s 9d 8d] [Ks]",
                ])),
            ),
            ("total_pot", Decimal(26310)),
            (
                "show_down",
                (_Street([
                    "", "costamar collected 21570 from side pot",
                    "costamar collected 4740 from main pot"
                ])),
            ),
            ("winners", ("costamar", )),
        ],
    )
    def test_body(self, hand, attribute, expected_value):
        attribute = getattr(hand, attribute)
        if (attribute is not None) & isinstance(attribute, _Street):
            assert attribute.actions == expected_value.actions
            assert attribute.cards == expected_value.cards
        else:
            assert attribute == expected_value

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("actions", None),
            ("cards", (Card("3c"), Card("6s"), Card("9d"))),
            ("is_rainbow", True),
            ("is_monotone", False),
            ("is_triplet", False),
            # TODO: http://www.pokerology.com/lessons/flop-texture/
            # assert flop.is_dry
            ("has_pair", False),
            ("has_straightdraw", True),
            ("has_gutshot", True),
            ("has_flushdraw", False),
            ("players", None),
        ],
    )
    def test_flop_attributes(self, hand, attribute, expected_value):
        assert getattr(hand.flop, attribute) == expected_value

    def test_flop(self, hand):
        assert isinstance(hand.flop, _Street)
Ejemplo n.º 10
0
class TestBodyMissingPlayerNoBoard:
    hand_text = stars_hands.HAND3

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("ident", "105026771696"),
            ("game_type", GameType.TOUR),
            ("tournament_ident", "797469411"),
            ("tournament_level", "X"),
            ("currency", Currency.USD),
            ("buyin", Decimal("3.19")),
            ("rake", Decimal("0.31")),
            ("game", Game.HOLDEM),
            ("limit", Limit.NL),
            ("sb", Decimal(300)),
            ("bb", Decimal(600)),
            ("date", ET.localize(datetime(2013, 10, 4, 14, 50, 56))),
        ],
    )
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("table_name", "797469411 11"),
            ("max_players", 9),
            (
                "button",
                _Player(
                    name="W2lkm2n", stack=10714, seat=8, combo=Combo("6d8d")),
            ),
            ("hero",
             _Player(name="W2lkm2n", stack=10714, seat=8,
                     combo=Combo("6d8d"))),
            (
                "players",
                [
                    _Player(name="Empty Seat 1", stack=0, seat=1, combo=None),
                    _Player(name="snelle_jel", stack=4295, seat=2, combo=None),
                    _Player(
                        name="EuSh0wTelm0", stack=11501, seat=3, combo=None),
                    _Player(name="panost3", stack=7014, seat=4, combo=None),
                    _Player(name="Samovlyblen", stack=7620, seat=5,
                            combo=None),
                    _Player(name="Theralion", stack=4378, seat=6, combo=None),
                    _Player(name="wrsport1015", stack=9880, seat=7,
                            combo=None),
                    _Player(name="W2lkm2n",
                            stack=10714,
                            seat=8,
                            combo=Combo("6d8d")),
                    _Player(name="fischero68", stack=8724, seat=9, combo=None),
                ],
            ),
            ("turn", None),
            ("river", None),
            ("board", None),
            (
                "preflop",
                (_Street([
                    "",
                    "fischero68: posts small blind 300",
                    "snelle_jel: posts big blind 600",
                    "EuSh0wTelm0: folds",
                    "panost3: folds",
                    "Samovlyblen: folds",
                    "Theralion: raises 600 to 1200",
                    "wrsport1015: folds",
                    "W2lkm2n: folds",
                    "fischero68: folds",
                    "snelle_jel: folds",
                    "Uncalled bet (600) returned to Theralion",
                    "Theralion collected 1900 from pot",
                    "Theralion: doesn't show hand",
                ])),
            ),
            ("total_pot", Decimal(1900)),
            ("show_down", None),
            ("winners", ("Theralion", )),
        ],
    )
    def test_body(self, hand, attribute, expected_value):
        attribute = getattr(hand, attribute)
        if (attribute is not None) & isinstance(attribute, _Street):
            assert attribute.actions == expected_value.actions
            assert attribute.cards == expected_value.cards
        else:
            assert attribute == expected_value

    def test_flop(self, hand):
        assert hand.flop is None
Ejemplo n.º 11
0
class TestHandWithFlopOnly:
    hand_text = stars_hands.HAND1

    # in py.test 2.4 it is recommended to use string like "attribute,expected",
    # but with tuple, it works in both 2.3.5 and 2.4
    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("ident", "105024000105"),
            ("game_type", GameType.TOUR),
            ("tournament_ident", "797469411"),
            ("tournament_level", "I"),
            ("currency", Currency.USD),
            ("buyin", Decimal("3.19")),
            ("rake", Decimal("0.31")),
            ("game", Game.HOLDEM),
            ("limit", Limit.NL),
            ("sb", Decimal(10)),
            ("bb", Decimal(20)),
            ("date", ET.localize(datetime(2013, 10, 4, 13, 53, 27))),
        ],
    )
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("table_name", "797469411 15"),
            ("max_players", 9),
            ("button", _Player(name="flettl2", stack=1500, seat=1,
                               combo=None)),
            ("hero",
             _Player(name="W2lkm2n", stack=3000, seat=5, combo=Combo("AcJh"))),
            (
                "players",
                [
                    _Player(name="flettl2", stack=1500, seat=1, combo=None),
                    _Player(name="santy312", stack=3000, seat=2, combo=None),
                    _Player(name="flavio766", stack=3000, seat=3, combo=None),
                    _Player(name="strongi82", stack=3000, seat=4, combo=None),
                    _Player(name="W2lkm2n",
                            stack=3000,
                            seat=5,
                            combo=Combo("AcJh")),
                    _Player(
                        name="MISTRPerfect", stack=3000, seat=6, combo=None),
                    _Player(
                        name="blak_douglas", stack=3000, seat=7, combo=None),
                    _Player(name="sinus91", stack=1500, seat=8, combo=None),
                    _Player(name="STBIJUJA", stack=1500, seat=9, combo=None),
                ],
            ),
            ("turn", None),
            ("river", None),
            ("board", (Card("2s"), Card("6d"), Card("6h"))),
            (
                "preflop",
                (_Street([
                    "", "santy312: posts small blind 10",
                    "flavio766: posts big blind 20", "strongi82: folds",
                    "W2lkm2n: raises 40 to 60", "MISTRPerfect: calls 60",
                    "blak_douglas: folds", "sinus91: folds", "STBIJUJA: folds",
                    "flettl2: folds", "santy312: folds", "flavio766: folds"
                ])),
            ),
            ("turn", None),
            ("river", None),
            ("total_pot", Decimal(150)),
            ("show_down", None),
            ("winners", ("W2lkm2n", )),
        ],
    )
    def test_body(self, hand, attribute, expected_value):
        attribute = getattr(hand, attribute)
        if isinstance(attribute, _Street):
            assert attribute.actions == expected_value.actions
            assert attribute.cards == expected_value.cards
        else:
            assert attribute == expected_value

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            (
                "actions",
                (
                    _PlayerAction("W2lkm2n", Action.BET, Decimal(80)),
                    _PlayerAction("MISTRPerfect", Action.FOLD, None),
                    _PlayerAction("W2lkm2n", Action.RETURN, Decimal(80)),
                    _PlayerAction("W2lkm2n", Action.WIN, Decimal(150)),
                    _PlayerAction("W2lkm2n", Action.MUCK, None),
                ),
            ),
            ("cards", (Card("2s"), Card("6d"), Card("6h"))),
            ("is_rainbow", True),
            ("is_monotone", False),
            ("is_triplet", False),
            # TODO: http://www.pokerology.com/lessons/flop-texture/
            # assert flop.is_dry
            ("has_pair", True),
            ("has_straightdraw", False),
            ("has_gutshot", True),
            ("has_flushdraw", False),
            ("players", ("W2lkm2n", "MISTRPerfect"))
        ],
    )
    def test_flop_attributes(self, hand, attribute, expected_value):
        assert getattr(hand.flop, attribute) == expected_value

    def test_flop(self, hand):
        assert isinstance(hand.flop, _Street)
Ejemplo n.º 12
0
class TestTournamentHand:
    hand_text = stars_hands.HAND7

    # in py.test 2.4 it is recommended to use string like "attribute,expected",
    # but with tuple, it works in both 2.3.5 and 2.4
    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("ident", "212626281897"),
            ("game_type", GameType.TOUR),
            ("tournament_ident", "2878387134"),
            ("tournament_level", "I"),
            ("currency", Currency.USD),
            ("buyin", Decimal("0.02")),
            ("rake", Decimal("0.00")),
            ("game", Game.HOLDEM),
            ("limit", Limit.NL),
            ("sb", Decimal(25)),
            ("bb", Decimal(50)),
            ("date", ET.localize(datetime(2020, 4, 24, 12, 16, 54))),
        ],
    )
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("table_name", "2878387134 4"),
            ("max_players", 9),
            ("button",
             _Player(name="Pavs777_89", stack=1500, seat=1, combo=None)),
            ("hero",
             _Player(name="Stickyfinger55",
                     stack=1500,
                     seat=6,
                     combo=Combo("TcKc"))),
            (
                "players",
                [
                    _Player(name="Pavs777_89", stack=1500, seat=1, combo=None),
                    _Player(name="lrb3", stack=1500, seat=2, combo=None),
                    _Player(name="ADINA.MM", stack=1500, seat=3, combo=None),
                    _Player(name="SARA CONAR",
                            stack=1500,
                            seat=4,
                            combo=Combo('5c5h')),
                    _Player(name="mikaela1209", stack=1500, seat=5,
                            combo=None),
                    _Player(name="Stickyfinger55",
                            stack=1500,
                            seat=6,
                            combo=Combo("TcKc")),
                    _Player(
                        name="Cold_Siemens13", stack=1500, seat=7, combo=None),
                    _Player(
                        name="igor82828282", stack=1500, seat=8, combo=None),
                    _Player(name="conor1409", stack=1500, seat=9, combo=None),
                ],
            ),
            ("board",
             (Card("4c"), Card("7s"), Card("8h"), Card("4h"), Card("As"))),
            (
                "preflop",
                (_Street([
                    "",
                    "lrb3: posts small blind 25",
                    "ADINA.MM: posts big blind 50",
                    "SARA CONAR: raises 1440 to 1490 and is all-in",
                    "mikaela1209: folds",
                    "Stickyfinger55: folds",
                    "Cold_Siemens13: folds",
                    "igor82828282: folds",
                    "conor1409: folds",
                    "Pavs777_89: folds",
                    "lrb3: calls 1465 and is all-in",
                    "ADINA.MM: folds",
                ])),
            ),
            (
                "turn",
                (_Street([
                    "[4c 7s 8h] [4h]",
                ])),
            ),
            (
                "river",
                (_Street([
                    "[4c 7s 8h 4h] [As]",
                ])),
            ),
            ("total_pot", Decimal(3120)),
            (
                "show_down",
                (_Street([
                    "",
                    "SARA CONAR collected 3120 from pot",
                ])),
            ),
            ("winners", ("SARA CONAR", )),
        ],
    )
    def test_body(self, hand, attribute, expected_value):
        attribute = getattr(hand, attribute)
        if (attribute is not None) & isinstance(attribute, _Street):
            assert attribute.actions == expected_value.actions
            assert attribute.cards == expected_value.cards
        else:
            assert attribute == expected_value
Ejemplo n.º 13
0
class TestVillainCardsParsed:
    hand_text = stars_hands.HAND12

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            ("button",
             _Player(name="sindyeichelbaum",
                     stack=Decimal('0.63'),
                     seat=8,
                     combo=Combo("Ad9h"))),  #Combo("Ad9h"))),
            ("hero",
             _Player(name="pokerhero",
                     stack=Decimal('2.0'),
                     seat=2,
                     combo=Combo("Th5s"))),
            (
                "players",
                [
                    _Player(name='Empty Seat 1', stack=0, seat=1, combo=None),
                    _Player(name="pokerhero",
                            stack=Decimal('2.0'),
                            seat=2,
                            combo=Combo("Th5s")),
                    _Player(name="oeggel",
                            stack=Decimal('2.05'),
                            seat=3,
                            combo=None),
                    _Player(name="3_Socks420",
                            stack=Decimal('0.96'),
                            seat=4,
                            combo=None),
                    _Player(name="Laandris09",
                            stack=Decimal('3.55'),
                            seat=5,
                            combo=None),
                    _Player(name="Ammageddon",
                            stack=Decimal('3.48'),
                            seat=6,
                            combo=None),
                    _Player(name="BigSiddyB",
                            stack=Decimal('2.93'),
                            seat=7,
                            combo=Combo("AsQh")),
                    _Player(name="sindyeichelbaum",
                            stack=Decimal('0.63'),
                            seat=8,
                            combo=Combo("Ad9h")),
                    _Player(name="masterhodge",
                            stack=Decimal('1.80'),
                            seat=9,
                            combo=None),
                ],
            ),
            ("board",
             (Card("3c"), Card("3h"), Card("3s"), Card("7c"), Card("Ks"))),
            ("total_pot", Decimal('1.29')),
        ],
    )
    def test_body(self, hand, attribute, expected_value):
        assert getattr(hand, attribute) == expected_value
Ejemplo n.º 14
0
class TestHandWithFlopTurnRiver:
    hand_text = ftp_hands.TURBO_SNG

    @pytest.mark.parametrize('attribute,expected_value', [
        ('game_type', GameType.SNG),
        ('sb', Decimal(15)),
        ('bb', Decimal(30)),
        ('date', ET.localize(datetime(2014, 6, 29, 5, 57, 1))),
        ('game', Game.HOLDEM),
        ('limit', Limit.NL),
        ('ident', '34374264321'),
        ('tournament_ident', '268569961'),
        ('table_name', '1'),
        ('tournament_level', None),
        ('buyin', Decimal(10)),
        ('rake', None),
        ('currency', Currency.USD),
    ])
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize('attribute,expected_value', [
        ('players', [
            _Player(name='snake 422', stack=1500, seat=1, combo=None),
            _Player(name='IgaziFerfi', stack=1500, seat=2,
                    combo=Combo('5d2h')),
            _Player(name='MixaOne', stack=1500, seat=3, combo=None),
            _Player(name='BokkaBlake', stack=1500, seat=4, combo=None),
            _Player(name='Sajiee', stack=1500, seat=5, combo=None),
            _Player(name='AzzzJJ', stack=1500, seat=6, combo=None),
        ]),
        ('button', _Player(name='AzzzJJ', stack=1500, seat=6, combo=None)),
        ('max_players', 6),
        ('hero',
         _Player(name='IgaziFerfi', stack=1500, seat=2, combo=Combo('5d2h'))),
        ('preflop_actions', (
            'MixaOne calls 30',
            'BokkaBlake folds',
            'Sajiee folds',
            'AzzzJJ raises to 90',
            'snake 422 folds',
            'IgaziFerfi folds',
            'MixaOne calls 60',
        )),
        ('turn', None),
        ('turn_actions', None),
        ('river', None),
        ('river_actions', None),
        ('total_pot', Decimal('285')),
        ('show_down', False),
        ('winners', ('AzzzJJ', )),
        ('board', (Card('6s'), Card('9c'), Card('3d'))),
        ('extra',
         dict(tournament_name='$10 Sit & Go (Turbo)',
              turn_pot=None,
              turn_num_players=None,
              river_pot=None,
              river_num_players=None)),
    ])
    def test_body(self, hand, attribute, expected_value):
        assert getattr(hand, attribute) == expected_value

    @pytest.mark.parametrize(
        ('attribute', 'expected_value'),
        [
            ('actions', (
                ('MixaOne', Action.BET, Decimal(30)),
                ('AzzzJJ', Action.RAISE, Decimal(120)),
                ('MixaOne', Action.FOLD),
                ('AzzzJJ', Action.RETURN, Decimal(90)),
                ('AzzzJJ', Action.MUCK),
                ('AzzzJJ', Action.WIN, Decimal(285)),
            )),
            ('cards', (Card('6s'), Card('9c'), Card('3d'))),
            ('is_rainbow', True),
            ('is_monotone', False),
            ('is_triplet', False),
            # TODO: http://www.pokerology.com/lessons/flop-texture/
            # assert flop.is_dry
            ('has_pair', False),
            ('has_straightdraw', True),
            ('has_gutshot', True),
            ('has_flushdraw', False),
            ('players', ('MixaOne', 'AzzzJJ')),
            ('pot', Decimal(285))
        ])
    def test_flop_attributes(self, hand, attribute, expected_value):
        assert getattr(hand.flop, attribute) == expected_value

    def test_flop(self, hand):
        assert isinstance(hand.flop, _Flop)
Ejemplo n.º 15
0
class TestAllinPreflopHand:
    hand_text = stars_hands.HAND2

    @pytest.mark.parametrize(('attribute', 'expected_value'), [
        ('ident', '105034215446'),
        ('game_type', GameType.TOUR),
        ('tournament_ident', '797536898'),
        ('tournament_level', 'XI'),
        ('currency', Currency.USD),
        ('buyin', Decimal('3.19')),
        ('rake', Decimal('0.31')),
        ('game', Game.HOLDEM),
        ('limit', Limit.NL),
        ('sb', Decimal(400)),
        ('bb', Decimal(800)),
        ('date', ET.localize(datetime(2013, 10, 4, 17, 22, 20))),
    ])
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(('attribute', 'expected_value'), [
        ('table_name', '797536898 9'),
        ('max_players', 9),
        ('button',
         _Player(name='W2lkm2n', stack=11815, seat=2, combo=Combo('JdJs'))),
        ('hero',
         _Player(name='W2lkm2n', stack=11815, seat=2, combo=Combo('JdJs'))),
        ('players', [
            _Player(name='RichFatWhale', stack=12910, seat=1, combo=None),
            _Player(name='W2lkm2n', stack=11815, seat=2, combo=Combo('JdJs')),
            _Player(name='Labahra', stack=7395, seat=3, combo=None),
            _Player(name='Lean Abadia', stack=7765, seat=4, combo=None),
            _Player(name='lkenny44', stack=10080, seat=5, combo=None),
            _Player(name='Newfie_187', stack=1030, seat=6, combo=None),
            _Player(name='Hokolix', stack=13175, seat=7, combo=None),
            _Player(name='pmmr', stack=2415, seat=8, combo=None),
            _Player(name='costamar', stack=13070, seat=9, combo=None),
        ]),
        ('turn', Card('8d')),
        ('river', Card('Ks')),
        ('board',
         (Card('3c'), Card('6s'), Card('9d'), Card('8d'), Card('Ks'))),
        ('preflop_actions',
         ("lkenny44: folds", "Newfie_187: raises 155 to 955 and is all-in",
          "Hokolix: folds", "pmmr: folds",
          "costamar: raises 12040 to 12995 and is all-in",
          "RichFatWhale: folds", "W2lkm2n: calls 11740 and is all-in",
          "Labahra: folds", "Lean Abadia: folds",
          "Uncalled bet (1255) returned to costamar")),
        ('turn_actions', None),
        ('river_actions', None),
        ('total_pot', Decimal(26310)),
        ('show_down', True),
        ('winners', ('costamar', )),
    ])
    def test_body(self, hand, attribute, expected_value):
        assert getattr(hand, attribute) == expected_value

    @pytest.mark.parametrize(
        ('attribute', 'expected_value'),
        [
            ('actions', None),
            ('cards', (Card('3c'), Card('6s'), Card('9d'))),
            ('is_rainbow', True),
            ('is_monotone', False),
            ('is_triplet', False),
            # TODO: http://www.pokerology.com/lessons/flop-texture/
            # assert flop.is_dry
            ('has_pair', False),
            ('has_straightdraw', True),
            ('has_gutshot', True),
            ('has_flushdraw', False),
            ('players', None),
        ])
    def test_flop_attributes(self, hand, attribute, expected_value):
        assert getattr(hand.flop, attribute) == expected_value

    def test_flop(self, hand):
        assert isinstance(hand.flop, _Street)

    @pytest.mark.xfail
    def test_flop_pot(self, hand):
        assert hand.flop.pot == Decimal(26310)
Ejemplo n.º 16
0
class TestHandWithFlopOnly:
    hand_text = ftp_hands.HAND1

    @pytest.mark.parametrize(('attribute', 'expected_value'), [
        ('game_type', GameType.TOUR),
        ('sb', Decimal(10)),
        ('bb', Decimal(20)),
        ('date', ET.localize(datetime(2013, 9, 22, 13, 26, 50))),
        ('game', Game.HOLDEM),
        ('limit', Limit.NL),
        ('ident', '33286946295'),
        ('tournament_ident', '255707037'),
        ('table_name', '179'),
        ('tournament_level', None),
        ('buyin', None),
        ('rake', None),
        ('currency', None),
    ])
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize('attribute,expected_value', [
        ('players', [
            _Player(name='Popp1987', stack=13587, seat=1, combo=None),
            _Player(name='Luckytobgood', stack=10110, seat=2, combo=None),
            _Player(name='FatalRevange', stack=9970, seat=3, combo=None),
            _Player(
                name='IgaziFerfi', stack=10000, seat=4, combo=Combo('Ks9d')),
            _Player(name='egis25', stack=6873, seat=5, combo=None),
            _Player(name='gamblie', stack=9880, seat=6, combo=None),
            _Player(name='idanuTz1', stack=10180, seat=7, combo=None),
            _Player(name='PtheProphet', stack=9930, seat=8, combo=None),
            _Player(name='JohnyyR', stack=9840, seat=9, combo=None),
        ]),
        ('button', _Player(name='egis25', stack=6873, seat=5, combo=None)),
        ('max_players', 9),
        ('hero',
         _Player(name='IgaziFerfi', stack=10000, seat=4, combo=Combo('Ks9d'))),
        ('preflop_actions',
         ('PtheProphet has 15 seconds left to act', 'PtheProphet folds',
          'JohnyyR raises to 40', 'Popp1987 has 15 seconds left to act',
          'Popp1987 folds', 'Luckytobgood folds', 'FatalRevange raises to 100',
          'IgaziFerfi folds', 'egis25 folds', 'gamblie folds',
          'idanuTz1 folds', 'JohnyyR has 15 seconds left to act',
          'JohnyyR calls 60')),
        ('turn', None),
        ('river', None),
        ('total_pot', Decimal(230)),
        ('show_down', False),
        ('winners', ('FatalRevange', )),
        ('board', (Card('8h'), Card('4h'), Card('Tc'))),
        ('extra',
         dict(tournament_name='MiniFTOPS Main Event',
              turn_pot=None,
              turn_num_players=None,
              river_pot=None,
              river_num_players=None)),
    ])
    def test_body(self, hand, attribute, expected_value):
        assert getattr(hand, attribute) == expected_value

    @pytest.mark.parametrize(
        ('attribute', 'expected_value'),
        [
            ('actions', (
                ('JohnyyR', Action.CHECK),
                ('FatalRevange', Action.THINK),
                ('FatalRevange', Action.BET, Decimal(120)),
                ('JohnyyR', Action.FOLD),
                ('FatalRevange', Action.RETURN, Decimal(120)),
                ('FatalRevange', Action.MUCK),
                ('FatalRevange', Action.WIN, Decimal(230)),
            )),
            ('cards', (Card('8h'), Card('4h'), Card('Tc'))),
            ('is_rainbow', False),
            ('is_monotone', False),
            ('is_triplet', False),
            # TODO: http://www.pokerology.com/lessons/flop-texture/
            # assert flop.is_dry
            ('has_pair', False),
            ('has_straightdraw', True),
            ('has_gutshot', True),
            ('has_flushdraw', True),
            ('players', ('JohnyyR', 'FatalRevange')),
            ('pot', Decimal(230))
        ])
    def test_flop_attributes(self, hand, attribute, expected_value):
        assert getattr(hand.flop, attribute) == expected_value

    def test_flop(self, hand):
        assert isinstance(hand.flop, _Flop)
Ejemplo n.º 17
0
class TestHandWithFlopTurnRiver:
    hand_text = ftp_hands.TURBO_SNG

    @pytest.mark.parametrize(
        "attribute,expected_value",
        [
            ("game_type", GameType.SNG),
            ("sb", Decimal(15)),
            ("bb", Decimal(30)),
            ("date", ET.localize(datetime(2014, 6, 29, 5, 57, 1))),
            ("game", Game.HOLDEM),
            ("limit", Limit.NL),
            ("ident", "34374264321"),
            ("tournament_ident", "268569961"),
            ("table_name", "1"),
            ("tournament_level", None),
            ("buyin", Decimal(10)),
            ("rake", None),
            ("currency", Currency.USD),
        ],
    )
    def test_values_after_header_parsed(self, hand_header, attribute,
                                        expected_value):
        assert getattr(hand_header, attribute) == expected_value

    @pytest.mark.parametrize(
        "attribute,expected_value",
        [
            (
                "players",
                [
                    _Player(name="snake 422", stack=1500, seat=1, combo=None),
                    _Player(name="IgaziFerfi",
                            stack=1500,
                            seat=2,
                            combo=Combo("5d2h")),
                    _Player(name="MixaOne", stack=1500, seat=3, combo=None),
                    _Player(name="BokkaBlake", stack=1500, seat=4, combo=None),
                    _Player(name="Sajiee", stack=1500, seat=5, combo=None),
                    _Player(name="AzzzJJ", stack=1500, seat=6, combo=None),
                ],
            ),
            ("button", _Player(name="AzzzJJ", stack=1500, seat=6, combo=None)),
            ("max_players", 6),
            (
                "hero",
                _Player(
                    name="IgaziFerfi", stack=1500, seat=2,
                    combo=Combo("5d2h")),
            ),
            (
                "preflop_actions",
                (
                    "MixaOne calls 30",
                    "BokkaBlake folds",
                    "Sajiee folds",
                    "AzzzJJ raises to 90",
                    "snake 422 folds",
                    "IgaziFerfi folds",
                    "MixaOne calls 60",
                ),
            ),
            ("turn", None),
            ("turn_actions", None),
            ("river", None),
            ("river_actions", None),
            ("total_pot", Decimal("285")),
            ("show_down", False),
            ("winners", ("AzzzJJ", )),
            ("board", (Card("6s"), Card("9c"), Card("3d"))),
            (
                "extra",
                dict(
                    tournament_name="$10 Sit & Go (Turbo)",
                    turn_pot=None,
                    turn_num_players=None,
                    river_pot=None,
                    river_num_players=None,
                ),
            ),
        ],
    )
    def test_body(self, hand, attribute, expected_value):
        assert getattr(hand, attribute) == expected_value

    @pytest.mark.parametrize(
        ("attribute", "expected_value"),
        [
            (
                "actions",
                (
                    _PlayerAction("MixaOne", Action.BET, Decimal(30)),
                    _PlayerAction("AzzzJJ", Action.RAISE, Decimal(120)),
                    _PlayerAction("MixaOne", Action.FOLD, None),
                    _PlayerAction("AzzzJJ", Action.RETURN, Decimal(90)),
                    _PlayerAction("AzzzJJ", Action.MUCK, None),
                    _PlayerAction("AzzzJJ", Action.WIN, Decimal(285)),
                ),
            ),
            ("cards", (Card("6s"), Card("9c"), Card("3d"))),
            ("is_rainbow", True),
            ("is_monotone", False),
            ("is_triplet", False),
            # TODO: http://www.pokerology.com/lessons/flop-texture/
            # assert flop.is_dry
            ("has_pair", False),
            ("has_straightdraw", True),
            ("has_gutshot", True),
            ("has_flushdraw", False),
            ("players", ("MixaOne", "AzzzJJ")),
            ("pot", Decimal(285)),
        ],
    )
    def test_flop_attributes(self, hand, attribute, expected_value):
        assert getattr(hand.flop, attribute) == expected_value

    def test_flop(self, hand):
        assert isinstance(hand.flop, _Street)