def suits(self): cards = {} cards['spades'] = Card("Espadas") cards['clubs'] = Card("Paus") cards['hearts'] = Card("Copas") cards['diamonds'] = Card("Ouros") return cards
def fixed_hand(self): self.card1 = Card("Espadas", "A") self.card2 = self.card1.clone("3") self.card3 = self.card1.clone("2") cards = [] cards.append(self.card1) cards.append(self.card2) cards.append(self.card3) return Hand(cards)
def add_round_cards_to_players(self, round): player = round.match.game.pairs[0].players['player1'] card = Card("Paus", "4") round.add_round_card(player, card) player = round.match.game.pairs[0].players['player2'] card = Card("Espadas", "A") round.add_round_card(player, card) player = round.match.game.pairs[1].players['player1'] card = Card("Copas", "7") round.add_round_card(player, card) player = round.match.game.pairs[1].players['player2'] card = Card("Ouros", "7") round.add_round_card(player, card)
def test_add_round_card(self, round): player = round.match.game.pairs[0].players['player1'] card = Card("Paus", "4") round.add_round_card(player, card) result = round.round_cards expected = {player: card} assert result == expected
class TestHand: @pytest.fixture def hand(self, deck): cards = [] for i in range(1, 4): cards.append(deck.get_bottom_card()) return Hand(cards) @pytest.fixture def fixed_hand(self): self.card1 = Card("Espadas", "A") self.card2 = self.card1.clone("3") self.card3 = self.card1.clone("2") cards = [] cards.append(self.card1) cards.append(self.card2) cards.append(self.card3) return Hand(cards) def test_throw_one_card(self, hand): assert len(hand.cards) == 3 hand.throw_card() assert len(hand.cards) == 2 def test_throw_two_card(self, hand): assert len(hand.cards) == 3 hand.throw_card() hand.throw_card() assert len(hand.cards) == 1 def test_throw_two_card(self, hand): assert len(hand.cards) == 3 hand.throw_card() hand.throw_card() hand.throw_card() assert len(hand.cards) == 0 def test_throw_first_card(self, fixed_hand): fixed_hand.throw_card(1) assert self.card1 not in fixed_hand.cards def test_throw_second_card(self, fixed_hand): fixed_hand.throw_card(2) assert self.card2 not in fixed_hand.cards def test_throw_third_card(self, fixed_hand): fixed_hand.throw_card(3) assert self.card3 not in fixed_hand.cards def test_throw_card_on_position_out_of_range(self, fixed_hand): fixed_hand.throw_card(10) assert self.card1 not in fixed_hand.cards def test_throw_first_then_second_card(self, fixed_hand): fixed_hand.throw_card(1) assert self.card1 not in fixed_hand.cards fixed_hand.throw_card(2) assert self.card3 not in fixed_hand.cards def test_throw_first_then_third_card(self, fixed_hand): fixed_hand.throw_card(1) assert self.card1 not in fixed_hand.cards fixed_hand.throw_card(3) assert self.card2 not in fixed_hand.cards def test_throw_second_then_first_card(self, fixed_hand): fixed_hand.throw_card(2) assert self.card2 not in fixed_hand.cards fixed_hand.throw_card(1) assert self.card1 not in fixed_hand.cards def test_throw_second_then_third_card(self, fixed_hand): fixed_hand.throw_card(2) assert self.card2 not in fixed_hand.cards fixed_hand.throw_card(3) assert self.card1 not in fixed_hand.cards def test_throw_third_then_second_card(self, fixed_hand): fixed_hand.throw_card(3) assert self.card3 not in fixed_hand.cards fixed_hand.throw_card(2) assert self.card2 not in fixed_hand.cards def test_throw_third_then_first_card(self, fixed_hand): fixed_hand.throw_card(3) assert self.card3 not in fixed_hand.cards fixed_hand.throw_card(1) assert self.card1 not in fixed_hand.cards
def card(self): return Card("Copas", "3")