Coverage for test\test_winamax.py: 100%

58 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-27 18:50 +0000

1import re 

2import pytest 

3 

4substitutions = { 

5 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes 

6 'LS' : r"\$|\xe2\x82\xac|\u20ac|" 

7 # legal currency symbols - Euro(cp1252, utf-8) 

8 } 

9 

10re_Identify = re.compile(r'Winamax\sPoker\s\-\s(CashGame|Go\sFast|HOLD\-UP|Tournament\s\")') 

11 

12def test_re_Identify(): 

13 text = 'Winamax Poker - HOLD-UP "Colorado" - HandId: #18876587-492053-1695486636 - Holdem no limit (0.01€/0.02€) - 2023/09/23 16:30:36 UTC' 

14 match = re_Identify.search(text) 

15 assert match is not None 

16 

17 

18re_HandInfo = re.compile(r""" 

19\s*Winamax\sPoker\s-\s(?P<RING>(CashGame|Go\sFast\s\"[^\"]+\"|HOLD\-UP\s\"[^\"]+\"))?(?P<TOUR>Tournament\s(?P<TOURNAME>.+)?\sbuyIn:\s(?P<BUYIN>(?P<BIAMT>[%(LS)s\d\,.]+)?(\s\+?\s|-)(?P<BIRAKE>[%(LS)s\d\,.]+)?\+?(?P<BOUNTY>[%(LS)s\d\.]+)?\s?(?P<TOUR_ISO>%(LEGAL_ISO)s)?|(?P<FREETICKET>[\sa-zA-Z]+))?\s(level:\s(?P<LEVEL>\d+))?.*)?\s-\sHandId:\s\#(?P<HID1>\d+)-(?P<HID2>\d+)-(?P<HID3>\d+)\s-\s(?P<GAME>Holdem|Omaha|Omaha5|Omaha8|5\sCard\sOmaha|5\sCard\sOmaha\sHi/Lo|Omaha\sHi/Lo|7\-Card\sStud|7stud|7\-Card\sStud\sHi/Lo|7stud8|Razz|2\-7\sTriple\sDraw|Lowball27)\s(?P<LIMIT>fixed\slimit|no\slimit|pot\slimit)\s\((((%(LS)s)?(?P<ANTE>[.0-9]+)(%(LS)s)?)/)?((%(LS)s)?(?P<SB>[.0-9]+)(%(LS)s)?)/((%(LS)s)?(?P<BB>[.0-9]+)(%(LS)s)?)\)\s-\s(?P<DATETIME>.*)(Table:?\s\'(?P<TABLE>[^(]+)(.(?P<TOURNO>\d+).\#(?P<TABLENO>\d+))?.*\'\s(?P<MAXPLAYER>\d+)\-max\s(?P<MONEY>\(real\smoney\)))? 

20 """ % substitutions, re.MULTILINE|re.DOTALL|re.VERBOSE) 

21 

22 

23def test_re_HandInfo(): 

24 text = 'Winamax Poker - HOLD-UP "Colorado" - HandId: #18876587-492053-1695486636 - Holdem no limit (0.01€/0.02€) - 2023/09/23 16:30:36 UTC' 

25 match = re_HandInfo.search(text) 

26 assert match is not None 

27 

28def test_re_HandInfoexp(): 

29 text = 'Winamax Poker - Tournament "Expresso Nitro" buyIn: 0.23€ + 0.02€ level: 1 - HandId: #3011596205705658369-1-1695541274 - Holdem no limit (10/20) - 2023/09/24 07:41:14 UTC' 

30 match = re_HandInfo.search(text) 

31 assert match is not None 

32 assert match.group('TOURNAME') == '"Expresso Nitro"' 

33 assert match.group('BUYIN') == '0.23€ + 0.02€' 

34 assert match.group('BIAMT') == '0.23€' 

35 assert match.group('BIRAKE') == '0.02€' 

36 assert match.group('LEVEL') == '1' 

37 assert match.group('HID1') == '3011596205705658369' 

38 assert match.group('HID2') == '1' 

39 assert match.group('HID3') == '1695541274' 

40 assert match.group('GAME') == 'Holdem' 

41 assert match.group('LIMIT') == 'no limit' 

42 assert match.group('SB') == '10' 

43 assert match.group('BB') == '20' 

44 assert match.group('DATETIME') == '2023/09/24 07:41:14 UTC' 

45 

46 

47re_HUTP = re.compile(r'Hold\-up\sto\sPot:\stotal\s((%(LS)s)?(?P<AMOUNT>[.0-9]+)(%(LS)s)?)' % substitutions, re.MULTILINE|re.VERBOSE) 

48 

49def test_re_HUTP(): 

50 text = 'Hold-up to Pot: total 0.20€' 

51 match = re_HUTP.search(text) 

52 assert match is not None 

53 assert match.group('AMOUNT') == '0.20' 

54 

55 

56re_PostSB = re.compile(r"(?P<PNAME>.*?)\sposts\ssmall\sblind\s(%(LS)s)?(?P<SB>[\.0-9]+)(%(LS)s)?(?!\sout\sof\sposition)" % substitutions, re.MULTILINE) 

57 

58def test_re_PostSB(): 

59 text = 'LordShiva posts small blind 0.01€' 

60 match = re_PostSB.search(text) 

61 assert match is not None 

62 assert match.group('PNAME') == 'LordShiva' 

63 assert match.group('SB') == '0.01' 

64 

65 

66re_PostBB = re.compile(r"(?P<PNAME>.*?)\sposts\sbig\sblind\s(%(LS)s)?(?P<BB>[\.0-9]+)(%(LS)s)?" % substitutions, re.MULTILINE) 

67 

68def test_re_PostBB(): 

69 text = 'LordShiva posts big blind 0.01€' 

70 match = re_PostBB.search(text) 

71 assert match is not None 

72 assert match.group('PNAME') == 'LordShiva' 

73 assert match.group('BB') == '0.01' 

74 

75re_PlayerInfo = re.compile(r"Seat\s(?P<SEAT>[0-9]+):\s(?P<PNAME>.*)\s\((%(LS)s)?(?P<CASH>[.0-9]+)(%(LS)s)?(,\s(%(LS)s)?(?P<BOUNTY>[.0-9]+)(%(LS)s)?\sbounty)?\)" % substitutions) 

76 

77def test_re_PlayerInfo(): 

78 text = 'Seat 1: 77boy77 (0.60€)' 

79 match = re_PlayerInfo.search(text) 

80 assert match is not None 

81 assert match.group('SEAT') == '1' 

82 assert match.group('PNAME') == '77boy77' 

83 assert match.group('CASH') == '0.60'