def test_not_straight(self): hand = [ Card("2", "Clubs"), Card("3", "Diamonds"), Card("4", "Hearts"), Card("5", "Diamonds") ] ranks = CheckRanks(hand) straight = Straight(ranks.list_ranks, ranks.list_suits) self.assertEqual(straight.is_valid, False)
def test_straight_and_extra(self): hand = [ Card("2", "Clubs"), Card("3", "Diamonds"), Card("4", "Hearts"), Card("5", "Diamonds"), Card("Queen", "Diamonds"), Card("Ace", "Diamonds"), Card("6", "Diamonds") ] ranks = CheckRanks(hand) straight = Straight(ranks.list_ranks, ranks.list_suits) self.assertEqual(straight.is_valid, True)
def test_straight_flush_return(self): hand = [ Card("2", "Diamonds"), Card("3", "Diamonds"), Card("4", "Diamonds"), Card("5", "Diamonds"), Card("7", "Clubs"), Card("8", "Clubs"), Card("6", "Diamonds"), ] expected_hand = [ Card("6", "Diamonds"), Card("5", "Diamonds"), Card("4", "Diamonds"), Card("3", "Diamonds"), Card("2", "Diamonds"), ] ranks = CheckRanks(hand) straight = Straight(ranks.list_ranks, ranks.list_suits) self.assertEqual(straight.high_straight, expected_hand)
def test_straight_return_higher(self): hand = [ Card("9", "Diamonds"), Card("3", "Diamonds"), Card("4", "Diamonds"), Card("5", "Diamonds"), Card("7", "Clubs"), Card("8", "Clubs"), Card("6", "Diamonds"), ] expected_hand = [ Card("9", "Diamonds"), Card("5", "Diamonds"), Card("7", "Clubs"), Card("8", "Clubs"), Card("6", "Diamonds"), ] expected_hand.sort(reverse=True) ranks = CheckRanks(hand) straight = Straight(ranks.list_ranks, ranks.list_suits) self.assertEqual(straight.high_straight, expected_hand)
def _check_for_straight(self, ranks, suits): straight = Straight(ranks, suits) if straight.is_valid: self._cards_in_hand = straight.cards self._set_hand("Straight", straight.value, straight.cards)