Coverage for test\test_card.py: 83%
30 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-27 18:50 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-27 18:50 +0000
1import pytest
2from Card import twoStartCards, decodeStartHandValue, StartCardRank
5def test_twoStartCards():
6 # Test pair
7 result = twoStartCards(4, 'd', 4, 'c')
8 assert result == 29
10 # Test suited
11 result = twoStartCards(10, 'h', 12, 'h')
12 assert result == 139
14 # Test unsuited
15 result = twoStartCards(6, 's', 9, 'c')
16 assert result == 60
18 # Test invalid cards
19 result = twoStartCards(1, 'd', 15, 'h')
20 assert result == 170
22 # Test invalid value
23 result = twoStartCards(5, 'd', 18, 's')
24 assert result == 170
26def test_decodeStartHandValue():
27 # Test holdem game
28 assert decodeStartHandValue("holdem", 169) == "AA"
29 assert decodeStartHandValue("6_holdem", 166) == "AJs"
31 # Test razz game
32 assert decodeStartHandValue("razz", 260) == '(T2)3'
33 assert decodeStartHandValue("27_razz", 200) == '(9A)6'
35 # Test unknown game
36 assert decodeStartHandValue("unknown_game", 123) == "xx"
39def test_StartCardRank():
40 # Tests that the function returns the correct tuple for idx = 0
41 def test_idx_0(self):
42 assert StartCardRank(0) == ('22',54,12)
44 # Tests that the function returns the correct tuple for idx = 5
45 def test_idx_5(self):
46 assert StartCardRank(5) == ('72o',169,24)
48 # Tests that the function returns the correct tuple for idx = 14
49 def test_idx_13(self):
50 assert StartCardRank(13) == ('32s',111,8)
52 # Tests that the function returns the correct tuple for idx = 15
53 def test_idx_14(self):
54 assert StartCardRank(14) == ('33',53,12)
56 # Tests that the function returns the correct tuple for idx = 170
57 def test_idx_169(self):
58 assert StartCardRank(171) == ('xx',170,0)