Coverage for test\test_card.py: 83%

29 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2024-11-18 00:10 +0000

1from Card import twoStartCards, decodeStartHandValue, StartCardRank 

2 

3 

4def test_twoStartCards(): 

5 # Test pair 

6 result = twoStartCards(4, "d", 4, "c") 

7 assert result == 29 

8 

9 # Test suited 

10 result = twoStartCards(10, "h", 12, "h") 

11 assert result == 139 

12 

13 # Test unsuited 

14 result = twoStartCards(6, "s", 9, "c") 

15 assert result == 60 

16 

17 # Test invalid cards 

18 result = twoStartCards(1, "d", 15, "h") 

19 assert result == 170 

20 

21 # Test invalid value 

22 result = twoStartCards(5, "d", 18, "s") 

23 assert result == 170 

24 

25 

26def test_decodeStartHandValue(): 

27 # Test holdem game 

28 assert decodeStartHandValue("holdem", 169) == "AA" 

29 assert decodeStartHandValue("6_holdem", 166) == "AJs" 

30 

31 # Test razz game 

32 assert decodeStartHandValue("razz", 260) == "(T2)3" 

33 assert decodeStartHandValue("27_razz", 200) == "(9A)6" 

34 

35 # Test unknown game 

36 assert decodeStartHandValue("unknown_game", 123) == "xx" 

37 

38 

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) 

43 

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) 

47 

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) 

51 

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) 

55 

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)