def test_when_deck_order_cards_then_correct_reordering_occurs( cards, expected_card_names, descending): deck = Deck() reordered_cards = deck.order_cards(cards, descending=descending) reordered_card_names = [card.name for card in reordered_cards] assert reordered_card_names == expected_card_names
def test_when_deck_reset_then_cards_used_reset(cards_five): deck = Deck() deck.cards_used = cards_five.copy() deck.reset() assert deck.cards_used == []
def test_when_deck_draw_multiple_card_then_card_in_cards_used(cards_five): deck = Deck() deck.cards_available = cards_five.copy() drawn_cards = deck.draw(num=3) assert len(deck.cards_used) == 3 assert deck.cards_used == drawn_cards[:3]
def test_when_deck_draw_multiple_card_then_correct_card_returned(cards_five): deck = Deck() deck.cards_available = cards_five.copy() drawn_cards = deck.draw(num=3) assert len(drawn_cards) == 3 assert drawn_cards == cards_five[:3]
def test_when_deck_draw_nultiple_card_and_not_enough_cards_available_then_raise_error( ): deck = Deck() deck.cards_available = [] with raises(ValueError, match="Not enough cards left in the deck!"): deck.draw(num=3)
def test_when_deck_draw_single_card_then_card_in_cards_used(cards_five): deck = Deck() deck.cards_available = cards_five.copy() drawn_cards = deck.draw() assert len(deck.cards_used) == 1 assert deck.cards_used[0] == drawn_cards[0]
def test_when_deck_draw_single_card_then_correct_card_returned(cards_five): deck = Deck() deck.cards_available = cards_five.copy() drawn_cards = deck.draw() assert len(drawn_cards) == 1 assert drawn_cards[0] == cards_five[0]
def test_when_deck_shuffle_then_shuffle_command_used(): deck = Deck() with patch("pypoker.deck.random") as random_mock: deck.shuffle() random_mock.assert_has_calls([call.shuffle(deck.cards_available)])
def test_when_deck_draw_single_card_then_card_not_in_cards_available( cards_five): deck = Deck() deck.cards_available = cards_five.copy() drawn_cards = deck.draw() assert len(deck.cards_available) == 4 assert drawn_cards[0] not in deck.cards_available
def test_when_deck_order_cards_and_non_card_passed_then_raise_error(): deck = Deck() cards = [Card("C5"), "Six of Spades", Card("S9")] with raises( ValueError, match= "All objects within cards value must be an instance of the Cards Class" ): deck.order_cards(cards)
def test_when_deck_draw_multiple_card_then_card_not_in_cards_available( cards_five): deck = Deck() deck.cards_available = cards_five.copy() drawn_cards = deck.draw(num=3) assert len(deck.cards_available) == 2 for card in drawn_cards: assert card not in deck.cards_available
def test_when_deck_reset_then_cards_available_reset(cards_five, deck_card_names): deck = Deck() deck.cards_available = cards_five.copy() deck.reset() card_names = [] for card in deck.cards_available: card_names.append(card.name) assert len(deck.cards_available) == 52 assert card_names.sort() == deck_card_names.sort()
def test_when_deck_init_then_cards_available_correct(deck_card_names): deck = Deck() card_names = [] for card in deck.cards_available: card_names.append(card.name) assert len(deck.cards_available) == 52 assert card_names.sort() == deck_card_names.sort()
def _determine_unused_cards(player_cards, board_cards): """ private helper method that finds all of the possible remaining cards based on the hole and boaard cards that are known. :param player_cards: Dictionary, of player names and their hole cards :param board_cards: List of cards representing the current board cards :return: """ used_cards = board_cards.copy() for cards in player_cards.values(): used_cards.extend(cards) return [card for card in Deck().cards_all if card not in used_cards]
def test_when_deck_init_then_cards_used_correct(): deck = Deck() assert len(deck.cards_used) == 0