class TestCard(unittest.TestCase): def setUp(self): self.card1 = Card('♠︎', 'A') self.card2 = Card('♣︎', '2') self.card3 = Card('♦︎', 'K') self.card4 = Card('♥', '10') def test_set_card_number(self): self.assertEqual(self.card1.num, 'A') self.assertEqual(self.card2.num, '2') self.assertEqual(self.card3.num, 'K') self.assertEqual(self.card4.num, '10') def test_set_card_suit(self): self.assertEqual(self.card1.suit, '♠︎') self.assertEqual(self.card2.suit, '♣︎') self.assertEqual(self.card3.suit, '♦︎') self.assertEqual(self.card4.suit, '♥') def test_set_card_value(self): self.assertEqual(self.card1.value, '♠︎A') self.assertEqual(self.card2.value, '♣︎2') self.assertEqual(self.card3.value, '♦︎K') self.assertEqual(self.card4.value, '♥10') def test_card_number(self): self.assertEqual(self.card1.card_number(), 1) self.assertEqual(self.card2.card_number(), 2) self.assertEqual(self.card3.card_number(), 13) self.assertEqual(self.card4.card_number(), 10)
def initialize_hand(self): self.hand.hand = ([ Card('♠', 'A'), Card('♣︎', '2'), Card('♦︎', 'K'), Card('♥', '10'), Card('♠', 'J') ])
def test_is_royal_true(self): self.hand.hand = [ Card('♠︎', 'A'), Card('♠︎', '10'), Card('♠︎', 'J'), Card('♠︎', 'Q'), Card('♠︎', 'K') ] self.assertEqual(self.straight_flash.is_royal(self.hand), True)
def test_is_royal_false(self): self.hand.hand = [ Card('♠︎', '9'), Card('♠︎', '10'), Card('♠︎', 'J'), Card('♠︎', 'Q'), Card('♠︎', 'K') ] self.assertEqual(self.straight_flash.is_royal(self.hand), False)
def test_check_is_True(self): self.hand.hand = [ Card('♠︎', '3'), Card('♣︎', '3'), Card('♦︎', '5'), Card('♥', '4'), Card('♠︎', '9') ] self.one_pair.check(self.hand) self.assertEqual(self.one_pair.result, True)
def test_check_is_True(self): self.hand.hand = [ Card('♠︎', 'A'), Card('♠︎', '3'), Card('♠︎', '5'), Card('♠︎', '7'), Card('♠︎', '9') ] self.flash.check(self.hand) self.assertEqual(self.flash.result, True)
def test_check_is_True(self): self.hand.hand = [ Card('♠︎', '3'), Card('♣︎', '3'), Card('♦︎', '3'), Card('♥', '4'), Card('♠︎', '9') ] self.three_card.check(self.hand) self.assertEqual(self.three_card.result, True)
def test_check_is_False(self): self.hand.hand = [ Card('♠︎', 'A'), Card('♦', '3'), Card('♠︎', '5'), Card('♦', '7'), Card('♠︎', '9') ] self.three_card.check(self.hand) self.assertEqual(self.three_card.result, False)
def test_check_is_True(self): self.hand.hand = [ Card('♠︎', 'A'), Card('♦', '2'), Card('♠︎', '3'), Card('♠︎', '4'), Card('♠︎', '5') ] self.straight.check(self.hand) self.assertEqual(self.straight.result, True)
def test_check_is_True_first_10(self): self.hand.hand = [ Card('♠︎', '10'), Card('♦', 'J'), Card('♠︎', 'Q'), Card('♠︎', 'K'), Card('♠︎', 'A') ] self.straight.check(self.hand) self.assertEqual(self.straight.result, True)
def test_check_is_False_when_two_pair(self): self.hand.hand = [ Card('♠︎', 'A'), Card('♦', 'A'), Card('♠︎', '5'), Card('♦', '5'), Card('♠︎', '9') ] self.one_pair.check(self.hand) self.assertEqual(self.one_pair.result, False)
def test_check_is_False(self): self.hand.hand = [ Card('♠︎', 'A'), Card('♦', '3'), Card('♠︎', '5'), Card('♦', '7'), Card('♠︎', '9') ] self.three_card.check(self.hand) self.one_pair.check(self.hand) self.full_house.check(self.hand, self.one_pair.result, self.three_card.result) self.assertEqual(self.full_house.result, False)
def test_check_is_True(self): self.hand.hand = [ Card('♠︎', '3'), Card('♣︎', '3'), Card('♦︎', '5'), Card('♥', '5'), Card('♠︎', '5') ] self.three_card.check(self.hand) self.one_pair.check(self.hand) self.full_house.check(self.hand, self.one_pair.result, self.three_card.result) self.assertEqual(self.full_house.result, True)
def test_check_is_False(self): self.hand.hand = [ Card('♠︎', 'A'), Card('♦', '3'), Card('♠︎', '5'), Card('♦', '7'), Card('♠︎', '9') ] self.flash.check(self.hand) self.straight.check(self.hand) flash_result = self.flash.result straight_result = self.straight.result self.straight_flash.check(self.hand, flash_result, straight_result) self.assertEqual(self.straight_flash.result, False)
def test_check_is_True(self): self.hand.hand = [ Card('♠︎', 'A'), Card('♠︎', '2'), Card('♠︎', '3'), Card('♠︎', '4'), Card('♠︎', '5') ] self.flash.check(self.hand) self.straight.check(self.hand) flash_result = self.flash.result straight_result = self.straight.result self.straight_flash.check(self.hand, flash_result, straight_result) self.assertEqual(self.straight_flash.result, True)
def test_check_royal_straight_flash(self): self.hand.hand = [ Card('♠︎', 'A'), Card('♠︎', '10'), Card('♠︎', 'J'), Card('♠︎', 'Q'), Card('♠︎', 'K') ] self.flash.check(self.hand) self.straight.check(self.hand) self.straight_flash.check(self.hand, self.flash.result, self.straight.result) self.assertEqual(self.straight_flash.result, True) self.assertEqual(self.straight_flash.porker_hand, 'RoyalStraightFlash') self.assertEqual(self.straight_flash.is_royal(self.hand), True)
def setUp(self): self.card1 = Card('♠︎', 'A') self.card2 = Card('♣︎', '2') self.card3 = Card('♦︎', 'K') self.card4 = Card('♥', '10')
def test_draw(self): self.assertEqual(type(self.deck.draw()), type(Card('♠︎', 'A'))) self.assertEqual(len(self.deck.deck_list), ((4 * 13) - 1))
def test_cut(self): self.hand.add(Card('♠︎', '1')) self.assertEqual(len(self.hand.hand), 1) self.hand.cut(0) self.assertEqual(len(self.hand.hand), 0)