Пример #1
0
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)
Пример #2
0
 def initialize_hand(self):
     self.hand.hand = ([
         Card('♠', 'A'),
         Card('♣︎', '2'),
         Card('♦︎', 'K'),
         Card('♥', '10'),
         Card('♠', 'J')
     ])
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 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)
Пример #10
0
 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)
Пример #11
0
 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)
Пример #12
0
 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)
Пример #13
0
 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)
Пример #14
0
 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)
Пример #15
0
    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)
Пример #16
0
    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)
Пример #17
0
 def setUp(self):
     self.card1 = Card('♠︎', 'A')
     self.card2 = Card('♣︎', '2')
     self.card3 = Card('♦︎', 'K')
     self.card4 = Card('♥', '10')
Пример #18
0
 def test_draw(self):
     self.assertEqual(type(self.deck.draw()), type(Card('♠︎', 'A')))
     self.assertEqual(len(self.deck.deck_list), ((4 * 13) - 1))
Пример #19
0
 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)