Esempio n. 1
0
    def test_capitalised(self):
        for rank_, suit_ in itertools.product(ALL_RANKS, ALL_SUITS):
            if rank_.isnumeric():
                continue

            card = '{rank}_of_{suit}'.format(rank=rank_.upper(), suit=suit_)
            with self.assertRaises(ValueError):
                rank(card)
Esempio n. 2
0
    def test_complete(self):
        ranks = {}
        for card in ALL_CARDS:
            rank_ = rank(card)
            ranks[rank_] = ranks.get(rank_, 0) + 1

        self.assertEqual(
            ranks, {
                'Ace': 4,
                '2': 4,
                '3': 4,
                '4': 4,
                '5': 4,
                '6': 4,
                '7': 4,
                '8': 4,
                '9': 4,
                '10': 4,
                'Jack': 4,
                'Queen': 4,
                'King': 4,
                'Joker': 2,
            })
Esempio n. 3
0
 def test_invalid_suit(self):
     with self.assertRaises(ValueError):
         rank('11_of_Hearts')
Esempio n. 4
0
 def test_reversable(self):
     for rank_, suit_ in itertools.product(ALL_RANKS, ALL_SUITS):
         card = '{rank}_of_{suit}'.format(rank=rank_, suit=suit_)
         self.assertEqual(rank(card), rank_)
Esempio n. 5
0
 def test_flipped(self):
     for rank_, suit_ in itertools.product(ALL_RANKS, ALL_SUITS):
         card = '{suit}_of_{rank}'.format(rank=rank_, suit=suit_)
         with self.assertRaises(ValueError):
             rank(card)
Esempio n. 6
0
 def test_jokers(self):
     self.assertEqual(rank('Red_Joker'), 'Joker')
     self.assertEqual(rank('Black_Joker'), 'Joker')
Esempio n. 7
0
 def test_basic(self):
     self.assertEqual(rank('Ace_of_Spades'), 'Ace')