def test_royal_straight_flush_true(self): cards = [] cards.append(Card('Spades', 'Ten')) cards.append(Card('Spades', 'Jack')) cards.append(Card('Spades', 'Queen')) cards.append(Card('Spades', 'King')) cards.append(Card('Spades', 'Ace')) pokerScore = review_score(cards) self.assertEqual(pokerScore.score == 'Royal Straight Flush', True)
def test_ace_straight_false(self): cards = [] cards.append(Card('Hearts', 'Ace')) cards.append(Card('Spades', 'Two')) cards.append(Card('Hearts', 'Two')) cards.append(Card('Hearts', 'Four')) cards.append(Card('Clubs', 'Five')) pokerScore = review_score(cards) self.assertEqual(pokerScore.score == 'Straight', False)
def test_full_house_true(self): cards = [] cards.append(Card('Spades', 'Two')) cards.append(Card('Hearts', 'Ten')) cards.append(Card('Clubs', 'Two')) cards.append(Card('Diamonds', 'Two')) cards.append(Card('Spades', 'Ten')) pokerScore = review_score(cards) self.assertEqual(pokerScore.score == 'Full House', True) self.assertEqual(pokerScore.get_top_card().rank == 'Two', True)
def test_two_pair_true(self): cards = [] cards.append(Card('Spades', 'Ten')) cards.append(Card('Hearts', 'Ten')) cards.append(Card('Clubs', 'Two')) cards.append(Card('Spades', 'Two')) cards.append(Card('Spades', 'Ace')) pokerScore = review_score(cards) self.assertEqual(pokerScore.score == 'Two Pair', True) self.assertEqual(pokerScore.get_top_card().rank == 'Ten', True)
def test_straight_true(self): cards = [] cards.append(Card('Spades', 'Ten')) cards.append(Card('Hearts', 'Jack')) cards.append(Card('Diamonds', 'Queen')) cards.append(Card('Spades', 'King')) cards.append(Card('Spades', 'Nine')) pokerScore = review_score(cards) self.assertEqual(pokerScore.score == 'Straight', True) self.assertEqual(pokerScore.get_top_card().rank == 'King', True)
def test_ace_straight_true(self): cards = [] cards.append(Card('Hearts', 'Ace')) cards.append(Card('Spades', 'Two')) cards.append(Card('Hearts', 'Three')) cards.append(Card('Hearts', 'Four')) cards.append(Card('Clubs', 'Five')) pokerScore = review_score(cards) self.assertEqual(pokerScore.score == 'Straight', True) # Ace should be low instead of high self.assertEqual(pokerScore.get_top_card().rank == 'Five', True)
def review_all_fiver_hands(self): if (len(self.seven_cards) != 7): raise Exception('Need seven cards') # review all the 5 cards combinations from given 7 cards scores = [] for comb_cards in list(combinations(self.seven_cards, 5)): pokerScore = review_score(comb_cards) scores.append(pokerScore) # return sorted score self.PokerScores = sorted(scores, key=lambda x: x.get_total_score(), reverse=True) return self.PokerScores