Exemple #1
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)
Exemple #2
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)
Exemple #3
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)
Exemple #4
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)
Exemple #5
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)
Exemple #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)
Exemple #7
0
class TestActionTypes():
    @pytest.mark.parametrize(
        ("action_line, expected"),
        [
            ({"MISTER FM is disconnected"}, None),
            ({"MISTER FM is connected"}, None),
            ({"susipoo: checks"},
             _PlayerAction(name="susipoo", action=Action.CHECK, amount=None)),
            ({"susipoo: folds"},
             _PlayerAction(name="susipoo", action=Action.FOLD, amount=None)),
            ({"susipoo: doesn't show hand "},
             _PlayerAction(name="susipoo", action=Action.MUCK, amount=None)),
            ({"Uncalled bet ($0.15) returned to susipoo"},
             _PlayerAction(name="susipoo",
                           action=Action.RETURN,
                           amount=Decimal('0.15'))),
            ({"susipoo collected $0.34 from pot"},
             _PlayerAction(
                 name="susipoo", action=Action.WIN, amount=Decimal('0.34'))),
            ({"Just God Spb: raises $0.10 to $0.15"},
             _PlayerAction(name="Just God Spb",
                           action=Action.RAISE,
                           amount=Decimal('0.15'))),
            ({"susipoo: bets $0.25"},
             _PlayerAction(
                 name="susipoo", action=Action.BET, amount=Decimal('0.25'))),
            ({"susipoo leaves the table"}, None),
            ({"susipoo cashed out the hand for $1.67 | Cash Out Fee $0.02"},
             _PlayerAction(name="susipoo",
                           action=Action.CASH_OUT,
                           amount=Decimal('1.67'))),
            ({"susipoo cashed out the hand for $1.53 | Cash Out Fee $0.02"},
             _PlayerAction(name="susipoo",
                           action=Action.CASH_OUT,
                           amount=Decimal('1.53'))),
            ({"susipoo cashed out the hand for $0.29"},
             _PlayerAction(name="susipoo",
                           action=Action.CASH_OUT,
                           amount=Decimal('0.29'))),
            ({"susipoo was removed from the table for failing to post"}, None),
        ],
    )
    def test_action_parsed(self, action_line, expected):
        street = _Street(["[\"2s 6d 6h]\""])
        street._parse_actions(action_line)
        if street.actions is not None:
            assert street.actions[0] == expected
        else:
            assert None is expected

    @pytest.mark.parametrize(
        ("action_line, expected"),
        [
            ({"Olefild1983: posts small blind $0.02"},
             _PlayerAction(name="Olefild1983",
                           action=Action.SB,
                           amount=Decimal('0.02'))),
            ({"flopec715: posts big blind $0.05"},
             _PlayerAction(
                 name="flopec715", action=Action.BB, amount=Decimal('0.05'))),
        ],
    )
    def test_blind_action_parsed(self, action_line, expected):
        street = _Street(["[\"2s 6d 6h]\""])
        street._parse_actions(action_line)
        if street.actions is not None:
            assert street.actions[0] == expected
        else:
            assert None is expected
Exemple #8
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)
Exemple #9
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)
Exemple #10
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)
Exemple #11
0
 def test_player_removed(self, hand):
     assert hand.preflop_actions[-1] == _PlayerAction('GenGen', Action.REMOVED, None)