Esempio n. 1
0
 def test_suitdict_0Spades_counts0(self):
     cards = tools.convert_to_cards(['Kc', '2h'])
     expected = 0
     suitdict = evaluator.suit_dict(cards)
     # 0 is the default in case there are no Aces
     result = suitdict.get('s', 0)
     self.assertEqual(expected, result)
Esempio n. 2
0
 def test_rankdict_0Ace_counts0(self):
     cards = tools.convert_to_cards(['Kc', '2s'])
     expected = 0
     rankdict = evaluator.rank_dict(cards)
     # 0 is the default in case there are no Aces
     result = rankdict.get('A', 0)
     self.assertEqual(expected, result)
Esempio n. 3
0
 def test_ranklist_2Aces_2AcesCounted(self):
     cards = tools.convert_to_cards(['As', 'Ah'])
     ranklist = evaluator.rank_list(cards)
     expected_qty = ranklist[0][0]
     expected_rank = ranklist[0][1]
     self.assertTrue(
         expected_qty == 2, expected_rank == 'A')
Esempio n. 4
0
 def test_findbesthand_straight_returnsSTRAIGHT(self):
     cards = tools.convert_to_cards(['Ac', 'As', '2c', '3s', '4h', '5s', '5h'])
     besthand = evaluator.find_best_hand(cards)
     val = evaluator.get_value(besthand)
     expected = 'STRAIGHT'
     result = evaluator.get_type(val)
     self.assertEqual(expected, result)
Esempio n. 5
0
 def test_findbesthand_flush_returnsFLUSH(self):
     cards = tools.convert_to_cards(['8s', '9s', 'Tc', 'Js', 'Qs', 'Ks', 'Ac'])
     besthand = evaluator.find_best_hand(cards)
     val = evaluator.get_value(besthand)
     expected = 'FLUSH'
     result = evaluator.get_type(val)
     self.assertEqual(expected, result)
Esempio n. 6
0
 def test_findbesthand_quads_returnsQUADS(self):
     cards = tools.convert_to_cards(['Kc', 'Kd', 'Ks', 'Ac', 'Kd', 'Ah', 'As'])
     besthand = evaluator.find_best_hand(cards)
     val = evaluator.get_value(besthand)
     expected = 'QUADS'
     result = evaluator.get_type(val)
     self.assertEqual(expected, result)
Esempio n. 7
0
 def test_findbesthand_straightflush_returnsSTRAIGHTFLUSH(self):
     cards = tools.convert_to_cards(['4s', '5s', '6s', '7s', '8s', 'Ks', 'As'])
     besthand = evaluator.find_best_hand(cards)
     val = evaluator.get_value(besthand)
     expected = 'STRAIGHT FLUSH'
     result = evaluator.get_type(val)
     self.assertEqual(expected, result)
Esempio n. 8
0
 def test_findbesthand_fullhouse_returnsFULLHOUSE(self):
     cards = tools.convert_to_cards(['7c', '7s', 'Ks', 'Kc', 'Ah', 'Ac', 'As'])
     besthand = evaluator.find_best_hand(cards)
     val = evaluator.get_value(besthand)
     expected = 'FULL HOUSE'
     result = evaluator.get_type(val)
     self.assertEqual(expected, result)
Esempio n. 9
0
 def test_suitedcarddict_1Spade_listlenEquals1(self):
     cards = tools.convert_to_cards(['Kc', 'As'])
     expected = 1
     suitdict = evaluator.suitedcard_dict(cards)
     # Empty list is the default in case there are no Aces
     result = len(suitdict.get('s', []))
     self.assertEqual(expected, result)
Esempio n. 10
0
 def test_sort_3cards_deuceisfirst(self):
     cards = tools.convert_to_cards(['As', '7s', '2s'])
     d = deck.Deck(cards)
     d.sort()
     expected = '2'
     result = d.cards[0].rank
     self.assertEqual(expected, result)
Esempio n. 11
0
 def test_getdiscards_pick12_returnsCard0and1(self):
     cards = tools.convert_to_cards(['As', 'Ks', 'Qs'])
     h = hand.Hand(cards)
     picks = [1, 2]
     expected = [cards[0], cards[1]]
     result = discard.get_discards(h, picks)
     self.assertEqual(expected, result)
Esempio n. 12
0
 def test_findbesthand_pair_returnsPAIR(self):
     cards = tools.convert_to_cards(['2c', '3c', '5s', '7s', 'Kc', 'Ac', 'As'])
     besthand = evaluator.find_best_hand(cards)
     val = evaluator.get_value(besthand)
     expected = 'PAIR'
     result = evaluator.get_type(val)
     self.assertEqual(expected, result)
Esempio n. 13
0
 def test_str_2cards_returnsAsKsinParentheses(self):
     cards = tools.convert_to_cards(['As', 'Ks'])
     d = deck.Deck(cards)
     d.unhide()  # They are hidden by default
     expected = 'As Ks'
     result = str(d)
     self.assertEqual(expected, result)
