def test_figures_out_pair_is_best_rank(self): cards = [ Card(rank="Ace", suit="Spades"), Card(rank="Ace", suit="Clubs") ] validator = PairValidator(cards=cards) self.assertEqual(validator.is_valid(), True)
def test_validates_that_cards_have_exactly_one_pair(self): cards = [ Card(rank="Ace", suit="Spades"), Card(rank="Ace", suit="Clubs") ] validator = PairValidator(cards=cards) self.assertEqual(validator.is_valid(), True)
def test_validates_that_cards_have_a_pair(self): cards = [ Card(rank="Ace", suit="Diamonds"), Card(rank="Ace", suit="Hearts") ] validator = PairValidator(cards=cards) self.assertEqual(validator.is_valid(), True)
def test_valid_rank_is_pair(self): cards = [ Card(rank="5", suite="hearts"), Card(rank="7", suite="spades"), Card(rank="9", suite="clubs"), Card(rank="9", suite="diamonds"), Card(rank="King", suite="hearts") ] pair = PairValidator(cards=cards) self.assertEqual(pair.is_valid(), True)
def test_returns_pair_from_card_collection(self): ten_of_spades = Card(rank="10", suit="Spades") ten_of_clubs = Card(rank="10", suit="Clubs") cards = [ Card(rank="3", suit="Hearts"), Card(rank="5", suit="Diamonds"), ten_of_spades, ten_of_clubs, Card(rank="King", suit="Clubs") ] validator = PairValidator(cards=cards) self.assertEqual(validator.valid_cards(), [ten_of_spades, ten_of_clubs])
def test_returns_pair_from_card_collection(self): ten_of_spades = Card(rank='10', suit='Spades') ten_of_clubs = Card(rank='10', suit='Clubs') cards = [ Card(rank='3', suit='Hearts'), Card(rank='8', suit='Diamonds'), ten_of_spades, ten_of_clubs, Card(rank='Queen', suit='Spades') ] validator = PairValidator(cards=cards) self.assertEqual(validator.valid_cards(), [ten_of_spades, ten_of_clubs])
def test_valid_cards_making_a_pair(self): nine_diamonds = Card(rank="9", suite="diamonds") nine_clubs = Card(rank="9", suite="clubs") cards = [ Card(rank="5", suite="hearts"), Card(rank="7", suite="spades"), nine_diamonds, nine_clubs, Card(rank="King", suite="hearts") ] cards.sort() pair = PairValidator(cards=cards) self.assertEqual(pair.valid_cards(), [nine_clubs, nine_diamonds])
def valid_cards(self): three_of_a_kind_cards = ThreeOfAKindValidator( cards=self.cards).valid_cards() pair_cards = PairValidator(cards=self.cards).valid_cards() all_cards = three_of_a_kind_cards + pair_cards all_cards.sort() return all_cards
def test_returns_a_winning_hand_with_pair_from_card_collection(self): seven_of_diamonds = Card(rank="7", suit="Diamonds") seven_of_spades = Card(rank="7", suit="Spades") cards = [ Card(rank="2", suit="Spades"), Card(rank="5", suit="Spades"), seven_of_diamonds, seven_of_spades, Card(rank="8", suit="Diamonds"), Card(rank="10", suit="Clubs"), Card(rank="Queen", suit="Clubs") ] validator = PairValidator(cards=cards) self.assertEqual(validator.valid_cards(), [ Card(rank="8", suit="Diamonds"), Card(rank="10", suit="Clubs"), Card(rank="Queen", suit="Clubs"), seven_of_diamonds, seven_of_spades ])
def is_valid(self): return ThreeOfAKindValidator( cards=self.cards).is_valid() and PairValidator( cards=self.cards).is_valid()
def valid_cards(self): all_cards = (ThreeOfAKindValidator(cards=self.cards).valid_cards() + PairValidator(cards=self.cards).valid_cards()) all_cards.sort() return all_cards
def test_validates_that_cards_have_exectly_one_pair(self): cards = [Card(rank='8', suit='Diamonds'), Card(rank='8', suit='Clubs')] validator = PairValidator(cards=cards) self.assertEqual(validator.is_valid(), True)