Coverage for test\test_juicy.py: 100%
39 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 re
2import pytest
5substitutions = {
6 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes
7 'LS' : r"\$|€|", # legal currency symbols - Euro(cp1252, utf-8)
8 'PLYR': r'(?P<PNAME>.+?)',
9 'CUR': r"(\$|€|)",
10 'NUM' :r".(,|\s)\d\xa0",
11 'NUM2': r'\b((?:\d{1,3}(?:\s\d{3})*)|(?:\d+))\b', # Regex pattern for matching numbers with spaces
12 }
14re_PlayerInfo = re.compile(r"""
15 ^Seat\s(?P<SEAT>[0-9]+):\s
16 (?P<PNAME>.+?)\s
17 \((%(LS)s)?(?P<CASH>[%(NUM)s]+)\sin\schips\)
18 (\s\s\(EUR\s(%(CUR)s)?(?P<EUROVALUE>[%(NUM)s]+)\))?""" % substitutions,
19 re.MULTILINE|re.VERBOSE)
21re_PlayerInfo2 = re.compile(r"""
22 ^Seat\s(?P<SEAT>[0-9]+):\s
23 (?P<PNAME>.+?)\s
24 \((%(LS)s)?(?P<CASH>[%(NUM2)s]+)\sin\schips\)
25 (\s\s\(EUR\s(%(CUR)s)?(?P<EUROVALUE>[%(NUM)s]+)\))?""" % substitutions,
26 re.MULTILINE|re.VERBOSE)
29def test_re_PlayerInfo2():
30 text = 'Seat 1: joker7 (1 200 in chips) '
31 match = re_PlayerInfo.search(text)
32 assert match is not None
33 assert match.group('SEAT') == '1'
34 assert match.group('PNAME') == 'joker7'
35 assert match.group('CASH') == '1 200'
37def test_re_PlayerInfo3():
38 text = 'Seat 1: joker7 (1 200 in chips) '
39 match = re_PlayerInfo2.search(text)
40 assert match is not None
41 assert match.group('SEAT') == '1'
42 assert match.group('PNAME') == 'joker7'
43 assert match.group('CASH') == '1 200'
45table_text = "Tournament: 17106061 Buy-In Freeroll : Table 10 - No Limit Holdem - 15/30"
46hand_text = "Hand#710910543B500014 - Freeroll to GOLD CHIPS T17122229 -- FREEROLL -- $0 + $0 -- 9 Max -- Table 4 -- 0/10/20 NL Hold'em -- 2023/09/22 - 17:35:27"
48re_GameInfo = re.compile(r"""
49 Hand\#(?P<HID>[A-Z0-9]+)\s+\-\s+(?P<TABLE>(?P<BUYIN1>(?P<BIAMT1>(%(LS)s)[%(NUM)s]+)\sNLH\s(?P<MAX1>\d+)\smax)?.+?)\s(\((Turbo,\s)?(?P<MAX>\d+)\-+[Mm]ax\)\s)?((?P<TOURNO>T\d+)|\d+)\s(\-\-\s(TICKET|CASH|TICKETCASH|FREEROLL)\s\-\-\s(?P<BUYIN>(?P<BIAMT>\$\d+)\s\+\s(?P<BIRAKE>\$\d+))\s\-\-\s(?P<TMAX>\d+)\sMax\s)?(\-\-\sTable\s(?P<TABLENO>\d+)\s)?\-\-\s(?P<CURRENCY>%(LS)s|)?(?P<ANTESB>(\-)?\d)/(%(LS)s)?(?P<SBBB>\d+)(/(%(LS)s)?(?P<BB>\d+))?\s(?P<LIMIT>NL|FL||PL)\s(?P<GAME>Hold\'em|Omaha|Omaha\sHi/Lo|OmahaHiLo)\s-\-\s(?P<DATETIME>.*$)
50 """ % substitutions, re.MULTILINE|re.VERBOSE)
52def test_re_GameInfo3():
53 text = "Hand#710910543B500014 - Freeroll to GOLD CHIPS T17122229 -- FREEROLL -- $0 + $0 -- 9 Max -- Table 4 -- 0/10/20 NL Hold'em -- 2023/09/22 - 17:35:27"
54 match = re_GameInfo.search(text)
55 assert match is not None
56 assert match.group('HID') == '710910543B500014'
57 assert match.group('TABLE') == 'Freeroll to GOLD CHIPS'
58 assert match.group('DATETIME') == '2023/09/22 - 17:35:27'
59 assert match.group('TABLENO') == '4'
60 assert match.group('BUYIN') == '$0 + $0'
61 assert match.group('TMAX') == '9'
62 assert match.group('BIAMT') == '$0'
63 assert match.group('BIRAKE') == '$0'
64 assert match.group('ANTESB') == '0'
65 assert match.group('SBBB') == '10'
66 assert match.group('BB') == '20'
67 assert match.group('LIMIT') == 'NL'
68 assert match.group('GAME') == 'Hold\'em'