Coverage for test\test_winamax.py: 100%
57 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-18 00:10 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-18 00:10 +0000
1import re
3substitutions = {
4 "LEGAL_ISO": "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes
5 "LS": r"\$|\xe2\x82\xac|\u20ac|",
6 # legal currency symbols - Euro(cp1252, utf-8)
7}
9re_Identify = re.compile(r"Winamax\sPoker\s\-\s(CashGame|Go\sFast|HOLD\-UP|Tournament\s\")")
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
18re_HandInfo = re.compile(
19 r"""
20\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\)))?
21 """
22 % substitutions,
23 re.MULTILINE | re.DOTALL | re.VERBOSE,
24)
27def test_re_HandInfo():
28 text = 'Winamax Poker - HOLD-UP "Colorado" - HandId: #18876587-492053-1695486636 - Holdem no limit (0.01€/0.02€) - 2023/09/23 16:30:36 UTC'
29 match = re_HandInfo.search(text)
30 assert match is not None
33def test_re_HandInfoexp():
34 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'
35 match = re_HandInfo.search(text)
36 assert match is not None
37 assert match.group("TOURNAME") == '"Expresso Nitro"'
38 assert match.group("BUYIN") == "0.23€ + 0.02€"
39 assert match.group("BIAMT") == "0.23€"
40 assert match.group("BIRAKE") == "0.02€"
41 assert match.group("LEVEL") == "1"
42 assert match.group("HID1") == "3011596205705658369"
43 assert match.group("HID2") == "1"
44 assert match.group("HID3") == "1695541274"
45 assert match.group("GAME") == "Holdem"
46 assert match.group("LIMIT") == "no limit"
47 assert match.group("SB") == "10"
48 assert match.group("BB") == "20"
49 assert match.group("DATETIME") == "2023/09/24 07:41:14 UTC"
52re_HUTP = re.compile(
53 r"Hold\-up\sto\sPot:\stotal\s((%(LS)s)?(?P<AMOUNT>[.0-9]+)(%(LS)s)?)" % substitutions, re.MULTILINE | re.VERBOSE
54)
57def test_re_HUTP():
58 text = "Hold-up to Pot: total 0.20€"
59 match = re_HUTP.search(text)
60 assert match is not None
61 assert match.group("AMOUNT") == "0.20"
64re_PostSB = re.compile(
65 r"(?P<PNAME>.*?)\sposts\ssmall\sblind\s(%(LS)s)?(?P<SB>[\.0-9]+)(%(LS)s)?(?!\sout\sof\sposition)" % substitutions,
66 re.MULTILINE,
67)
70def test_re_PostSB():
71 text = "LordShiva posts small blind 0.01€"
72 match = re_PostSB.search(text)
73 assert match is not None
74 assert match.group("PNAME") == "LordShiva"
75 assert match.group("SB") == "0.01"
78re_PostBB = re.compile(
79 r"(?P<PNAME>.*?)\sposts\sbig\sblind\s(%(LS)s)?(?P<BB>[\.0-9]+)(%(LS)s)?" % substitutions, re.MULTILINE
80)
83def test_re_PostBB():
84 text = "LordShiva posts big blind 0.01€"
85 match = re_PostBB.search(text)
86 assert match is not None
87 assert match.group("PNAME") == "LordShiva"
88 assert match.group("BB") == "0.01"
91re_PlayerInfo = re.compile(
92 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)?\)"
93 % substitutions
94)
97def test_re_PlayerInfo():
98 text = "Seat 1: 77boy77 (0.60€)"
99 match = re_PlayerInfo.search(text)
100 assert match is not None
101 assert match.group("SEAT") == "1"
102 assert match.group("PNAME") == "77boy77"
103 assert match.group("CASH") == "0.60"