def test_cmp_shorter_and_longer_sequence_same_cards(self): score1 = HoldemPokerScore( HoldemPokerScore.NO_PAIR, [Card(14, 0), Card(11, 1), Card(10, 3), Card(9, 2), Card(7, 2)] ) score2 = HoldemPokerScore( HoldemPokerScore.NO_PAIR, [Card(14, 0), Card(11, 1), Card(10, 3), Card(9, 2)] ) self._test_cmp(score1, score2)
def test_cmp_same_categories(self): four_9 = HoldemPokerScore( HoldemPokerScore.QUADS, [Card(9, 3), Card(9, 2), Card(9, 1), Card(9, 0), Card(14, 2)] ) four_8 = HoldemPokerScore( HoldemPokerScore.QUADS, [Card(8, 3), Card(8, 2), Card(8, 1), Card(8, 0), Card(14, 0)] ) self._test_cmp(four_9, four_8)
def test_cmp_different_categories(self): highest_card = HoldemPokerScore( HoldemPokerScore.NO_PAIR, [Card(13, 0), Card(11, 1), Card(10, 1), Card(9, 0), Card(7, 2)] ) four_oak = HoldemPokerScore( HoldemPokerScore.QUADS, [Card(14, 3), Card(14, 2), Card(14, 1), Card(14, 0), Card(9, 0)] ) self._test_cmp(four_oak, highest_card)
def test_cmp_shorter_and_longer_sequence_different_ranks(self): # Even if score1 is a shorter sequence, it's still stronger than score2 because of the card ranks score1 = HoldemPokerScore( HoldemPokerScore.NO_PAIR, [Card(13, 0), Card(11, 1), Card(10, 3), Card(10, 2)] ) score2 = HoldemPokerScore( HoldemPokerScore.NO_PAIR, [Card(13, 0), Card(11, 1), Card(10, 3), Card(9, 2), Card(7, 2)] ) self._test_cmp(score1, score2)
def test_cmp_shorter_and_longer_sequence_same_ranks(self): # In this scenario, even if score2 has better cards according the the suits, score1 is still stronger as it has # the same ranks but it's a longer sequence. # When comparing two scores with a different sequence size, suits are not taken into account. score1 = HoldemPokerScore( HoldemPokerScore.NO_PAIR, [Card(13, 0), Card(11, 1), Card(10, 3), Card(9, 2), Card(7, 2)] ) score2 = HoldemPokerScore( HoldemPokerScore.NO_PAIR, [Card(13, 3), Card(11, 3), Card(10, 3), Card(9, 2)] ) self._test_cmp(score1, score2)
def test_cmp_AA_with_AA(self): score1 = HoldemPokerScore( HoldemPokerScore.PAIR, [Card(14, 3), Card(14, 2)] ) score2 = HoldemPokerScore( HoldemPokerScore.PAIR, [Card(14, 1), Card(14, 0)] ) self.assertEquals(0, score1.cmp(score2)) self.assertEquals(0, score2.cmp(score1))
def test_cmp_straight_flush(self): min_straight = HoldemPokerScore( HoldemPokerScore.STRAIGHT_FLUSH, [Card(5, 3), Card(4, 3), Card(3, 3), Card(2, 3), Card(14, 3)] ) max_straight = HoldemPokerScore( HoldemPokerScore.STRAIGHT_FLUSH, [Card(14, 2), Card(13, 2), Card(12, 2), Card(11, 2), Card(10, 2)] ) self.assertLess(min_straight.cmp(max_straight), 0) self.assertGreater(max_straight.cmp(min_straight), 0)
def test_cmp_same_cards(self): score1 = HoldemPokerScore( HoldemPokerScore.NO_PAIR, [Card(14, 0), Card(11, 1), Card(10, 3), Card(9, 2), Card(7, 2)] ) score2 = HoldemPokerScore( HoldemPokerScore.NO_PAIR, [Card(14, 0), Card(11, 1), Card(10, 3), Card(9, 2), Card(7, 2)] ) self.assertEqual(score1.cmp(score2), 0) self.assertEqual(score2.cmp(score1), 0)
def test_get_category(self): category = HoldemPokerScore.STRAIGHT_FLUSH cards = [Card(14, 2), Card(13, 2), Card(12, 2), Card(11, 2), Card(10, 2)] score = HoldemPokerScore(category, cards) self.assertEqual(score.category, category)