Esempio n. 14
0
 def test_str_2cards_unhidden_returnsAs_Ks(self):
     cards = tools.convert_to_cards(['As', 'Ks'])
     h = hand.Hand(cards)
     h.unhide()
     expected = 'As Ks'
     result = str(h)
     self.assertEqual(expected, result)
Esempio n. 15
0
 def test_sort_unsortedhand_sortedafter(self):
     cards = tools.convert_to_cards(['5s', '6s', '4s'])
     h = hand.Hand(cards)
     h.sort()
     expected = [cards[2], cards[1], cards[0]]
     result = h.cards
     self.assertTrue(expected, result)
Esempio n. 16
0
    def test_getupcards_1up1down_returns1up(self):
        cards = tools.convert_to_cards(['As', 'Ks'])
        cards[0].hidden = False
        h = hand.Hand(cards)

        expected = 1
        result = len(h.get_upcards())
        self.assertEqual(expected, result)
Esempio n. 17
0
 def test_peek_AsKs_returnsString(self):
     cards = tools.convert_to_cards(['As', 'Ks'])
     #  c1 = card.color(cards[0].peek())
     #  c2 = card.color(cards[1].peek())
     h = hand.Hand(cards)
     expected = 'As Ks'
     result = h.peek()
     self.assertEqual(expected, result)
Esempio n. 18
0
 def test_converttocards_AsKs_returnsCardAsKs(self):
     As, Ks = card.Card('A', 's'), card.Card('K', 's')
     cardstr = ['As', 'Ks']
     expected = [As, Ks]
     result = tools.convert_to_cards(cardstr)
     self.assertEqual(expected, result)
Esempio n. 19
0
 def test_getallcombos_3cards_returns7(self):
     cards = tools.convert_to_cards(['As', 'Ks', 'Qs'])
     allcombos = combos.get_allcombos(cards)
     expected = 7
     result = len(allcombos)
     self.assertEqual(expected, result)
Esempio n. 20
0
 def test_getallcombos_1card_returns1(self):
     cards = tools.convert_to_cards(['As'])
     allcombos = combos.get_allcombos(cards)
     expected = 1
     result = len(allcombos)
     self.assertEqual(expected, result)
Esempio n. 21
0
 def test_removepairs_2345_returns2345(self):
     cards = tools.convert_to_cards(['2c', '3d', '4d', '5h'])
     result = evaluator.remove_pairs(cards)
     self.assertEqual(cards, result)
Esempio n. 22
0
 def test_len_2cards_haslen2(self):
     cards = tools.convert_to_cards(['As', 'Ks'])
     d = deck.Deck(cards)
     expected = 2
     result = len(d)
     self.assertEqual(expected, result)
Esempio n. 23
0
 def test_issuited_2unsuitedcard_returnsFalse(self):
     cards = tools.convert_to_cards(['As', 'Ad'])
     expected = False
     result = evaluator.is_suited(cards)
     self.assertEqual(expected, result)
Esempio n. 24
0
 def test_dominantsuit_HigherSpades_returnsSpades(self):
     cards = tools.convert_to_cards(['Ac', 'Ks', 'As', 'Qc'])
     expected = 's'
     result = evaluator.dominant_suit(cards)
     self.assertEqual(expected, result)
Esempio n. 25
0
 def test_removepairs_A223_returns23A(self):
     # Keep the first 2
     cards = tools.convert_to_cards(['As', '2h', '2c', '3d'])
     expected = tools.convert_to_cards(['2h', '3d', 'As'])
     result = evaluator.remove_pairs(cards)
     self.assertEqual(expected, result)
Esempio n. 26
0
 def test_removecards_removeAsKs_containsNeither(self):
     d = deck.Deck()
     cards = tools.convert_to_cards(['As', 'Ks'])
     d.remove_cards(cards)
     self.assertFalse(cards[0] in d)
     self.assertFalse(cards[1] in d)
Esempio n. 27
0
 def test_unhide_2cards_bothfaceup(self):
     cards = tools.convert_to_cards(['As', 'Ks'])
     d = deck.Deck(cards)
     d.unhide()
     self.assertTrue(d.cards[0].hidden is False)
     self.assertTrue(d.cards[1].hidden is False)
Esempio n. 28
0
 def test_peek_AsKs_stillhidden(self):
     cards = tools.convert_to_cards(['As', 'Ks'])
     h = hand.Hand(cards)
     h.peek()
     result = h.cards[0].hidden is True and h.cards[1].hidden is True
     self.assertTrue(result)
Esempio n. 29
0
 def test_issuited_2suitedcards_returnsTrue(self):
     cards = tools.convert_to_cards(['As', '2s'])
     expected = True
     result = evaluator.is_suited(cards)
     self.assertEqual(expected, result)
Esempio n. 30
0
 def test_removepairs_22_returns2(self):
     cards = tools.convert_to_cards(['2c', '2d'])
     expected = [card.Card('2', 'c')]
     result = evaluator.remove_pairs(cards)
     self.assertEqual(expected, result)