Example #1
0
 def test_check_straight_flush(self):
     hand1 = '2C 3C 4C 5C 6C'
     hand2 = '2D 3S 4D 5S 6C'
     hand3 = '2C 8C 4C 5C 6C'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     self.assertTrue(check_straight_flush(cards1))
     self.assertFalse(check_straight_flush(cards2))
     self.assertFalse(check_straight_flush(cards3))
Example #2
0
 def test_get_score_straight_flush(self):
     hand1 = 'TC JC QC KC AC'
     hand2 = 'TD JS QD KS AC'
     hand3 = 'TC JC QC KC 9C'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     self.assertNotEqual(get_score(cards1), 9)
     self.assertNotEqual(get_score(cards2), 9)
     self.assertEqual(get_score(cards3), 9)
Example #3
0
 def test_check_royal_flush(self):
     hand1 = 'TC JC QC KC AC'
     hand2 = 'TD JS QD KS AC'
     hand3 = 'TC JC QC KC 9C'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     self.assertTrue(check_royal_flush(cards1))
     self.assertFalse(check_royal_flush(cards2))
     self.assertFalse(check_royal_flush(cards3))
Example #4
0
 def test_check_straight(self):
     hand1 = '2C 2C 2C 2C 6C'
     hand2 = '2D 3S 2D 2S 2C'
     hand3 = '2C 8C 4C 5C 6C'
     hand4 = 'TS JS QC KC AC'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     cards4 = create_readable_cards(hand4.split(' '))
     self.assertFalse(check_straight(cards1))
     self.assertFalse(check_straight(cards2))
     self.assertFalse(check_straight(cards3))
     self.assertTrue(check_straight(cards4))
Example #5
0
 def test_check_flush(self):
     hand1 = '2C 2C 2C 2C 6C'
     hand2 = '2D 3S 2D 2S 2C'
     hand3 = '2C 8C 4C 5C 6C'
     hand4 = '3S 2C 3C 3C 3C'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     cards4 = create_readable_cards(hand4.split(' '))
     self.assertTrue(check_if_same_suit(cards1['suits']))
     self.assertFalse(check_if_same_suit(cards2['suits']))
     self.assertTrue(check_if_same_suit(cards3['suits']))
     self.assertFalse(check_if_same_suit(cards4['suits']))
Example #6
0
 def test_check_full_house(self):
     hand1 = '2C 2C 2C 6C 6C'
     hand2 = '2D 3S 3D 2S 2C'
     hand3 = '2C 8C 4C 5C 6C'
     hand4 = '3S 2C 3C 3C 3C'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     cards4 = create_readable_cards(hand4.split(' '))
     self.assertTrue(check_full_house(cards1))
     self.assertTrue(check_full_house(cards2))
     self.assertFalse(check_full_house(cards3))
     self.assertFalse(check_full_house(cards4))
Example #7
0
 def test_get_score_straight(self):
     hand1 = '2C 2C 2C 2C 6C'
     hand2 = '2D 3S 2D 2S 2C'
     hand3 = '3C 7C 4S 5C 6C'
     hand4 = 'TS JS QC KC AC'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     cards4 = create_readable_cards(hand4.split(' '))
     self.assertNotEqual(get_score(cards1), 5)
     self.assertNotEqual(get_score(cards2), 5)
     self.assertEqual(get_score(cards3), 5)
     self.assertEqual(get_score(cards4), 5)
Example #8
0
 def test_get_score_flush(self):
     hand1 = '2C 2C 2C 2C 6C'
     hand2 = '2D 3S 2D 2S 2C'
     hand3 = '2C 8C 4C 5C 6C'
     hand4 = '3S 2C 3C 3C 3C'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     cards4 = create_readable_cards(hand4.split(' '))
     self.assertNotEqual(get_score(cards1), 6)
     self.assertNotEqual(get_score(cards2), 6)
     self.assertEqual(get_score(cards3), 6)
     self.assertNotEqual(get_score(cards4), 6)
Example #9
0
 def test_check_three_of_a_kind(self):
     hand1 = '2C 2C 2C 2C 6C'
     hand2 = '2D 3S 2D 2S 2C'
     hand3 = '2C 8C 4C 5C 6C'
     hand4 = '3S 2C 3C 3C 3C'
     hand5 = '3S 2C 6C 3C 3C'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     cards4 = create_readable_cards(hand4.split(' '))
     cards5 = create_readable_cards(hand5.split(' '))
     self.assertTrue(check_three_of_a_kind(cards1))
     self.assertTrue(check_three_of_a_kind(cards2))
     self.assertFalse(check_three_of_a_kind(cards3))
     self.assertTrue(check_three_of_a_kind(cards4))
     self.assertTrue(check_three_of_a_kind(cards5))
Example #10
0
 def test_get_score_one_pair(self):
     hand1 = '2C 2C 3S 4C 6C'
     hand2 = '2D 3S 2D 2S 2C'
     hand3 = '2C 8S 4C 8C 6C'
     hand4 = '3S 2C 3C 3C 2C'
     hand5 = '3S 2C 6C 7C 3C'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     cards4 = create_readable_cards(hand4.split(' '))
     cards5 = create_readable_cards(hand5.split(' '))
     self.assertEqual(get_score(cards1), 2)
     self.assertNotEqual(get_score(cards2), 2)
     self.assertEqual(get_score(cards3), 2)
     self.assertNotEqual(get_score(cards4), 2)
     self.assertEqual(get_score(cards5), 2)
Example #11
0
 def test_get_score_two_pairs(self):
     hand1 = '2C 2C 3C 3C 6S'
     hand2 = '2D 3S 4D 2S 2C'
     hand3 = '2C 2C 4S 5C 5C'
     hand4 = '3S 2C 3C 3C 2C'
     hand5 = '3S 2C 6C 3C 3C'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     cards4 = create_readable_cards(hand4.split(' '))
     cards5 = create_readable_cards(hand5.split(' '))
     self.assertEqual(get_score(cards1), 3)
     self.assertNotEqual(get_score(cards2), 3)
     self.assertEqual(get_score(cards3), 3)
     self.assertNotEqual(get_score(cards4), 3)
     self.assertNotEqual(get_score(cards5), 3)
Example #12
0
 def test_get_score_three_of_a_kind(self):
     hand1 = '2C 2C 2C 2C 6C'
     hand2 = '2D 3S 2D 2S 2C'
     hand3 = '2C 8C 4C 5C 6C'
     hand4 = '3S 2C 3C 3C 3C'
     hand5 = '3S 2C 6C 3C 3C'
     cards1 = create_readable_cards(hand1.split(' '))
     cards2 = create_readable_cards(hand2.split(' '))
     cards3 = create_readable_cards(hand3.split(' '))
     cards4 = create_readable_cards(hand4.split(' '))
     cards5 = create_readable_cards(hand5.split(' '))
     self.assertNotEqual(get_score(cards1), 4)
     self.assertNotEqual(get_score(cards2), 4)
     self.assertNotEqual(get_score(cards3), 4)
     self.assertNotEqual(get_score(cards4), 4)
     self.assertEqual(get_score(cards5), 4)